OSDN Git Service

Version 3.0.3+toward_3.0.4_20131115074959
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 14 Nov 2013 23:09:31 +0000 (08:09 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Thu, 14 Nov 2013 23:09:31 +0000 (08:09 +0900)
[IMPROVED] Support for systems in which pkgng is the default or legacy package tools are abandoned is improved.

[BUG FIX] The execution was terminated by error when /etc/make.conf does not exist.

 [BUG FIX] The execution was terminated by error when there is no INDEX file for the current OS version is prepared.

 [BUG FIX] Some meaningless warnings are suppressed.

 [BUG FIX] Comments at termination during building the temporary database were inconsistent.

modified:   README
modified:   bin/portsreinstall
modified:   lib/libconf.sh
modified:   lib/libmessage.sh
modified:   lib/liboptions.sh
modified:   lib/libpkgsys.sh
modified:   lib/libtemp.sh
modified:   man/portsreinstall.8

README
bin/portsreinstall
lib/libconf.sh
lib/libmessage.sh
lib/liboptions.sh
lib/libpkgsys.sh
lib/libtemp.sh
man/portsreinstall.8

diff --git a/README b/README
index 6cae93b..93c6da8 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 ================================================================================
  portsreinstall - ports upgrading utility for massive forced reinstallation
-  Version 3.0.3, August 2, 2013
+  Version 3.0.4, November ?, 2013
  Copyright (C) 2010-2013 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 ================================================================================
 
index 171c263..ba1900e 100755 (executable)
@@ -15,7 +15,7 @@ APPNAME=`basename "$0"`
 # MYVERSION=3.0.3
 # COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
 # Template for development versions
-MYVERSION=3.0.3+toward_3.0.4_20131107220944
+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]+)$'
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
 MYPREFIX=${MYPREFIX:-/usr/local}
@@ -229,7 +229,7 @@ _program_exec_and_record_completion__operation ()
        need_msg=no
        rm -rf "${DBDIR}/conf"
        mkdir -p "${DBDIR}/conf"
-       [ "x`options_get_effective_opt_load_pkgtoolsconf`" != xno -a $opt_batch_mode = no ] \
+       [ "x`options_get_effective_opt_load_pkgtoolsconf 2> /dev/null`" != xno -a $opt_batch_mode = no ] \
                && need_msg=yes
        [ $need_msg = yes ] && \
                message_section_title "Parsing pkgtools.conf (by using installed portupgrade)"
@@ -345,6 +345,7 @@ then
                reinstall_exec ports-mgmt/pkg
                reinstall_restore_conflicts
                rm -f "${DBDIR}/target_all"
+               temp_set_msg_current_stage
                message_echo
        }
        program_exec_and_record_completion UPGRADE_PKGNG
@@ -367,6 +368,7 @@ then
                reinstall_exec ports-mgmt/dialog4ports
                reinstall_restore_conflicts
                rm -f "${DBDIR}/target_all"
+               temp_set_msg_current_stage
                message_echo
        }
        program_exec_and_record_completion UPGRADE_DIALOG4PORTS
@@ -389,6 +391,7 @@ then
                reinstall_exec "$MYPORTORIGIN"
                reinstall_restore_conflicts
                rm -f "${DBDIR}/target_all"
+               temp_set_msg_current_stage
                message_echo
        }
        program_exec_and_record_completion UPGRADE_SELF
@@ -1269,7 +1272,7 @@ _program_exec_and_record_completion__operation ()
 program_exec_and_record_completion LIST_DEINST_PKGS
 
 # Collect entire distfiles list
-if [ $opt_suppress_inspect_entire_distinfo = yes ]
+if [ $opt_inspect_entire_distinfo = yes ]
 then
        PROGRAM_DEPENDS=''
        _program_exec_and_record_completion__operation ()
@@ -1343,6 +1346,7 @@ _program_exec_and_record_completion__operation ()
        message_section_title "Reinstallation"
        program_exec_restartable_loop_operation reinst_todo
        reinstall_restore_conflicts
+       temp_set_msg_current_stage
        message_echo
 }
 program_exec_and_record_completion REINSTALLATION
