OSDN Git Service

Version 3.0.0+toward_3.1.0_20130606182950
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 6 Jun 2013 09:37:12 +0000 (18:37 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 6 Jun 2013 09:37:12 +0000 (18:37 +0900)
Commands of escape and restore are modified.

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

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

index 42897cf..3bab447 100755 (executable)
@@ -15,7 +15,7 @@ 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_20130606094346
+MYVERSION=3.0.0+toward_3.1.0_20130606182950
 COMPATIBLE_VERSIONS='^(3\.0\.0\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
 
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
index ff486c1..43c6212 100644 (file)
@@ -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 backup_pkg origin_orig origin_replace
+       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 pkg_orig tmp_done_orig origin_regexp
        case $COMMAND_MODE in
        ok)
                dbfile=${DBDIR}/manually_done.list
@@ -608,18 +608,23 @@ command_exec_irrespective_of_saved_options ()
                _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 "$@"
+               for origin in `pkgsys_eval_ports_glob "$@"`
                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"`
+                       message_echo "  Registered $origin as taboo."
+                       pkg=`pkg_info_qO "$origin"` || continue
+                       [ -n "$pkg" ] || continue
+                       if backup_pkg=`pkgsys_get_backup_pkg "$origin"`
+                       then
+                               message_echo "INFO: A backup package for $pkg ($origin) already exists as $backup_pkg."
+                       elif backup_pkg=`pkgsys_create_backup_pkg "$pkg" "${DBDIR}/backup_packages"`
                        then
-                               message_echo "ERROR: Failed to backup $pkg ($origin)." >&2
+                               message_echo "  Backed up $pkg ($origin) into $backup_pkg"
+                       else
+                               message_echo "ERROR: Failed to back up $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
@@ -636,32 +641,57 @@ command_exec_irrespective_of_saved_options ()
                _command_exec_irrespective_of_saved_options__notify_ignored_options
                message_echo "Restoring the following temporary escaped packages:"
                message_echo
-               for pkg in "$@"
+               tmp_done_orig=${TMPDIR}/command_exec_irrespective_of_saved_options::restore::done_orig
+               cp /dev/null "$tmp_done_orig"
+               for origin in `pkgsys_eval_ports_glob "$@"`
                do
-                       origin=`pkg_info_qo "$pkg"` || :
                        pkgsys_register_evaluated_globs remove "${DBDIR}/taboo.list" "$origin"
-                       message_echo "  Deregistered $pkg ($origin) from taboo."
+                       message_echo "  Deregistered $origin from taboo."
+                       origin_regexp=`str_escape_regexp "$origin"`
+                       grep -E -q "^$origin_regexp$" "$tmp_done_orig" || :
+                       if pkg_info_eO "$origin"
+                       then
+                               pkg=`pkg_info_qO "$origin"` || :
+                               message_echo "WARNING: $pkg ($origin) is already installed." >&2
+                               message_echo >&2
+                               continue
+                       fi
                        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"; }
+                       if [ "x$origin_orig" = "x$origin" ] && pkg_info_eO "$origin_orig"
                        then
-                               message_echo "WARNING: $pkg ($origin) is already installed."
+                               pkg_orig=`pkg_info_qO "$origin_orig"` || :
+                               message_echo "WARNING: An original version of $origin ($pkg_orig, $origin_orig) is already installed." >&2
                                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`
+                       origin_replace=`echo "$origin" \
+                               | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern"`
+                       if [ "x$origin_replace" != "x$origin" ]
+                       then
+                               if pkg_info_eO "$origin_replace"
+                               then
+                                       pkg_replace=`pkg_info_qO "$origin_replace"` || :
+                                       message_echo "WARNING: A replacement of $origin ($pkg_replace, $origin_replace) is already installed." >&2
+                                       message_echo >&2
+                                       continue
+                               fi
+                               if backup_pkg=`pkgsys_get_backup_pkg "$origin_replace" 2> /dev/null`
+                               then
+                                       message_echo "INFO: $origin is replaced with $origin_replace ($pkg_replace)."
+                                       echo "$origin_replace" >> $tmp_done_orig
+                                       origin=$origin_replace
+                               fi
+                       else
+                               backup_pkg=
+                       fi
+                       if [ -z "$backup_pkg" ] && ! backup_pkg=`pkgsys_get_backup_pkg "$origin" 2> /dev/null`
                        then
-                               message_echo "ERROR: Backup for $pkg ($origin) is not found." >&2
+                               message_echo "ERROR: Backup for $origin is not found." >&2
                                message_echo >&2
                                continue
                        fi
+                       pkg=`pkgsys_pkgarc_to_pkgname "$backup_pkg"`
                        if ! pkg_add_fF "$backup_pkg"
                        then
                                message_echo "ERROR: Failed to restore $pkg ($origin)." >&2
index b89dc2a..61bb41f 100644 (file)
@@ -64,7 +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...
+          | escape globs... | restore globs...
           | 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 029105a..d34e375 100644 (file)
@@ -153,13 +153,13 @@ 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 ...].
+\fBescape\fR \fIglob\fR [\fIglob2\fR ...]
+Back up and delete packages specified by \fIglobs\fR for a temporary escape mainly for resolving undeclared conflicts.
+The escaped packages are registered as taboo as same as \fBtaboo add\fR \fIglob\fR [\fIglob2\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 ...].
+\fBrestore\fR \fIglob\fR [\fIglob2\fR ...]
+Restore packages specified by \fIglobs\fR escaped by \fBescape\fR command.
+The escaped packages are deregistered from taboo as same as \fBtaboo del\fR \fIglob\fR [\fIglob2\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.