2 # ==============================================================================
3 # portsreinstall library script
4 # Overlay onto lib/libcommand.sh for portsreinstall-chroot
5 # - Operations of commands as well as check of command line arguments -
6 # Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
7 # This software is distributed under the 2-Clause BSD License.
8 # ==============================================================================
10 # ============= Check the necessity of opening notice =============
11 command_all_chk_need_opening_notice ()
16 # ============= Execute command operations before getting the temporary database ready =============
17 command_all_exec_before_db_creation ()
19 local COMMAND_RESTART COMMAND_MODE COMMAND_OPERATION
25 COMMAND_OPERATION=${1:-normal}
27 _command_parse_args__chk_no_arg $#
28 case $COMMAND_OPERATION in
30 database_maintain_clean_force
38 # ============= Check and parse command line arguments =============
39 command_all_parse_args ()
48 COMMAND_OPERATION=${1:-normal}
50 case $COMMAND_OPERATION in
55 _command_parse_args__chk_no_arg $#
58 COMMAND_RESTART=$COMMAND_MODE
62 fs_inspect_fs_privilege
63 if ! fs_chk_mount > /dev/null && ! ( misc_chk_privilege )
65 message_echo "ERROR: The file system of the builder chroot environment is not yet ready." >&2
68 _command_parse_args__chk_no_arg $#
71 fs_inspect_fs_privilege
72 if fs_chk_mount > /dev/null
74 message_echo "INFO: Already mounted"
78 _command_parse_args__chk_no_arg $#
81 fs_inspect_fs_privilege
82 if fs_chk_unmount > /dev/null
84 message_echo "INFO: Already unmounted"
88 _command_parse_args__chk_no_arg $#
92 _command_parse_args__chk_no_arg $#
95 _command_parse_args__chk_no_arg $#
98 message_echo "ERROR: Invalid command [$COMMAND_MODE]." >&2
102 COMMAND_SHIFT=$(($num_args_init - $#))
105 # ============= Execute command operations which should be done without upgrade of tools =============
106 command_all_exec_before_tools_upgrade ()
108 case $COMMAND_MODE in
110 database_maintain_clean
111 [ $opt_no_opening_message = yes ] || message_echo "Done"
115 database_maintain_destroy
116 [ $opt_no_opening_message = yes ] || message_echo "Done"
124 command_do_chroot_cleanup
127 temp_reset_termination_messages_common
128 [ $opt_no_opening_message = yes ] || message_echo "Done"
132 if misc_chk_privilege
134 command_do_chroot_cleanup
137 elif ! fs_chk_mount > /dev/null
139 message_echo "ERROR: The file system of the builder chroot environment is not ready." >&2
142 command_do_chroot_enter_shell
143 if misc_chk_privilege
145 message_echo "Exited successfully"
146 program_deregister_stage_complete UPGRADE_GUEST
151 command_do_chroot_cleanup
154 command_do_update_host_files
155 [ $opt_no_opening_message = yes ] || message_echo "Done"
161 # ============= Execute command operations as the main process =============
162 command_all_exec_main ()
164 case $COMMAND_MODE in
166 command_do_chroot_cleanup
167 command_do_starter_portsnap
168 command_do_starter_pkg
170 command_do_starter_clean
171 command_do_main_init_resinst
172 command_do_chroot_enter_if_incomplete "$@"
174 command_do_ending_process