cat "${DBDIR}/recent_exit_status"
}
-# ============= Enter the guest =============
-command_do_chroot_enter ()
+# ============= Enter the shell of the guest =============
+command_do_chroot_enter_shell ()
{
local shellcmd exitstatus
message_cat <<eof
return $exitstatus
}
+# ============= Execute in the chroot environment automatically repeating by fixing the file systems =============
+_command_do_auto_repeat_by_fixing_fs ()
+{
+ until "$@" || ! command_do_chk_unionfs_error_at_chroot
+ do
+ message_echo "INFO: Retrying by re-mounting the file systems for the builder chroot environment." >&2
+ fs_unmount
+ fs_mount
+ done
+}
+
+# ============= Continue reinstallation in the guest =============
+command_do_chroot_enter_fullcourse ()
+{
+ local exitstatus opt_quiet
+ message_section_title "Full course main: Reinstallation process"
+ [ $opt_batch_mode = yes ] && opt_quiet='-a '
+ chroot "$opt_basedir"/builder /usr/bin/env ${PROGRAM} -S $opt_quiet
+ exitstatus=$?
+ echo "$exitstatus" > ${DBDIR}/recent_exit_status
+ return $exitstatus
+}
+
# ============= Enter the guest and execute portsreinstall(8) automatically =============
command_do_chroot_auto ()
{
- local exitstatus
+ local exitstatus opt_quiet
[ $opt_batch_mode = yes ] && opt_quiet='-a '
message_cat <<eof
=========================================================
Automatic execution inside the builder chroot environment:
-portsreinstall -S $opt_quiet $@
+portsreinstall -S $@
=========================================================
eof
return $exitstatus
}
+# ============= Enter the guest =============
+command_do_chroot_enter ()
+{
+ if [ $COMMAND_MODE = auto ]
+ then
+ [ $opt_fullcourse = yes ] && message_section_title "Full course main"
+ _command_do_auto_repeat_by_fixing_fs command_do_chroot_auto "$@"
+ elif [ $opt_fullcourse = no ]
+ then
+ if ! command_do_chroot_enter_shell
+ then
+ message_echo "INFO: The last exit status in the builder chroot environment was non-zero." >&2
+ command_do_chk_unionfs_error_at_chroot && \
+ message_echo "INFO: Executing ${APPNAME} again may be sufficient for the troubleshooting." >&2
+ fi
+ else
+ _command_do_auto_repeat_by_fixing_fs command_do_chroot_enter_fullcourse
+ fi
+ return `command_do_get_recent_chroot_exit_status`
+}
+
# ============= Update of the files affecting package installation of the host environment =============
command_do_update_host_files ()
{
local dirpath filepath
- message_echo "Updating the files affecting package installation (packages, distfiles, port options, ports/packages management tools configurations) of the host environment..."
+ [ "x$opt_share_port_pkgs_dirs" = xyes ] && return
+ message_section_title "Update the files affecting package installation of the host environment"
+ message_echo "INFO: targets are packages, distfiles, port options and ports/packages management tools configurations"
for dirpath in "${DISTDIR}" "${PACKAGES}" "${PORT_DBDIR}"
do
(
mkdir -p "$nodedir"
cp -p "$opt_basedir/builder$dirpath/$file" "$dirpath/$file"
done
- find -d $dirpath -type d -empty -delete
+ find -d $dirpath -mindepth 1 -type d -empty -delete
done
for filepath in "${LOCALBASE}"/etc/portsreinstall.conf "${LOCALBASE}"/etc/pkgtools.conf "${LOCALBASE}"/etc/pkg.conf /etc/make.conf "${DBDIR}"
do
rm -f $filepath
fi
done
- :
+ message_echo
}
# ============= Ending process =============
_program_exec_and_record_completion__operation ()
{
fs_destroy
+ message_echo
}
program_exec_and_record_completion CLEANUP_GUEST
}
{
if ! command_do_chk_build_completion
then
- message_echo "ERROR: Exited from the builder chroot environment without completing the build." >&2
- exit 1
+ message_echo "INFO: Exited from the builder chroot environment without completing the build." >&2
+ exit 130
fi
message_echo "INFO: The package build completed."
message_echo "Is it OK to apply the upgrade to the host environment? ([y]/n)"
if ! message_query_yn_default_yes
then
message_echo "INFO: Terminated because the continuation is stopped by the user."
- exit 1
+ exit 130
fi
}
-# ============= Enter the chroot environment =============
-command_do_chroot_enter_if_incomplete ()
+# ============= Starter process in the chroot environment: Update the ports tree =============
+command_do_starter_portsnap ()
{
local PROGRAM_DEPENDS
- command_do_chk_build_completion || program_deregister_stage_complete UPGRADE_GUEST
PROGRAM_DEPENDS='CLEANUP_GUEST'
_program_exec_and_record_completion__operation ()
{
- local exitstatus
+ local mode stdout
+ [ $opt_fullcourse = no ] && return
+ message_section_title "Full course starter: Update the ports tree"
+ pkgsys_update_portstree
message_echo
- if ! command_do_chroot_enter
+ }
+ program_exec_and_record_completion STARTER_GUEST_PORTS_TREE
+}
+
+# ============= Starter process of the full course: Update the package repository =============
+command_do_starter_pkg ()
+{
+ local PROGRAM_DEPENDS
+ PROGRAM_DEPENDS='STARTER_GUEST_PORTS_TREE'
+ _program_exec_and_record_completion__operation ()
+ {
+ local opts
+ [ $opt_fullcourse = no ] && return
+ message_section_title "Full course starter: Update the package repository"
+ pkg_update_pkgrepository
+ message_echo
+ }
+ program_exec_and_record_completion STARTER_GUEST_PKG_REPO
+}
+
+# ============= Starter process of the full course: Clean the temporary database =============
+command_do_starter_clean ()
+{
+ local PROGRAM_DEPENDS
+ PROGRAM_DEPENDS='STARTER_GUEST_PKG_REPO'
+ _program_exec_and_record_completion__operation ()
+ {
+ local opts
+ [ $opt_fullcourse = no ] && return
+ message_section_title "Full course starter: Clean the temporary database"
+ if [ $opt_batch_mode = no ]
then
- exitstatus=`command_do_get_recent_chroot_exit_status`
- message_echo "INFO: The last exit status in the builder chroot environment was non-zero." >&2
- command_do_chk_unionfs_error_at_chroot && \
- message_echo "INFO: Executing ${APPNAME} again may be sufficient for the troubleshooting." >&2
- exit $exitstatus
+ opts=
+ else
+ opts='-q'
fi
- command_do_chroot_postprocess
+ chroot "$opt_basedir"/builder /usr/bin/env ${PROGRAM} $opts clean force
+ message_echo
}
- program_exec_and_record_completion UPGRADE_GUEST
+ program_exec_and_record_completion STARTER_GUEST_CLEAN
}
-# ============= Enter the chroot environment and execute portsreinstall automatically =============
-command_do_auto_if_incomplete ()
+# ============= Main process in the chroot environment: Initiate the reinstallation process =============
+command_do_main_init_resinst ()
{
local PROGRAM_DEPENDS
- command_do_chk_build_completion || program_deregister_stage_complete UPGRADE_GUEST
- PROGRAM_DEPENDS='CLEANUP_GUEST'
+ PROGRAM_DEPENDS='STARTER_GUEST_CLEAN'
_program_exec_and_record_completion__operation ()
{
local exitstatus
+ [ $opt_fullcourse = no ] && return
+ message_section_title "Full course main: Initiate the reinstallation process"
+ opts=
+ [ $opt_batch_mode = yes ] && opts='-Ya'
+ chroot "$opt_basedir"/builder /usr/bin/env ${PROGRAM} -SJCGjqx $opts
message_echo
- until command_do_chroot_auto "$@" || ! command_do_chk_unionfs_error_at_chroot
- do
- message_echo "INFO: Retrying by re-mounting the file systems for the builder chroot environment." >&2
- fs_terminate_if_unmount_unavailable
- fs_unmount
- fs_mount
- done
+ }
+ program_exec_and_record_completion STARTER_GUEST_INIT_REINST
+}
+
+# ============= Enter the chroot environment =============
+command_do_chroot_enter_if_incomplete ()
+{
+ local PROGRAM_DEPENDS
+ command_do_chk_build_completion || program_deregister_stage_complete UPGRADE_GUEST
+ PROGRAM_DEPENDS='STARTER_GUEST_INIT_REINST'
+ _program_exec_and_record_completion__operation ()
+ {
+ local exitstatus
+ command_do_chroot_enter "$@"
exitstatus=`command_do_get_recent_chroot_exit_status`
[ "$exitstatus" -gt 0 ] && exit $exitstatus
command_do_chroot_postprocess
+ message_echo
}
program_exec_and_record_completion UPGRADE_GUEST "$@"
}
PROGRAM_DEPENDS='UPGRADE_GUEST'
_program_exec_and_record_completion__operation ()
{
- message_echo "Packing the upgrades..."
+ message_section_title "Pack the upgrades"
[ $opt_batch_mode = yes ] && opt_quiet='-a '
chroot "$opt_basedir"/builder /bin/csh -c "${PROGRAM} -S $opt_quiet packupgrade create && ${PROGRAM} -S $opt_quiet packupgrade crop /.${PROGRAM}"
}
PROGRAM_DEPENDS='UPDATE_HOST'
_program_exec_and_record_completion__operation ()
{
- message_echo "Extracting the upgrade archive..."
- (
- cd "$opt_basedir"/store
- rm -rf work
- mkdir work
- tar xzf portsreinstall-upgrade.tar.gz -C work
- )
+ local storedir
+ message_section_title "Extract the upgrade archive"
+ storedir=$opt_basedir/store
+ rm -rf "$storedir/work"
+ mkdir "$storedir/work"
+ tar xzf "$storedir/portsreinstall-upgrade.tar.gz" -C "$storedir/work"
+ message_echo
}
program_exec_and_record_completion EXTRACT_SCRIPT_ARCHIVE
PROGRAM_DEPENDS='EXTRACT_SCRIPT_ARCHIVE'
_program_exec_and_record_completion__operation ()
{
- message_echo "Updating the packages at the host environment..."
- (
- cd "$opt_basedir"/store
- opt_quiet=
- [ $opt_batch_mode = yes ] && opt_quiet='-a '
- work/portsreinstall-upgrade -S clean
- work/portsreinstall-upgrade -S $opt_quiet -P "${PACKAGES}/${PKGREPOSITORYSUBDIR}"
- )
+ local opt_quiet
+ message_section_title "Update the packages at the host environment"
+ opt_quiet=
+ [ $opt_batch_mode = yes ] && opt_quiet='-a '
+ $opt_basedir/store/work/portsreinstall-upgrade -S clean
+ $opt_basedir/store/work/portsreinstall-upgrade -S $opt_quiet -P "${PACKAGES}/${PKGREPOSITORYSUBDIR}"
}
program_exec_and_record_completion UPGRADE_HOST
}
# ============= Main pre-operation of do/auto =============
command_do_pre ()
{
- # Initial clean up
- command_do_chroot_cleanup
-
# Build and mount of the chroot environment
fs_build_chroot
- fs_terminate_if_mount_unavailable
fs_mount
}