cat "$tmp_fetch.main"
}
+# ============= Execute a command by recording the standard output and error output into a file in case of error =============
+reinstall_execcmd_tee_errlog ()
+{
+ local func tmp_err
+ func=$1
+ tmp_err=${TMPDIR}/reinstall_execcmd_tee_errlog::error
+ rm -f "$tmp_err"
+ { eval "$func"; } 2>&1 || touch "$tmp_err"; } | tee "$REINSTALL_DBNODE_DIR/error.log"
+ [ -e "$tmp_err" ] && return 1
+ rm -f "$REINSTALL_DBNODE_DIR/error.log"
+ return
+}
+
+# ============= Execute a command to output to stdout by recording the error output into a file in case of error =============
+reinstall_execcmd_getstdout_errlog ()
+{
+ local func
+ func=$1
+ if $func 2> $REINSTALL_DBNODE_DIR/error.log
+ then
+ rm -f "$REINSTALL_DBNODE_DIR/error.log"
+ return
+ fi
+ cat "$REINSTALL_DBNODE_DIR/error.log" >&2
+ return 1
+}
+
# ============= Reinstallation for a flavored origin =============
reinstall_exec ()
{
if ! reinstall_chk_stage_complete CHECK_SANITY
then
message_echo "Sanity Check..."
- if ! reinstall_make_anymode check-sanity > ${TMPDIR}/reinstall_exec:check-sanity.msg
+ _reinstall_exec__tmpcmd () { reinstall_make_anymode check-sanity; }
+ if ! check_sanity_msg=`reinstall_execcmd_getstdout_errlog _reinstall_exec__tmpcmd`
then
- cat "${TMPDIR}/reinstall_exec:check-sanity.msg"
+ echo "$check_sanity_msg"
reinstall_restore_if_temporarily_deinstalled
reinstall_errproc 'check sanity'
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
if [ $REINSTALL_IS_FROZEN = yes ]
then
message_echo "(Port to freeze)"
- pkg=`pkg_get_remote_repository_version "$REINSTALL_ORIGIN" || :`
- if [ -z "$pkg" ]
+ _reinstall_exec__tmpcmd () { pkg_get_remote_repository_version "$REINSTALL_ORIGIN"; }
+ if ! pkg=`reinstall_execcmd_getstdout_errlog _reinstall_exec__tmpcmd` || [ -z "$pkg" ]
then
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_restore_if_temporarily_deinstalled
reinstall_deinstall_old_ports
reinstall_deinstall
reinstall_backup_and_delete_remaining_install_conflicts__by_pkg "$pkg"
- if pkg_inst_remote "$pkg"
+ _reinstall_exec__tmpcmd () { pkg_inst_remote "$pkg"; }
+ if reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
then
message_echo "INFO: Deemed success."
message_echo "WARNING: This action may cause problems due to the version/option mismatch." >&2
! reinstall_chk_stage_complete BEFOREBUILD
then
message_echo "-- BEFOREBUILD operations (start)"
- if ! sh -e "$REINSTALL_DBNODE_DIR/BEFOREBUILD.conf"
+ _reinstall_exec__tmpcmd () { sh -e "$REINSTALL_DBNODE_DIR/BEFOREBUILD.conf"; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
then
reinstall_restore_if_temporarily_deinstalled
reinstall_errproc 'BEFOREBUILD operations'
fi
if [ $opt_fetch_only = no ] && ! reinstall_chk_stage_complete CLEAN_BEFORE_BUILD
then
- if ! reinstall_make_anymode clean
+ _reinstall_exec__tmpcmd () { reinstall_make_anymode clean; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
then
reinstall_restore_if_temporarily_deinstalled
reinstall_errproc 'clean before build'
if ! reinstall_chk_stage_complete FAILED_FETCH.RETRIAL_2
then
message_echo "INFO: Refetching distfiles as the second retrial for $REINSTALL_ORIGPKGTAG."
- if ! reinstall_make_anymode fetch FETCH_ARGS=-Ap
+ _reinstall_exec__tmpcmd () { reinstall_make_anymode fetch FETCH_ARGS=-Ap; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
then
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_restore_if_temporarily_deinstalled
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
return
fi
- if ! reinstall_make_anymode checksum
+ _reinstall_exec__tmpcmd () { reinstall_make_anymode checksum; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
then
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_restore_if_temporarily_deinstalled
reinstall_register_stage in_build
flag_restarted_build=no
fi
+ if reinstall_chk_stage in_retrial_build
+ then
+ message_echo "(Restarting the previously terminated retrial build process...)"
+ build_args='MAKE_JOBS_UNSAFE=yes'
+ else
+ build_args=
+ fi
if ! reinstall_chk_stage_complete BUILD
then
pkgsys_get_conflicting_installed_pkgs build "$REINSTALL_ORIGIN" \
then
message_echo "Found missing requirements:"
message_cat < ${TMPDIR}/reinstall_exec::missing_requirements
+ {
+ echo "Found missing requirements:"
+ cat "${TMPDIR}/reinstall_exec::missing_requirements"
+ } > "$REINSTALL_DBNODE_DIR/error.log"
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_restore_if_temporarily_deinstalled
reinstall_errproc 'check of missing packages'
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
return
fi
- if ! reinstall_make build
+ if ! reinstall_make build $build_args
then
+ reinstall_register_stage in_retrial_build
[ $flag_restarted_build = yes ] && message_echo "INFO: This failure may be due to restarting from a terminated build."
is_build_env_modified=no
if pkgsys_get_conflicting_installed_pkgs install "$REINSTALL_ORIGIN" \
reinstall_deinstall
is_build_env_modified=yes
fi
- if [ $flag_restarted_build = no -a $is_build_env_modified = no ]
- then
- if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
- then
- pkg_is_tool_available || pkg_rescue_tools
- fi
- reinstall_restore_conflicts "$REINSTALL_ORIGIN"
- reinstall_restore_if_temporarily_deinstalled
- reinstall_errproc 'build'
- temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
- return
- fi
reinstall_deregister_stage_complete CLEAN_BEFORE_BUILD
message_echo "INFO: Retrying the build process after cleaning for $REINSTALL_ORIGPKGTAG."
- reinstall_make clean || \
+ _reinstall_exec__tmpcmd () { reinstall_make clean; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
{
if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
then
return
}
reinstall_register_stage_complete CLEAN_BEFORE_BUILD
- reinstall_make build MAKE_JOBS_UNSAFE=yes || \
+ _reinstall_exec__tmpcmd () { reinstall_make build MAKE_JOBS_UNSAFE=yes; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
{
if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
then
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
return
}
+ reinstall_deregister_stage in_retrial_build
fi
if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
then
fi
reinstall_register_stage_complete BUILD
fi
+ reinstall_deregister_stage in_retrial_build
reinstall_deregister_stage in_build
if reinstall_chk_stage in_stage
then
fi
if ! reinstall_chk_stage_complete STAGE
then
- if ! reinstall_make stage
+ _reinstall_exec__tmpcmd () { reinstall_make stage; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
then
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_restore_if_temporarily_deinstalled
if [ -e "$REINSTALL_DBNODE_DIR/BEFOREDEINSTALL.conf" ] && ! reinstall_chk_stage_complete BEFOREDEINSTALL
then
message_echo "-- BEFOREDEINSTALL operations (start)"
- sh -e "$REINSTALL_DBNODE_DIR/BEFOREDEINSTALL.conf" || \
- {
+ _reinstall_exec__tmpcmd () { sh -e "$REINSTALL_DBNODE_DIR/BEFOREDEINSTALL.conf"; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
+ then
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_restore_if_temporarily_deinstalled
reinstall_errproc 'BEFOREDEINSTALL operations'
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
return
- }
+ fi
message_echo "-- BEFOREDEINSTALL operations (end)"
reinstall_register_stage_complete BEFOREDEINSTALL
fi
reinstall_make deinstall \
|| message_echo "WARNING: Continuing by hoping a success." >&2
message_echo "INFO: Retrying the installation."
- reinstall_make $insttarget MAKE_JOBS_UNSAFE=yes
+ _reinstall_exec__tmpcmd () { reinstall_make $insttarget MAKE_JOBS_UNSAFE=yes; }
+ reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
}
then
touch "$REINSTALL_DBNODE_DIR/installed_timestamp"
if [ -e "$REINSTALL_DBNODE_DIR/AFTERINSTALL.conf" ] && ! reinstall_chk_stage_complete AFTERINSTALL
then
message_echo "-- AFTERINSTALL operations (start)"
- sh -e "$REINSTALL_DBNODE_DIR/AFTERINSTALL.conf" || \
- {
+ _reinstall_exec__tmpcmd () { sh -e "$REINSTALL_DBNODE_DIR/AFTERINSTALL.conf"; }
+ if ! reinstall_execcmd_tee_errlog _reinstall_exec__tmpcmd
+ then
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
reinstall_errproc 'AFTERINSTALL operations'
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
return
- }
+ fi
message_echo "-- AFTERINSTALL operations (end)"
reinstall_register_stage_complete AFTERINSTALL
fi