OSDN Git Service

Version 3.0.0+toward_3.1.0_20130606094346
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 6 Jun 2013 00:44:06 +0000 (09:44 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 6 Jun 2013 00:44:06 +0000 (09:44 +0900)
[NEW] Commands escape and restore are added.

modified:   bin/portsreinstall
modified:   lib/libcommand.sh
modified:   lib/libreinstall.sh
modified:   lib/libusage.sh
modified:   man/portsreinstall.8

bin/portsreinstall
lib/libcommand.sh
lib/libreinstall.sh
lib/libusage.sh
man/portsreinstall.8

index 186da52..42897cf 100755 (executable)
@@ -15,7 +15,8 @@ APPNAME=`basename "$0"`
 # MYVERSION=3.0.0
 # COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
 # Template for development versions
-MYVERSION=3.0.0+toward_3.1.0_20130606070810                                                                                   COMPATIBLE_VERSIONS='^(3\.0\.0\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
+MYVERSION=3.0.0+toward_3.1.0_20130606094346
+COMPATIBLE_VERSIONS='^(3\.0\.0\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
 
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
 MYPREFIX=${MYPREFIX:-/usr/local}
index ab737d9..ff486c1 100644 (file)
@@ -198,7 +198,7 @@ command_parse_args ()
        options)
                _command_parse_args__chk_no_arg $#
                ;;
-       reconf|forget)
+       reconf|forget|escape|restore)
                misc_chk_privilege
                temp_warn_obsolete_temp_db
                _command_parse_args__chk_glob_args $#
@@ -436,7 +436,7 @@ command_forget ()
 # ============= Execute command operations which are irrespective of option settings =============
 command_exec_irrespective_of_saved_options ()
 {
-       local dbfile tmp_manually_done_diff evalated_globs dbdir_parent dbdir_node arcfile grandtitle title isfirst origin origin_regexp
+       local dbfile tmp_manually_done_diff evalated_globs dbdir_parent dbdir_node arcfile grandtitle title isfirst origin origin_regexp backup_pkg origin_orig origin_replace
        case $COMMAND_MODE in
        ok)
                dbfile=${DBDIR}/manually_done.list
@@ -604,6 +604,76 @@ command_exec_irrespective_of_saved_options ()
                command_forget "$@"
                exit
                ;;
+       escape)
+               _command_exec_irrespective_of_saved_options__notify_ignored_options
+               message_echo "Backing up and deleting the following packages for a temporary escape:"
+               message_echo
+               for pkg in "$@"
+               do
+                       origin=`pkg_info_qo "$pkg"` || :
+                       pkgsys_register_evaluated_globs add "${DBDIR}/taboo.list" "$origin"
+                       message_echo "  Registered $pkg ($origin) as taboo."
+                       if ! backup_pkg=`pkgsys_create_backup_pkg "$pkg" "${DBDIR}/backup_packages"`
+                       then
+                               message_echo "ERROR: Failed to backup $pkg ($origin)." >&2
+                               message_echo >&2
+                               continue
+                       fi
+                       message_echo "  Backed up $pkg ($origin) into $backup_pkg"
+                       pkg_delete_f "$pkg" || \
+                       {
+                               message_echo "ERROR: Failed to deinstall $pkg ($origin)." >&2
+                               message_echo >&2
+                       }
+                       message_echo "  Deinstalled $pkg ($origin)."
+                       message_echo
+               done
+               program_deregister_stage_complete INSPECT_ALL_DEPENDENCIES
+               message_echo "Done"
+               exit
+               ;;
+       restore)
+               _command_exec_irrespective_of_saved_options__notify_ignored_options
+               message_echo "Restoring the following temporary escaped packages:"
+               message_echo
+               for pkg in "$@"
+               do
+                       origin=`pkg_info_qo "$pkg"` || :
+                       pkgsys_register_evaluated_globs remove "${DBDIR}/taboo.list" "$origin"
+                       message_echo "  Deregistered $pkg ($origin) from taboo."
+                       origin_orig=`echo "$origin" \
+                               | sed -E -f "${DBDIR}/REVERSE_REPLACE.complete_sed_pattern"`
+                       [ "x$origin_orig" = "x$origin" ] && origin_orig=
+                       origin_replace=`echo "$origin" \
+                               | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"`
+                       [ "x$origin_replace" = "x$origin" ] && origin_replace=
+                       if pkg_info_e "$pkg" || pkg_info_eO "$origin" || \
+                               { [ -n "$origin_orig" ] && pkg_info_eO "$origin_orig"; } || \
+                               { [ -n "$origin_replace" ] && pkg_info_eO "$origin_replace"; }
+                       then
+                               message_echo "WARNING: $pkg ($origin) is already installed."
+                               message_echo >&2
+                               continue
+                       fi
+                       message_echo "INFO: Restoring the backup of $pkg ($origin)."
+                       if ! backup_pkg=`pkgsys_get_backup_pkg "$origin" 2> /dev/null`
+                       then
+                               message_echo "ERROR: Backup for $pkg ($origin) is not found." >&2
+                               message_echo >&2
+                               continue
+                       fi
+                       if ! pkg_add_fF "$backup_pkg"
+                       then
+                               message_echo "ERROR: Failed to restore $pkg ($origin)." >&2
+                               message_echo >&2
+                       fi
+                       message_echo "  Restored $pkg ($origin)."
+                       message_echo
+               done
+               program_deregister_stage_complete INSPECT_ALL_DEPENDENCIES
+               message_echo "Done"
+               exit
+               ;;
        redo)
                if [ $opt_reload_conf = yes ]
                then
