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
# 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}
[ -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
# 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
# ============= 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
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 ...]