OSDN Git Service

Version 3.1.1+toward_3.2.0_20141228193746
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sun, 28 Dec 2014 10:39:10 +0000 (19:39 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sun, 28 Dec 2014 10:39:10 +0000 (19:39 +0900)
[BUG FIX] Reinstallation of ports-mgmt/pkg could encounter error termination.

modified:   README
modified:   bin/portsreinstall
modified:   lib/libpkgsys.sh
modified:   lib/libreinstall.sh
modified:   man/portsreinstall.8

README
bin/portsreinstall
lib/libpkgsys.sh
lib/libreinstall.sh
man/portsreinstall.8

diff --git a/README b/README
index c85b6b2..d6e286c 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 ================================================================================
  portsreinstall - ports upgrading utility for massive forced reinstallation
-  Version 3.2.0, December 17, 2014
+  Version 3.2.0, December 28, 2014
  Copyright (C) 2010-2014 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 ================================================================================
 
index cd109b6..b1795ef 100755 (executable)
@@ -15,7 +15,7 @@ APPNAME=`basename "$0"`
 # MYVERSION=3.2.0
 # COMPATIBLE_VERSIONS='^(3\.[1-2]\.[0-9]+)$'
 # Template for development versions
-MYVERSION=3.1.1+toward_3.2.0_20141221233254
+MYVERSION=3.1.1+toward_3.2.0_20141228193746
 COMPATIBLE_VERSIONS='^(3\.[1-2]\.[0-9]+\+toward_3\.[1-2]\.[0-9]+_[0-9]+|3\.[1-2]\.[0-9]+)$'
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
 MYPREFIX=${MYPREFIX:-/usr/local}
index 11415c2..773c43a 100644 (file)
@@ -58,6 +58,12 @@ pkgsys_is_pkgtool ()
        esac
 }
 
+# ============= Check whether a port is indispensable for package operations =============
+pkgsys_is_necessary_pkgtool ()
+{
+       [ x"$WITH_PKGNG" = x'yes' -a "x$1" = x'ports-mgmt/pkg' ]
+}
+
 # ============= Check whether the dialog for selecting port options is dialog4ports =============
 pkgsys_is_dialog4ports_used ()
 {
@@ -490,7 +496,7 @@ pkgsys_def_pkgtools ()
                        PKGNG_PORTAUDIT_SITE='http=//portaudit.FreeBSD.org/auditfile.tbz'
                        # Load configuration for pkg(1)
                        pkg_conf=`pkg query %Fp pkg 2> /dev/null | grep '/etc/pkg\.conf\.sample$' | sed 's/\.sample$//'` || :
-                       [ -n "$pkg_conf" ] || pkg_conf=/usr/local/etc/pkg.conf
+                       [ -n "$pkg_conf" ] || pkg_conf=${MYPREFIX}/etc/pkg.conf
                        grep -v -e '^[[:space:]]*#' -e '^[[:space:]]*$' "$pkg_conf" 2> /dev/null \
                                | grep -e '^[[:space:]]*[A-Z0-9_]*[[:space:]]*:[[:space:]]*.*' \
                                | while read srcline
index f3bc1d9..f054167 100644 (file)
@@ -229,6 +229,28 @@ reinstall_backup_and_delete_conflicts ()
        mv "${DBDIR}/deleted_conflicts.tmp" "${DBDIR}/deleted_conflicts"
 }
 