index 6f4a409..cc891ea 100644 (file)
@@ -239,6 +239,13 @@ reinstall_restore_conflicts ()
                        mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
                        continue
                fi
+               origin_regexp_esc=`str_escape_regexp "$origin"`
+               origin_replace_regexp_esc=`str_escape_regexp "$origin_replace"`
+               if grep -q -E -e "^$origin_regexp_esc$" -e "^$origin_replace_regexp_esc$" "${DBDIR}/taboo.all.list" 2> /dev/null
+               then
+                       message_echo "INFO: Restoration of a conflict, $origin ($pkg), is avoided because it is taboo."
+                       return
+               fi
                message_echo "INFO: Restoring a conflict, $origin ($pkg)."
                if ! backup_pkg=`pkgsys_get_backup_pkg "$origin"`
                then
@@ -342,7 +349,7 @@ reinstall_deinstall ()
 # ============= Recovery after failure of installation of the new package =============
 reinstall_failed_install_recover ()
 {
-       local backedup_version backup_pkg
+       local backedup_version origin_regexp_esc backup_pkg
        reinstall_chk_stage_complete FAILED_INSTALL.RECOVER && return
        message_echo "INFO: Trying to deinstall the failed/terminated installation (Ignore failures)."
        if [ -n "$REINSTALL_CURRENTPKG" ]
@@ -352,6 +359,12 @@ reinstall_failed_install_recover ()
        message_echo "INFO: Trying to deinstall by ports to make sure (This usually ends up with warnings)."
        reinstall_make deinstall || :
        backedup_version=`cat "$REINSTALL_DBNODE_DIR/backedup_version" 2> /dev/null || :`
+       origin_regexp_esc=`str_escape_regexp "$REINSTALL_ORIGIN"`
+       if grep -q -E "^$origin_regexp_esc$" "${DBDIR}/taboo.all.list" 2> /dev/null
+       then
+               message_echo "INFO: Restoration of the backup of $backedup_version is avoided because it is taboo."
+               return
+       fi
        if [ -n "$backedup_version" ]
        then
                message_echo "INFO: Restoring the backup of $backedup_version."
index 0edeb1a..b89dc2a 100644 (file)
@@ -64,6 +64,7 @@ USAGE: ${APPNAME} [OPTIONS] [--] [command]
           | reselect leaves | reselect obsolete
           | save [dir] | load path | glob globs... | options
           | reconf globs... | forget globs...
+          | escape pkgs... | restore pkgs...
           | show todo | show done | show resolved | show failure | show redo
           | show taboo | show need | show noneed | show restored | show deleted
           | show conflict | show requirements glob... | show dependents glob...
index 553339e..029105a 100644 (file)
@@ -153,6 +153,14 @@ In advance to executing this command, deinstallation for the specified ports sho
 It is noted that ports registered by \fBok\fR, \fBtaboo\fR and \fBnoneed\fR commands are NOT deleted.
 Internal tables used for \fBshow\fR command keep their information regardless of this command.
 .TP
+\fBescape\fR \fIpackage1\fR [\fIpackage2\fR ...]
+Back up and delete specified packages for a temporary escape mainly for resolving undeclared conflicts.
+The escaped packages are registered as taboo implying the effects of \fBtaboo add\fR \fIpackage1\fR [\fIpackage2\fR ...].
+.TP
+\fBrestore\fR \fIpackage1\fR [\fIpackage2\fR ...]
+Restore specified packages escaped by \fBescape\fR command.
+The escaped packages are deregistered from taboo implying the effects of \fBtaboo del\fR \fIpackage1\fR [\fIpackage2\fR ...].
+.TP
 \fBshow\fR [\fIsubject\fR] [@[\fBrun\fR|\fBbuild\fR|\fBall\fR][,[\fBdirect\fR|\fBfull\fR]]] [\fIarguments\fR]
 Show the list of ports to be reinstalled.
 The applied scope of dependencies can be controlled by "show option" proceeded by "@"; \fBrun\fR, \fBbuild\fR and \fBall\fR employ the run-time, build-time or both-time ones, respectively; \fBdirect\fR and \fBfull\fR include only the direct or fully recursive ones, respectively.
@@ -708,71 +716,24 @@ For analysis of ports for the same software of different versions,
 .RE
 can be used, where \fIglob_req\fR denotes a glob specifying the suspicious requirements.
 .PP
-If a conflict is found, first back up and delete the conflict (whose package name is \fIpackage_conflict\fR) and the unsuccessful port (whose package name is \fIpackage_failed\fR) as
-.RS
-.B pkg_create \-b
-.I package_conflict
-.RE
-.RS
-.B pkg_create \-b
-.I package_failed
-.RE
-.RS
-.B pkg_delete \-f
-.I package_conflict
-.I package_failed
-.RE
-in case if the legacy packages, or
-.RS
-.B pkg create
-.I package_conflict
-.I package_failed
-.RE
-.RS
-.B pkg delete \-f
-.I package_conflict
-.I package_failed
-.RE
-in case if pkgng.
-Here it is noted that the backup package archive is created in the current directory.
-.PP
-Then try
+If a conflict is found, first escape (back up and delete) the conflict by
 .RS
-\fBmake \-C\fR /usr/ports/\fIorigin\fR clean
+\fBportsreinstall escape\fR \fIpackage_conflict\fR
 .RE
+where \fIpackage_conflict\fR is the conflicting package.
 .RS
-\fBmake \-C\fR /usr/ports/\fIorigin\fR reinstall
-.RE
-for the unsuccessful port whose origin is \fIorigin\fR.
-.PP
-If the installation is successful, execute
-.B portsreinstall ok add
-.I origin
-so as to register the port to be "resolved".
-.PP
-Next clean up the work directory by
-.RS
-\fBmake \-C\fR /usr/ports/\fIorigin\fR clean
-.RE
-and try to restore the conflicts by
-.RS
-\fBpkg_add \-ifF\fR ./\fIpackage_conflict\fR.tbz
-.RE
-in case if the legacy packages, or
-.RS
-\fBpkg add\fR ./\fIpackage_conflict\fR.txz
-.RE
-in case if pkgng.
-Here it is noted that the suffix of the pkgng packages may be different from the default (.txz).
-The restoration process may fail if some file locations conflict with the reinstalled port.
-In this case, leaving this situation temporarily and continue to the next step.
 .PP
 Then execute
 .RS
 .B portsreinstall redo
 .RE
 for completing (re)installation of the dependents of the resolved port.
-The unsuccessful restoration, if any, may be resolved by this process.
+.PP
+If the (re)installation is successful, execute
+.RS
+\fBportsreinstall restore\fR \fIpackage_conflict\fR
+.RE
+to restore the escaped package (reinstallation may fail if a newer version is installed but there is no problem).
 If any conflicts still remain unresolved, refer to case 2.
 .SS Workaround for failed ports: conflicts: case 2
 If some upgraded ports fundamentally conflict with each other, the output log of this utility for do/redo processes will report a message entitled "The following ports are temporarily deleted due to conflicts".
@@ -928,6 +889,8 @@ Configuration file of \fBportupgrade\fR(1).
 \fBportsreinstall\fR has been developed as below.
 .TP
 3.0.1 (? June 2013)
+[NEW] Commands \fBescape\fR and \fBrestore\fR are added.
+
 [IMPROVED] The behavior of \fB\-C\fR option is changed in case of \fBdialog4ports\fR(1) so that the port options are unchanged and unsaved throughout the all stages from the temporary database build to (re)installation. This allows the all stages to run on \fBscript\fR(1) and \fBnohup\fR(1).
 
 [IMPROVED] Changes are made so that installation by packages is split into fetch and installation stages and backup/restoration of old packages are skipped if the fetch is unsuccessful.