OSDN Git Service

Version: 3.0.4+toward_3.0.5_20131206004108
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 5 Dec 2013 15:43:52 +0000 (00:43 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 5 Dec 2013 15:43:52 +0000 (00:43 +0900)
[IMPROVED] Automatic resolution of duplicated registrations of multiple packages for the same port origin is implemented in pkgsanity command.

modified:   README
modified:   bin/portsreinstall
modified:   lib/libcommand.sh
modified:   lib/libdatabase_query.sh
modified:   man/portsreinstall.8

README
bin/portsreinstall
lib/libcommand.sh
lib/libdatabase_query.sh
man/portsreinstall.8

diff --git a/README b/README
index 46a8b67..f3e1878 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 ================================================================================
  portsreinstall - ports upgrading utility for massive forced reinstallation
-  Version 3.0.4, November 16, 2013
+  Version 3.0.5, November 16, 2013
  Copyright (C) 2010-2013 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 ================================================================================
 
index de18cb0..d0f3040 100755 (executable)
 # ============ Set up of environment =============
 APPNAME=`basename "$0"`
 
-MYVERSION=3.0.4
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
+MYVERSION=3.0.4
+COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
 # Template for development versions
-# MYVERSION=3.0.3+toward_3.0.4_20131115074959
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.[0-9]+_[0-9]+|3\.0\.[0-9]+)$'
+MYVERSION=3.0.4+toward_3.0.5_20131206004108
+COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.[0-9]+_[0-9]+|3\.0\.[0-9]+)$'
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
 MYPREFIX=${MYPREFIX:-/usr/local}
 LIBDIR=${MYPREFIX}/lib/${APPNAME}
index 6909d74..ab506d1 100644 (file)
@@ -715,28 +715,70 @@ command_exec_irrespective_of_saved_options ()
                exit
                ;;
        pkgsanity)
-               tmp_pkgsanity=${TMPDIR}/command_exec_irrespective_of_saved_options:pkgsanity
+               tmp_pkgs=${TMPDIR}/command_exec_irrespective_of_saved_options:pkgs
+               tmp_orgs=${TMPDIR}/command_exec_irrespective_of_saved_options:orgs
+               tmp_pkgs_for_an_org=${TMPDIR}/command_exec_irrespective_of_saved_options:pkgs_for_an_org
                _command_exec_irrespective_of_saved_options__notify_ignored_options
                if [ $# -eq 0 ]
                then
                        message_echo "Sanity check of the installed files for each package:"
                        message_echo
-                       pkg_info_Ea > $tmp_pkgsanity
+                       pkg_info_Ea > $tmp_pkgs
+                       pkg_info_qoa > $tmp_orgs
                else
                        message_echo "Examining the installed files for each specified package:"
                        message_echo
-                       pkgsys_eval_ports_glob "$@" | while read origin
+                       pkgsys_eval_ports_glob "$@" > $tmp_orgs
+                       while read origin
                        do
                                pkg_info_qO "$origin" || :
-                       done | grep -v '^[[:space:]]*$' > $tmp_pkgsanity
+                       done < $tmp_orgs | grep -v '^[[:space:]]*$' > $tmp_pkgs
                fi
-               nlines=`wc -l < $tmp_pkgsanity`
+               message_echo "<< Phase 1: Check and fix duplicated packages registrations for the same port origin >>"
+               message_echo
+               while read origin
+               do
+                       [ `pkg_info_qO "$origin" | wc -l` -gt 1 ] || continue
+                       pkg_info_qO "$origin" | while read pkg
+                       do
+                               echo "$((0+`pkg_check_sanity \"$pkg\" | wc -l`))" "$pkg"
+                       done | sort -g > $tmp_pkgs_for_an_org
+                       pkg_valid=`head -n 1 "$tmp_pkgs_for_an_org" | cut -d ' ' -f 2`
+                       message_echo "Port [$origin] has multiply registered packages."
+                       message_echo "The valid one will be [$pkg_valid]."
+                       message_echo "Invalid one(s) will be as follows and to be deleted:"
+                       sed 1d "$tmp_pkgs_for_an_org" | cut -d ' ' -f 2 | message_cat <&3
+                       errout=/dev/stderr
+                       [ "x$opt_batch_mode" = xyes ] && errout=/dev/null
+                       if backup_pkg=`pkgsys_create_backup_pkg "$pkg_valid" "${DBDIR}/backup_packages"`
+                       message_echo
+                       then
+                               pkg_delete_f `cat "$tmp_pkgs_for_an_org"` 2> $errout || {
+                                       message_echo "WARNING: Deletion of the broken packages may not be fully successful, but continuing anyway." >&2
+                                       message_echo >&2
+                               }
+                               pkg_add_fF "$backup_pkg" || {
+                                       message_echo "WARNING: Reinstallation of the most valid package failed, but continuing anyway." >&2
+                                       message_echo >&2
+                               }
+                       else
+                               message_echo "WARNING: Backup of the most valid package failed, but continuing anyway." >&2
+                               pkg_delete_f `cat "$tmp_pkgs_for_an_org"` 2> $errout || {
+                                       message_echo "WARNING: Deletion of the broken packages may not be fully successful, but continuing anyway." >&2
+                                       message_echo >&2
+                               }
+                       fi
+               done < $tmp_orgs
+               
+               message_echo "<< Phase 2: Check and mark broken packages for reinstallation >>"
+               message_echo
+               nlines=`wc -l < $tmp_pkgs`
                iline=1
                while [ $iline -le $nlines ]
                do
-                       pkg=`sed -n ${iline}p "$tmp_pkgsanity"`
+                       pkg=`sed -n ${iline}p "$tmp_pkgs"`
                        iline=$((${iline}+1))
-                       origin=`pkg_info_qo "$pkg"`
+                       origin=`pkg_info_qo "$pkg"` || continue
                        [ -n "$origin" ] || continue
                        origin_regexp=`str_escape_regexp "$origin"`
                        grep -q -E "^$origin_regexp$" "${DBDIR}/damaged_package" 2>/dev/null && continue
index 4fd2592..834c4b0 100644 (file)
@@ -258,9 +258,7 @@ database_query_is_default_conf ()
        if [ "x$mode" != xquiet ]
        then
                message_echo "INFO: This port is configured to be non-default because of"
-               message_cat 3<< eof
-`sed 's/^/         /' "$dbpath/is_customized"`
-eof
+               sed 's/^/         /' "$dbpath/is_customized" | message_cat <&3
                message_echo "      so the prebuilt package is not used."
        fi
        return 1
index a838041..9a38308 100644 (file)
@@ -909,6 +909,11 @@ Configuration file of \fBportupgrade\fR(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
+3.0.5 (? December 2013)
+.RS
+[IMPROVED] Automatic resolution of duplicated registrations of multiple packages for the same port origin is implemented in \fBpkgsanity\fR command.
+.RE
+.TP
 3.0.4 (16 November 2013)
 .RS
 [IMPROVED] Support for systems in which pkgng is the default or legacy package tools are abandoned is improved.