+# ============= Back up and delete remaining actual install conflicts =============
+reinstall_backup_and_delete_remaining_install_conflicts ()
+{
+       local stagedir
+       message_echo "(Checking installation conflict...)"
+       stagedir=`database_query_get_makevar_val "$REINSTALL_ORIGIN" STAGEDIR`
+       {
+               ( set -e
+                       cd "$stagedir"
+                       find . -not -type d
+               ) | sed 's|^\.||' | while read filepath
+               do
+                       [ ! -e "$filepath" ] && continue
+                       pkg=`pkg_which "$filepath"`
+                       [ -z "$pkg" ] && continue
+                       origin=`pkg_info_qo "$pkg"`
+                       [ x"$pkg" = x"$REINSTALL_ORIGIN" ] || echo "$pkg"
+               done
+               pkgsys_get_conflicting_installed_pkgs install "$REINSTALL_ORIGIN"
+       } | sort -u | reinstall_backup_and_delete_conflicts
+}
+
 # ============= Restoration of backed up conflicts =============
 reinstall_restore_conflicts ()
 {
@@ -403,13 +425,21 @@ reinstall_deinstall ()
 {
        [ -n "$REINSTALL_CURRENTPKG" ] || return 0
        reinstall_chk_stage_complete DEINSTALL && return
-       echo "$REINSTALL_CURRENTPKG" | tr ' ' '\n' | grep -v '^$' | while read pkg
-       do
-               pkg_delete_f "$pkg" || \
+       if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
+       then
+               pkg_delete_f "$REINSTALL_CURRENTPKG" || \
                {
-                       message_echo "WARNING: Failed to deinstall $pkg by $PKGSYS_CMD_PKG_DELETE." >&2
+                       message_echo "WARNING: Failed to deinstall $REINSTALL_CURRENTPKG by $PKGSYS_CMD_PKG_DELETE." >&2
                }
-       done
+       else
+               echo "$REINSTALL_CURRENTPKG" | tr ' ' '\n' | grep -v '^$' | while read pkg
+               do
+                       pkg_delete_f "$pkg" || \
+                       {
+                               message_echo "WARNING: Failed to deinstall $pkg by $PKGSYS_CMD_PKG_DELETE." >&2
+                       }
+               done
+       fi
        message_echo "-- (Trying to deinstall by ports to make sure. This usually ends up with warnings.)"
        reinstall_make deinstall || \
        {
@@ -642,7 +672,8 @@ reinstall_exec ()
                then
                        if ! reinstall_chk_stage FAILED_INSTALL_BY_PKG
                        then
-                               if [ "x$REINSTALL_ORIGIN" = 'xports-mgmt/pkg'  -a "x$PKGSYS_USE_PKGNG" = xyes ]
+                               if [ "x$PKGSYS_USE_PKGNG" = xyes ] \
+                                       && pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
                                then
                                        if reinstall_deinstall && pkg_is_tool_available && pkg_info_e "$REINSTALL_NEWPKGNAME"
                                        then
@@ -671,6 +702,10 @@ reinstall_exec ()
                                                else
                                                        reinstall_register_stage FAILED_INSTALL_BY_PKG
                                                fi
+                                               if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
+                                               then
+                                                       pkg_is_tool_available || pkg_rescue_tools
+                                               fi
                                        else
                                                reinstall_register_stage FAILED_INSTALL_BY_PKG
                                        fi
@@ -816,13 +851,6 @@ reinstall_exec ()
                then
                        [ $flag_restarted_build = yes ] && message_echo "INFO: This failure may be due to restarting from a terminated build."
                        is_build_env_modified=no
-                       if pkg_info_eO "$REINSTALL_ORIGIN"
-                       then
-                               message_echo "INFO: The currently installed package for this port is deinstalled for retrial because it may have effects on build."
-                               reinstall_pkg_backup || :
-                               reinstall_deinstall
-                               is_build_env_modified=yes
-                       fi
                        if pkgsys_get_conflicting_installed_pkgs install "$REINSTALL_ORIGIN" \
                                > ${TMPDIR}/reinstall_exec::conflicts_install
                        then
@@ -830,8 +858,19 @@ reinstall_exec ()
                                reinstall_backup_and_delete_conflicts < ${TMPDIR}/reinstall_exec::conflicts_install
                                is_build_env_modified=yes
                        fi
+                       if pkg_info_eO "$REINSTALL_ORIGIN"
+                       then
+                               message_echo "INFO: The currently installed package for this port is deinstalled for retrial because it may have effects on build."
+                               reinstall_pkg_backup || :
+                               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'
@@ -842,6 +881,10 @@ reinstall_exec ()
                        message_echo "INFO: Retrying the build process after cleaning for $REINSTALL_ORIGPKGTAG."
                        reinstall_make clean || \
                        {
+                               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 and clean after build failure'
@@ -851,6 +894,10 @@ reinstall_exec ()
                        reinstall_register_stage_complete CLEAN_BEFORE_BUILD
                        reinstall_make build MAKE_JOBS_UNSAFE=yes || \
                        {
+                               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 'retrial of build after failure'
@@ -858,6 +905,10 @@ reinstall_exec ()
                                return
                        }
                fi
+               if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
+               then
+                       pkg_is_tool_available || pkg_rescue_tools
+               fi
                reinstall_register_stage_complete BUILD
        fi
        reinstall_deregister_stage in_build
@@ -908,22 +959,16 @@ reinstall_exec ()
                fi
                reinstall_register_stage_complete BEFOREDEINSTALL
        fi
-       reinstall_deinstall
        if ! reinstall_chk_stage_complete INSTALL
        then
-               message_echo "(Checking installation conflict...)"
-               stagedir=`database_query_get_makevar_val "$REINSTALL_ORIGIN" STAGEDIR`
-               {
-                       ( set -e
-                               cd "$stagedir"
-                               find . -not -type d
-                       ) | sed 's|^\.||' | while read filepath
-                       do
-                               [ -e "$filepath" ] || continue
-                               pkg_which "$filepath"
-                       done
-                       pkgsys_get_conflicting_installed_pkgs install "$REINSTALL_ORIGIN"
-               } | sort -u | reinstall_backup_and_delete_conflicts
+               if pkgsys_is_necessary_pkgtool
+               then
+                       reinstall_backup_and_delete_remaining_install_conflicts
+                       reinstall_deinstall
+               else
+                       reinstall_deinstall
+                       reinstall_backup_and_delete_remaining_install_conflicts
+               fi
                if ! reinstall_chk_stage FAILED_INSTALL
                then
                        if reinstall_make $insttarget || \
@@ -943,7 +988,12 @@ reinstall_exec ()
                fi
                if reinstall_chk_stage FAILED_INSTALL
                then
-                       reinstall_failed_install_recover
+                       if pkgsys_is_necessary_pkgtool "$REINSTALL_ORIGIN"
+                       then
+                               pkg_is_tool_available || pkg_rescue_tools
+                       else
+                               reinstall_failed_install_recover
+                       fi
                        if [ -e "$REINSTALL_DBNODE_DIR/AFTERINSTALL.conf" ] && \
                                ! reinstall_chk_stage_complete FAILED_INSTALL.AFTERINSTALL
                        then
index 84cf15e..9aa73e1 100644 (file)
@@ -2,7 +2,7 @@
 .\" ports reinstall installation guide
 .\" Copyright (C) 2010-2014 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 .\" ==================================================================================
-.TH PORTSREINSTALL 8 "21 December 2014" "FreeBSD" "FreeBSD System Manager's Manual"
+.TH PORTSREINSTALL 8 "28 December 2014" "FreeBSD" "FreeBSD System Manager's Manual"
 .SH NAME
 portsreinstall \- ports upgrading utility for massive forced reinstallation
 .SH SYNOPSIS
@@ -931,9 +931,11 @@ Configuration file of \fBportupgrade\fR(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-3.2.0 (21 December 2014)
+3.2.0 (28 December 2014)
 .RS
 [IMPROVED] The automatic resolution of installation conflict is improved to avoid stripping due to restore\-and\-delete of backup packages that possibly occurs when the default version changes.
+.PP
+[BUG FIX] Reinstallation of ports\-mgmt/pkg could encounter error termination.
 .RE
 .TP
 3.1.1 (17 December 2014)