# ============= Deinstallation of the currently installed package =============
reinstall_deinstall ()
{
- local tmp_installedpkg installed_pkgs
+ local tmp_installedpkg installed_pkgs dev_out dev_err
+ dev_out=/dev/stdout
+ dev_err=/dev/stderr
+ if [ $opt_batch_mode = yes ]
+ then
+ dev_out=/dev/null
+ dev_err=/dev/null
+ fi
tmp_installedpkg=${TMPDIR}/reinstall_deinstall:installedpkg
pkgsys_get_installed_pkg_from_origin "$REINSTALL_ORIGIN" > $tmp_installedpkg
[ `wc -l < $tmp_installedpkg` -gt 0 ] || return 0
done < $tmp_installedpkg
fi
message_echo "-- (Trying to deinstall by ports to make sure. This may cause negligible warnings.)"
- reinstall_make deinstall || \
+ reinstall_make deinstall > $dev_out 2> $dev_err|| \
{
message_echo "WARNING: Failed to deinstall $REINSTALL_CURRENTPKG by make deinstall." >&2
}
# ============= Recovery after failure of installation of the new package =============
reinstall_failed_install_recover ()
{
- local backedup_version backup_pkg
+ local backedup_version backup_pkg dev_out dev_err
+ dev_out=/dev/stdout
+ dev_err=/dev/stderr
+ if [ $opt_batch_mode = yes ]
+ then
+ dev_out=/dev/null
+ dev_err=/dev/null
+ fi
reinstall_chk_stage_complete FAILED_INSTALL.RECOVER && return
message_echo "INFO: Trying to deinstall the failed/terminated installation (Ignore failures)."
if [ -n "$REINSTALL_CURRENTPKG" ]
pkg_delete_f "$REINSTALL_CURRENTPKG" || :
fi
message_echo "INFO: Trying to deinstall by ports to make sure (This may cause negligible warnings)."
- reinstall_make deinstall || :
+ reinstall_make deinstall > $dev_out 2> $dev_err|| :
backedup_version=`cat "$REINSTALL_FROMNODE_DIR/backedup_version" 2> /dev/null || :`
if grep -q -Fx "$REINSTALL_ORIGIN" "${DBDIR}/taboo.all.list" 2> /dev/null
then
func=$1
tmp_err=${TMPDIR}/reinstall_execcmd_tee_errlog::error
rm -f "$tmp_err"
- { {
- $func
- } 2>&1 || touch "$tmp_err"; } | tee "$REINSTALL_DBNODE_DIR/error.log"
+ if [ $opt_batch_mode = yes ]
+ then
+ { {
+ $func
+ } 2>&1 || touch "$tmp_err"; } > "$REINSTALL_DBNODE_DIR/error.log"
+ else
+ { {
+ $func
+ } 2>&1 || touch "$tmp_err"; } | tee "$REINSTALL_DBNODE_DIR/error.log"
+ fi
[ -e "$tmp_err" ] && return 1
rm -f "$REINSTALL_DBNODE_DIR/error.log"
return
{
local func
func=$1
- if $func 2> $REINSTALL_DBNODE_DIR/error.log
+ if $func > $REINSTALL_DBNODE_DIR/error.log 2>&1
then
rm -f "$REINSTALL_DBNODE_DIR/error.log"
return
# Return status 1 for error end
reinstall_exec_reinstall_fetch ()
{
+ local dev_out dev_err
+ dev_out=/dev/stdout
+ dev_err=/dev/stderr
+ if [ $opt_batch_mode = yes ]
+ then
+ dev_out=/dev/null
+ dev_err=/dev/null
+ fi
if ! reinstall_chk_stage_complete FETCH
then
if ! reinstall_chk_stage FAILED_FETCH
then
- reinstall_make_anymode checksum || \
+ reinstall_make_anymode checksum > $dev_out > $dev_err || \
reinstall_register_stage FAILED_FETCH
fi
if reinstall_chk_stage FAILED_FETCH
then
message_echo "INFO: Refetching distfiles for $REINSTALL_ORIGPKGTAG."
{
- reinstall_make_anymode fetch FETCH_ARGS=-Ap &&
- reinstall_make_anymode checksum
+ reinstall_make_anymode fetch FETCH_ARGS=-Ap > $dev_out > $dev_err &&
+ reinstall_make_anymode checksum > $dev_out > $dev_err
} || reinstall_register_stage FAILED_REFETCH_1
reinstall_register_stage_complete FAILED_FETCH.RETRIAL_1
fi
if ! reinstall_chk_stage_complete FAILED_FETCH.RETRIAL_2.DISTCLEAN
then
message_echo "INFO: Cleaning distfiles for the second refetch for $REINSTALL_ORIGPKGTAG."
- reinstall_make_anymode distclean || :
+ reinstall_make_anymode distclean > $dev_out > $dev_err || :
reinstall_register_stage_complete FAILED_FETCH.RETRIAL_2.DISTCLEAN
fi
if ! reinstall_chk_stage_complete FAILED_FETCH.RETRIAL_2
# Return status 1 for error end
reinstall_exec_reinstall_build ()
{
- local flag_restarted_build build_args is_build_env_modified conflicts_install
+ local flag_restarted_build build_args is_build_env_modified conflicts_install dev_out dev_err
+ dev_out=/dev/stdout
+ dev_err=/dev/stderr
+ if [ $opt_batch_mode = yes ]
+ then
+ dev_out=/dev/null
+ dev_err=/dev/null
+ fi
if reinstall_chk_stage in_build
then
message_echo "(Restarting the previously terminated build process...)"
pkgsys_get_conflicting_installed_pkgs build "$REINSTALL_ORIGIN" \
| reinstall_backup_and_delete_conflicts
reinstall_chk_missing_requirement || return
- if ! reinstall_make build $build_args
+ if ! reinstall_make build $build_args > $dev_out 2> $dev_err
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."
# Return status 1 for error end
reinstall_exec_reinstall_install ()
{
- local insttarget
+ local insttarget dev_out dev_err
+ dev_out=/dev/stdout
+ dev_err=/dev/stderr
+ if [ $opt_batch_mode = yes ]
+ then
+ dev_out=/dev/null
+ dev_err=/dev/null
+ fi
if [ -e "$REINSTALL_FROMNODE_DIR/installed_version" ]
then
insttarget=reinstall
fi
if ! reinstall_chk_stage FAILED_INSTALL
then
- if reinstall_make $insttarget || \
+ if reinstall_make $insttarget > $dev_out 2> $dev_err || \
{
message_echo "INFO: Cleaning up for retrial."
- reinstall_make deinstall \
+ reinstall_make deinstall > $dev_out 2> $dev_err \
|| message_echo "WARNING: Continuing by hoping a success." >&2
message_echo "INFO: Retrying the installation."
_reinstall_exec__tmpcmd () { reinstall_make $insttarget MAKE_JOBS_UNSAFE=yes; }
# ============= Reinstallation of the current origin: Closing process after successful install =============
reinstall_exec_reinstall_close ()
{
+ local dev_out dev_err
+ dev_out=/dev/stdout
+ dev_err=/dev/stderr
+ if [ $opt_batch_mode = yes ]
+ then
+ dev_out=/dev/null
+ dev_err=/dev/null
+ fi
reinstall_restore_conflicts "$REINSTALL_ORIGIN"
if ! reinstall_chk_stage_complete CLEAN_AFTER_INSTALL
then
- if ! reinstall_make clean
+ if ! reinstall_make clean > $dev_out 2> $dev_err
then
message_echo "WARNING: Failed to clean $REINSTALL_ORIGPKGTAG." >&2
fi