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