OSDN Git Service

Version 3.0.1+toward_3.0.2_20130703211449
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Wed, 3 Jul 2013 12:15:09 +0000 (21:15 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Wed, 3 Jul 2013 12:15:09 +0000 (21:15 +0900)
The sanity check is changed to be more intelligent to detect the necessity of reinstallation.

modified:   bin/portsreinstall
modified:   lib/libcommand.sh
modified:   lib/libmessage.sh
modified:   lib/libpkgsys.sh
modified:   man/portsreinstall.8

bin/portsreinstall
lib/libcommand.sh
lib/libmessage.sh
lib/libpkgsys.sh
man/portsreinstall.8

index 2623a54..06c01fd 100755 (executable)
@@ -15,7 +15,7 @@ APPNAME=`basename "$0"`
 # MYVERSION=3.0.1
 # COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
 # Template for development versions
-MYVERSION=3.0.1+toward_3.0.2_20130703190902
+MYVERSION=3.0.1+toward_3.0.2_20130703211449
 COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
 MYPREFIX=${MYPREFIX:-/usr/local}
index 0efcf18..6909d74 100644 (file)
@@ -740,19 +740,28 @@ command_exec_irrespective_of_saved_options ()
                        [ -n "$origin" ] || continue
                        origin_regexp=`str_escape_regexp "$origin"`
                        grep -q -E "^$origin_regexp$" "${DBDIR}/damaged_package" 2>/dev/null && continue
-                       pkgsys_sanitychk_pkgcontents "$pkg" && continue
+                       pkgsys_sanitychk_pkgcontents "$pkg" is_reinstall_encouraged && continue
                        if [ ! -d "${PORTSDIR}/$origin" ]
                        then
                                message_echo "WARNING: $pkg ($origin) is obsolete." >&2
                                message_echo >&2
                                continue
                        fi
-                       if [ $opt_batch_mode = no ]
+                       if [ $is_reinstall_encouraged = no ]
                        then
-                               message_echo "Do you want to reinstall it? (y/[n])"
-                               message_query_yn_default_no || continue
+                               if [ $opt_batch_mode = no ]
+                               then
+                                       message_echo "Do you want to reinstall it? (y/[n])"
+                                       message_query_yn_default_no || continue
+                               fi
+                       else
+                               if [ $opt_batch_mode = no ]
+                               then
+                                       message_echo "Do you want to reinstall it? ([y]/n)"
+                                       message_query_yn_default_yes || continue
+                               fi
+                               database_record_reconf_recover_sanity "$origin"
                        fi
-                       database_record_reconf_recover_sanity "$origin"
                done
                message_echo "Done"
                exit
index b8ac319..adf1535 100644 (file)
@@ -6,9 +6,31 @@
 # This software is distributed under the 2-Clause BSD License.
 # ==============================================================================
 
+# ============= Simple query by y (yes) or n (no) where yes by default =============
+message_query_yn_default_yes ()
+{
+       local answer
+       read answer || :
+       case `echo "$answer" | head -c 1` in
+       y|Y)    message_echo
+               return 0
+               ;;
+       n|N)    message_echo
+               return 1
+               ;;
+       '')     return 0
+               ;;
+       *)      message_echo
+               message_echo 'Pardon? ([y]/n)'
+               message_query_yn_default_yes
+               ;;
+       esac
+}
+
 # ============= Simple query by y (yes) or n (no) where no by default =============
 message_query_yn_default_no ()
 {
+       local answer
        read answer || :
        case `echo "$answer" | head -c 1` in
        y|Y)    message_echo
index f2845f7..52647eb 100644 (file)
@@ -942,11 +942,38 @@ pkgsys_chk_conflict_by_a_pkg ()
 # ============= Check whether installed files are lost or broken for a package =============
 pkgsys_sanitychk_pkgcontents ()
 {
-       local pkg tmp_sanity origin
+       local pkg var_is_reinstall_encouraged tmp_sanity nlines iline is_reinstall_encouraged src filename icol filename_esc origin
        pkg=$1
+       var_is_reinstall_encouraged=$2
        tmp_sanity=${TMPDIR}/pkgsys_sanitychk_pkgcontents:sanity
        pkg_check_sanity "$pkg" > $tmp_sanity || :
        [ `wc -l < $tmp_sanity` -eq 0 ] && return
+       nlines=`wc -l < $tmp_sanity`
+       iline=1
+       is_reinstall_encouraged=no
+       while [ $iline -le $nlines ]
+       do
+               src=`sed -n ${iline}p "$tmp_sanity"`
+               filename=`echo "$src" | cut -d ' ' -f 1`
+               icol=2
+               until [ -e "$filename" -o "$filename" = "$src" ]
+               do
+                       filename="$filename "`echo "$src" | cut -d ' ' -f $icol`
+               done
+               [ -e "$filename" ] || continue
+               if expr "$filename" : '.*/include/.*' > /dev/null
+               then
+                       is_reinstall_encouraged=yes
+                       break
+               fi
+               filename_esc=`str_escape_regexp "$filename"`
+               if file "$filename" | sed -E "s/^$filename_esc:[[:space:]]//" | grep -q '^ELF '
+               then
+                       is_reinstall_encouraged=yes
+                       break
+               fi
+       done 
+       eval "$var_is_reinstall_encouraged=\$is_reinstall_encouraged"
        origin=`pkg_info_qo "$pkg"`
        if [ $opt_batch_mode = no ]
        then
index e16c192..891afdd 100644 (file)
@@ -157,8 +157,9 @@ Internal tables used for \fBshow\fR command keep their information regardless of
 Examine the sanity of installed packages, i.e., whether the installed files exist and match the checksum.
 If arguments \fIglobs\fR are given, only the matching packages are examined.
 For each insane package, the user is queried whether to reinstall it forcedly in the following do/redo runs.
+The default choice is "yes" for packages containing changed ELF binaries or include files, and "no" for the others.
 Insane packages already assigned to be reinstalled are skipped.
-With \fB\-a\fR enabled, all insane packages are assigned to be reinstalled forcedly.
+With \fB\-a\fR enabled, all insane packages are assigned to be the above mentioned default.
 It is noted that this sanity check can detect some configuration or cache files which are changed during normal use and need not to be recovered.
 .TP
 \fBescape\fR \fIglob\fR [\fIglob2\fR ...]