OSDN Git Service

[NEW] errormessage command is added.
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sat, 28 Jul 2018 16:07:33 +0000 (00:07 +0800)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sat, 28 Jul 2018 16:07:33 +0000 (00:07 +0800)
 Changes to be committed:
modified:   README
modified:   lib/libcommand_show.sh
modified:   lib/libmain.sh
modified:   lib/libreinstall.sh
modified:   lib/main/libcommand.sh
modified:   lib/main/libusage.sh
modified:   man/portsreinstall.8

README
lib/libcommand_show.sh
lib/libmain.sh
lib/libreinstall.sh
lib/main/libcommand.sh
lib/main/libusage.sh
man/portsreinstall.8

diff --git a/README b/README
index f4e3803..42e4692 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 ================================================================================
  portsreinstall - ports upgrading utility for massive forced reinstallation
-  Version 4.0.0, June 29, 2018
+  Version 4.1.0, August ??, 2018
  Copyright (C) 2010-2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 ================================================================================
 
index 43b1523..4e19ed6 100644 (file)
@@ -75,5 +75,13 @@ command_show ()
                database_query_show_list_inclusion_of_matching_port "$grandtitle" "$lists" "$pkgnamedb" \
                        "$COMMAND_SHOW_DEPTAG" "$COMMAND_SHOW_LEVEL" "$@"
                ;;
+       errormessage )
+               grandtitle="Error messages in (re)installation:"
+               title="\n==== %s ===="
+               list=error.log
+               listdb='requires'
+               pkgnamedb='moved_from'
+               database_query_show_port_lists "$grandtitle" "$title" "$list" "$listdb" "$pkgnamedb" "$@"
+               ;;
        esac
 }
index 04a52c1..42b91ce 100644 (file)
@@ -12,7 +12,7 @@ main_set_version ()
        MYVERSION=4.0.1
        COMPATIBLE_VERSIONS='^(4\.[0]\.[0-1])$'
        # Template for development versions
-       MYVERSION=4.0.0+toward_4.0.1_20180726014524
+       MYVERSION=4.0.0+toward_4.0.1_20180729000704
        COMPATIBLE_VERSIONS='^(4\.[0]\.[0-1]]|4\.[0]\.[0]+(|\+toward_4\.[0]\.[1]+_[0-9]+))$'
 }
 
index a6962af..6f131cb 100644 (file)
@@ -766,6 +766,33 @@ reinstall_fetch_missing_distfiles ()
        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 ()
 {
@@ -888,9 +915,10 @@ 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}"
@@ -1053,8 +1081,8 @@ reinstall_exec ()
        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
@@ -1078,7 +1106,8 @@ reinstall_exec ()
                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
@@ -1122,7 +1151,8 @@ reinstall_exec ()
                ! 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'
@@ -1134,7 +1164,8 @@ reinstall_exec ()
        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'
@@ -1173,7 +1204,8 @@ reinstall_exec ()
                                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
@@ -1181,7 +1213,8 @@ reinstall_exec ()
                                                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
@@ -1231,6 +1264,13 @@ reinstall_exec ()
                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" \
@@ -1244,14 +1284,19 @@ reinstall_exec ()
                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" \
@@ -1269,21 +1314,10 @@ reinstall_exec ()
                                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
@@ -1296,7 +1330,8 @@ reinstall_exec ()
                                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
@@ -1308,6 +1343,7 @@ reinstall_exec ()
                                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
@@ -1315,6 +1351,7 @@ reinstall_exec ()
                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
@@ -1324,7 +1361,8 @@ reinstall_exec ()
        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
@@ -1345,14 +1383,15 @@ reinstall_exec ()
        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
@@ -1376,7 +1415,8 @@ reinstall_exec ()
                                        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"
@@ -1440,13 +1480,14 @@ reinstall_exec ()
        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
index ee03c91..3ed8cfc 100644 (file)
@@ -237,7 +237,7 @@ command_all_parse_args ()
                todo | done | redo | resolved | failure | taboo | freeze | need | noneed | restored | deleted | conflict )
                        _command_parse_args__chk_no_arg $#
                        ;;
-               initrequirements | requirements | initdependents | dependents | conflict_files | status )
+               initrequirements | requirements | initdependents | dependents | conflict_files | status | errormessage )
                        _command_parse_args__chk_glob_args $#
                        ;;
                *)
index dcf2e69..39aa7ca 100644 (file)
@@ -79,6 +79,7 @@ USAGE: portsreinstall [OPTIONS] [--] [command]
           | show conflict | show requirements glob... | show dependents glob...
           | show initrequirements glob... | show initdependents glob...
           | show conflict_files glob... | show status glob...
+          | show errormessage glob...
 
 [DESCRIPTIONS]
  This utility is an alternative to portupgrade(1) and portmaster(8), and designed to be suitable for reinstallation of all packages after major version upgrade of the system or very long absence of ports upgrade.
index d3e369c..eeb74e0 100644 (file)
@@ -312,6 +312,10 @@ In other words, if something is outputted, the port Makefile can have some defec
 \fBstatus\fR \fIglob1\fR [\fIglob2\fR ...]
 Current success/failure status in (re)installation of matching ports/packages.
 Returned values are null, "todo", "done", "resolved", "failure", "redo", "taboo", "freeze", "need", "noneed", "restored", "deleted" or "conflict", where null means that they are untouched in the current option configuration or temporary reset due to configuration changes. 
+.TP
+       \fBerrormessage\fR \fIglob1\fR [\fIglob2\fR ...]
+Error message in (re)installation of matching ports/packages.
+Returned values are null for successful or skipped ports/packages. 
 .RE
 .SH OPTIONS
 If duplicated or conflicting ones are set, the last ones are effective.
@@ -1073,7 +1077,7 @@ Configuration file of \fBportupgrade\fR(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-4.0.1 (?? July 2018)
+4.1.0 (?? August 2018)
 .RS
 [NEW] Option \fB\-x\fR is added.
 .PP
@@ -1081,6 +1085,8 @@ Configuration file of \fBportupgrade\fR(1).
 .PP
 [NEW] \fBauto\fR command is added to \fBportsreinstall\-chroot\fR(8).
 .PP
+[NEW] \fBerrormessage\fR command is added.
+.PP
 [NEW] BUILDCONFLICT and INSTCONFLICT sections are added to ${LOCALBASE}/etc/portsreinstall.conf.
 .PP
 [IMPROVED] The (Re)installation scheme is changed to skip ports whose requirements are not installed at their turns .