index 6598be3..5be9c0f 100644 (file)
@@ -11,20 +11,29 @@ conf_setup_ports_envs ()
 {
        PORTS_MOVED_DB=${PORTSDIR}/MOVED
        PORTS_INDEX_DB=${PORTSDIR}/INDEX-`uname -r | cut -d . -f 1`
+       if [ ! -e "${PORTS_INDEX_DB}" ]
+       then
+               message_echo "INFO: The ports index for the current OS version is not found, so fetching it now."
+               if ! make -C "${PORTSDIR}" fetchindex || [ ! -e "${PORTS_INDEX_DB}" ]
+               then
+                       message_echo "WARNING: Failed to fetch the ports index, so trying to build it locally." >&2
+                       make -C "${PORTSDIR}" index
+               fi
+       fi
 }
 
 # ============= Set up environment variables =============
 conf_setup_envs ()
 {
        local tmp_work
-       tmp_work=${TMPDIR}/pkgsys_def_pkgtools:work
+       tmp_work=${TMPDIR}/conf_setup_envs:work
        rm -rf "$tmp_work"
        mkdir "$tmp_work"
-       PORTSDIR=${PORTSDIR:-`make -C "$tmp_work" -f /etc/make.conf -V PORTSDIR`}
+       PORTSDIR=${PORTSDIR:-`[ -e /etc/make.conf ] && make -C "$tmp_work" -f /etc/make.conf -V PORTSDIR 2> /dev/null`} || :
        PORTSDIR=${PORTSDIR:-/usr/ports}
        for var in LOCALBASE PORT_DBDIR LINUXBASE DISTDIR PACKAGES PKGREPOSITORYSUBDIR PKGREPOSITORY
        do
-               val=`make -C "$tmp_work" -f "${PORTSDIR}/Mk/bsd.port.mk" -V $var`
+               val=`pkgsys_sysvar $var`
                eval $var=\$val
        done
        PKGREPOSITORY=${PKG_PATH:-${PKGREPOSITORY}}
index adf1535..97e68a3 100644 (file)
@@ -51,14 +51,14 @@ message_query_yn_default_no ()
 # ============= Output the version =============
 message_version ()
 {
-       [ $opt_batch_mode = no ] && echo -n "${APPNAME} version "
+       [ "x$opt_batch_mode" = xno ] && echo -n "${APPNAME} version "
        echo "${MYVERSION}"
 }
 
 # ============= Output a message except for the batch mode =============
 message_echo ()
 {
-       [ $opt_batch_mode = yes ] && return
+       [ "x$opt_batch_mode" = xyes ] && return
        echo "$@" | fold -s -w `misc_get_console_column_size`
 }
 
@@ -67,7 +67,7 @@ message_echo ()
 message_cat ()
 {
        local ncolumns
-       [ $opt_batch_mode = yes ] && return
+       [ "x$opt_batch_mode" = xyes ] && return
        ncolumns=`misc_get_console_column_size`
        if [ $# -eq 0 ]
        then
@@ -81,7 +81,7 @@ message_cat ()
 message_credit ()
 {
        local ncolumns
-       [ $opt_batch_mode = yes ] && return
+       [ "x$opt_batch_mode" = xyes ] && return
        ncolumns=`misc_get_console_column_size`
        message_version | fold -s -w $ncolumns
        fold -s -w $ncolumns << eof
@@ -103,7 +103,7 @@ message_timestamp ()
 message_opening_notice ()
 {
        local ncolumns
-       [ $opt_batch_mode = yes ] && return
+       [ "x$opt_batch_mode" = xyes ] && return
        ncolumns=`misc_get_console_column_size`
        fold -s -w $ncolumns << eof
 
@@ -125,7 +125,7 @@ message_report_failure_for_a_port ()
 # ============= Output the relation of the current port with specified targets =============
 message_target_relations ()
 {
-       [ $opt_batch_mode = yes ] && return
+       [ "x$opt_batch_mode" = xyes ] && return
        ( set -e
                origin=$1
                database_query_get_target_attributes it "$origin"
index d3f9a67..d33a45f 100644 (file)
@@ -44,7 +44,7 @@ d     keep-distfiles  opt_keep_distfiles      no      yes
 k      suppress-self-upadte    opt_suppress_self_upadte        no      yes
 g      suppress-pkgtools-upadte        opt_suppress_pkgtools_upadte    no      yes
 c      suppress-clean-obsolete-database        opt_suppress_obsolete_db_clean  no      yes
-D      suppress-entire-inspection-distinfo     opt_suppress_inspect_entire_distinfo    yes     no
+D      suppress-entire-inspection-distinfo     opt_inspect_entire_distinfo     yes     no
 n      dry-run opt_dry_run     no      yes
 X      deselect-all    opt_dialog_auto no      none
 Y      select-all      opt_dialog_auto no      all
index 5327968..fd8ae3e 100644 (file)
@@ -23,7 +23,7 @@ pkgsys_sysvar ()
        tmp_work=${TMPDIR}/pkgsys_sysvar:work
        rm -rf "$tmp_work"
        mkdir "$tmp_work"
-       make -C "$tmp_work" -f "${PORTSDIR}/Mk/bsd.port.mk" -V "$var"
+       make -C "$tmp_work" -f "${PORTSDIR}/Mk/bsd.port.mk" -V "$var" 2> /dev/null
 }
 
 # ============= Get the file name of package check sum file =============
@@ -214,6 +214,12 @@ pkg_is_dependency_of_a_legacypkg_latest ()
        :
 }
 
+# ============= Check whether legacy package tools are available =============
+pkgsys_is_legacy_tool_available ()
+{
+       which -s pkg_info
+}
+
 # ============= Define wrapper commands for hiding the differences between pkg_* tools and pkgng =============
 pkgsys_def_pkgtools ()
 {
@@ -237,7 +243,10 @@ pkgsys_def_pkgtools ()
                PKGSYS_CMD_PKG_ADD='pkg add'
                pkg_is_tool_available ()
                {
-                       which -a pkg | grep -v '^/usr/sbin/pkg$' | grep -q '/sbin/pkg$'
+                       which -a pkg | grep -v '^/usr/sbin/pkg$' | grep -q '/sbin/pkg$' && return
+                       [ -x /usr/sbin/pkg ] || return
+                       /usr/sbin/pkg
+                       pkg_is_tool_available
                }
                pkg_info_Ea ()
                {
@@ -399,6 +408,7 @@ pkgsys_def_pkgtools ()
                        then
                                pkg_inst_remote "$pkg" "$mode" && return
                        fi
+                       pkgsys_is_legacy_tool_available || return
                        message_echo "INFO: Trying to use a legacy package and convert it to pkgng."
                        pkgsys_fetch_legacy_remote "$pkg" || return
                        pkgarc=`pkgsys_fetch_legacy_remote__fetched_pkg`
@@ -453,9 +463,8 @@ pkgsys_def_pkgtools ()
                        local packagepath checksumpath pkgname
                        packagepath=`pkgsys_get_backup_pkg ports-mgmt/pkg` && \
                                pkg_add_tools "$packagepath" && return
-                       [ -x /usr/local/sbin/pkg ] && return
-                       message_echo "WARNING: WITH_PKGNG is set, but pkgng is missing. It is installed now." >&2
-                       [ -x /usr/sbin/pkg ] && /usr/sbin/pkg && return
+                       pkg_is_tool_available && return
+                       message_echo "WARNING: WITH_PKGNG is set, but pkgng is still missing. It is installed now." >&2
                        pkgsys_ready_checksum_file || return
                        checksumpath=`pkgsys_ready_checksum_file__fetched_file`
                        pkgname=`sed 's/^MD5[[:space:]]*(//;s/\.tbz)[[:space:]]*=[^=]*$//' "$checksumpath" \
@@ -476,7 +485,7 @@ pkgsys_def_pkgtools ()
                PKGSYS_CMD_PKG_ADD='pkg_add'
                pkg_is_tool_available ()
                {
-                       :
+                       pkgsys_is_legacy_tool_available
                }
                pkg_info_Ea ()
                {
@@ -650,17 +659,21 @@ pkgsys_init_pkg_orig_by_ambiguous_matching ()
        ambsuffix=
        norigins=0
        len_pkg=`echo -n "$pkg" | wc -c`
-       while [ $len_pkg -gt 0 ]
-       do
-               pkg_regexp=`str_escape_regexp "$pkg"`$ambsuffix
-               grep -E "^${pkg_regexp}[[:space:]]" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
-                       | cut -f 2 > $tmporigin
-               norigins=`wc -l < $tmporigin`
-               [ $norigins -gt 0 ] && break
-               len_pkg=$(($len_pkg-1))
-               pkg=`echo -n "$pkg" | head -c $len_pkg`
-               ambsuffix='[a-zA-Z0-9.,_+-]*'
-       done
+       if [ $len_pkg -gt 0 ]
+       then
+               while :
+               do
+                       pkg_regexp=`str_escape_regexp "$pkg"`$ambsuffix
+                       grep -E "^${pkg_regexp}[[:space:]]" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" 2> /dev/null \
+                               | cut -f 2 > $tmporigin
+                       norigins=`wc -l < $tmporigin`
+                       [ $norigins -gt 0 ] && break
+                       ambsuffix='[a-zA-Z0-9.,_+-]*'
+                       len_pkg=$(($len_pkg-1))
+                       [ $len_pkg -gt 0 ] || break
+                       pkg=`echo -n "$pkg" | head -c $len_pkg`
+               done
+       fi
        [ $norigins -eq 1 ] || return
        cat "$tmporigin"
 }
index 7d04eb0..a0cfa05 100644 (file)
@@ -25,7 +25,7 @@ temp_warn_obsolete_temp_db ()
 # ============= Creation of temporary work directories =============
 temp_trap_init ()
 {
-       trap 'errno=$?; temp_warn_obsolete_temp_db; temp_warn_obsolete_temp_db () { :; }; temp_terminate_process; temp_terminate_process () { :; }; rm -rf "${TMPDIR}" 2> /dev/null; [ x`cat "${DBDIR}/.lock" 2> /dev/null` = x$$ ] && rm -f "${DBDIR}/.lock"; [ $errno -gt 0 -a $errno -ne 130 ] && message_echo "(Error exit by $errno)" >&2; exit $errno' 0 1 2 3 9 15 17 18
+       trap 'errno=$?; temp_warn_obsolete_temp_db; temp_warn_obsolete_temp_db () { :; }; temp_terminate_process; temp_terminate_process () { :; }; rm -rf "${TMPDIR}" 2> /dev/null; [ -n "${DBDIR}" -a x`cat "${DBDIR}/.lock" 2> /dev/null` = x$$ ] && rm -f "${DBDIR}/.lock"; [ $errno -gt 0 -a $errno -ne 130 ] && message_echo "(Error exit by $errno)" >&2; exit $errno' 0 1 2 3 9 15 17 18
        { until TMPDIR=`mktemp -dq /tmp/"${APPNAME}".XXXXXXXX` ; do : ; done ; }
        chgrp "`id -gn`" "${TMPDIR}"
 }
index be2611e..277f892 100644 (file)
@@ -2,7 +2,7 @@
 .\" ports reinstall installation guide
 .\" Copyright (C) 2010-2013 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 .\" ==================================================================================
-.TH PORTSREINSTALL 8 "2 August 2013" "FreeBSD" "FreeBSD System Manager's Manual"
+.TH PORTSREINSTALL 8 "? November 2013" "FreeBSD" "FreeBSD System Manager's Manual"
 .SH NAME
 portsreinstall \- ports upgrading utility for massive forced reinstallation
 .SH SYNOPSIS
@@ -907,11 +907,21 @@ Configuration file of \fBportupgrade\fR(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-3.0.4 (? August 2013)
+3.0.4 (? November 2013)
 .RS
+[IMPROVED] Support for systems in which pkgng is the default or legacy package tools are abandoned is improved.
+.PP
 [IMPROVED] Changes are made so that MAKE_JOBS_UNSAFE=yes is set in retrials of build and installation.
 .PP
-[BUG FIX] Commands of \fBforget\fR and \fBreconf\fR and option \fB\-L\fR could have caused error ends in following \fBshow failure\fR command and the part showing the failure list at the end of commands of \fBdo\fR and \fBredo\fR.
+[BUG FIX] Commands of \fBforget\fR and \fBreconf\fR and option \fB\-L\fR could have caused error ends in following \fBshow failure\fR command and the part showing the failure list at the end of execution of \fBdo\fR and \fBredo\fR commands.
+.PP
+[BUG FIX] The execution was terminated by error when /etc/make.conf does not exist.
+.PP
+[BUG FIX] The execution was terminated by error when there is no INDEX file for the current OS version is prepared.
+.PP
+[BUG FIX] Some meaningless warnings are suppressed.
+.PP
+[BUG FIX] Comments at termination during building the temporary database were inconsistent.
 .RE
 .TP
 3.0.3 (2 August 2013)