OSDN Git Service

[CHANGE] Functionalities of options -t and -T are changed so as to prevent deinstalla...
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sun, 22 Jul 2012 14:40:31 +0000 (23:40 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Sun, 22 Jul 2012 14:40:31 +0000 (23:40 +0900)
modified:   portsreinstall
modified:   portsreinstall.8
modified:   portsreinstall.8~
modified:   portsreinstall~

portsreinstall
portsreinstall.8
portsreinstall.8~
portsreinstall~

index c1038b0..25cb9e8 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.1.1_20120604171436
+MYVERSION=1.1.0+toward_1.1.1_20120722233957
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -791,6 +791,44 @@ show_list_failure ()
        done < ${DBDIR}/failed.list
 }
 
+_chk_if_target ()
+{
+       _is_all=y
+       _is_target=
+       _is_dependent=
+       if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
+       then
+               _is_all=
+               if [ ! -f "${DBDIR}/requires/$origin/dependents.pattern" ]
+               then
+                       str_escape_regexp_filter < "${DBDIR}/requires/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/dependents.pattern" 2> /dev/null || :
+               fi
+               if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_target=y
+               elif grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_required=y
+               fi
+       fi
+       _is_required=
+       if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
+       then
+               _is_all=
+               if [ ! -f "${DBDIR}/requires/$origin/requires.pattern" ]
+               then
+                       str_escape_regexp_filter < "${DBDIR}/requires/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/requires.pattern" 2> /dev/null || :
+               fi
+               if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_target=y
+               elif grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_dependent=y
+               fi
+       fi
+}
+
 # ==================================================
 # ==================== MAIN ========================
 # ==================================================
@@ -1650,13 +1688,26 @@ then
                        iline=$(($iline+1))
                        currentpkg=`pkg_info -qO "$origin" 2> /dev/null`
                        [ -n "$currentpkg" ] || continue
+                       _chk_if_target "$origin"
+                       if [ -z "${_is_all}" -a -z "${_is_target}${_is_dependent}${_is_required}" ]
+                       then
+                               echo "-- (Skipping an irrelative package for obsolete port $origin as $currentpkg)"
+                               continue
+                       fi
                        origin_ptn=`str_escape_regexp ${origin}`
                        if [ `grep -m 1 -E "^${origin_ptn}$" "${DBDIR}/HOLD_PORTS.conflist" 2> /dev/null | wc -l` -gt 0 ]
                        then
-                               echo "-- (Skipping a hold package for port $origin as $currentpkg)"
+                               echo "-- (Skipping a hold package for obsolete port $origin as $currentpkg)"
                                continue
                        fi
                        _MSG_CURRENT_STAGE=${_MSG_CURRENT_STAGE_general}
+                       echo "========== Starting deinstallation process for obsolete port $origin as $currentpkg =========="
+                       if [ -z "${_is_all}" -a -n "${_is_target}${_is_dependent}${_is_required}" ]
+                       then
+                               [ "${_is_target}" = y ] && echo "(Target port)"
+                               [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
+                               [ "${_is_required}" = y ] && echo "(Required by the target port(s))"
+                       fi
                        echo "-- (Creating backup package for $origin as $currentpkg)"
                        tag=`echo $origin | sed 's|/|.|'`
                        if [ ! -e "${DBDIR}/status_deinst/$tag.backup" ]
@@ -1664,6 +1715,7 @@ then
                                pkg_create -b "$currentpkg" || { echo "*** Continuating forcibly by hoping success..."; continue; }
                                touch "${DBDIR}/status_deinst/$tag.backup"
                        fi
+                       echo "-- (Deleting package for $origin as $currentpkg)"
                        pkg_delete -f "$currentpkg" || { echo "*** Continuating forcibly by hoping success..."; continue; }
                        rm_a_line "$origin" "${DBDIR}/moved_or_lost.list.remained"
                        _MSG_CURRENT_STAGE=${_MSG_CURRENT_STAGE_general}
@@ -1748,47 +1800,15 @@ then
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
                        continue
                fi
-               _is_all=y
-               _is_target=
-               _is_dependent=
-               if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
-               then
-                       _is_all=
-                       if [ ! -f "${DBDIR}/requires/$origin/dependents.pattern" ]
-                       then
-                               str_escape_regexp_filter < "${DBDIR}/requires/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/dependents.pattern" 2> /dev/null || :
-                       fi
-                       if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_target=y
-                       elif grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_required=y
-                       fi
-               fi
-               _is_required=
-               if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
-               then
-                       _is_all=
-                       if [ ! -f "${DBDIR}/requires/$origin/requires.pattern" ]
-                       then
-                               str_escape_regexp_filter < "${DBDIR}/requires/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/requires.pattern" 2> /dev/null || :
-                       fi
-                       if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_target=y
-                       elif grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_dependent=y
-                       fi
-               fi
+               _chk_if_target "$origin"
+               cp /dev/null "${TMPDIR}"/msg_if_target
                if [ -z "${_is_all}" ]
                then
                        if [ -n "${_is_target}${_is_dependent}${_is_required}" ]
                        then
-                               [ "${_is_target}" = y ] && echo "(Target port)"
-                               [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
-                               [ "${_is_required}" = y ] && echo "(Required by the target port(s))"
+                               [ "${_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
+                               [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ "${_is_required}" = y ] && echo "(Required by the target port(s))" >> ${TMPDIR}/msg_if_target
                        else
                                echo "========== $counter (Skipping an irrelative package for port $position_msg at `timestamp`) =========="
                                echo
@@ -1799,6 +1819,7 @@ then
                if grep -m 1 -E "^`str_escape_regexp ${origin}`$" "${DBDIR}/HOLD_PORTS.conflist" 2> /dev/null > /dev/null
                then
                        echo "========== $counter (Skipping a hold package for port $position_msg at `timestamp`) =========="
+                       cat ${TMPDIR}/msg_if_target
                        echo
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
                        continue
@@ -1806,6 +1827,7 @@ then
                if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/taboo.all.list" 2> /dev/null > /dev/null
                then
                        echo "========== $counter (Ignored a taboo port $position_msg at `timestamp`) =========="
+                       cat ${TMPDIR}/msg_if_target
                        echo
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
                        continue
@@ -1813,6 +1835,7 @@ then
                if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/manually_done.list" 2> /dev/null > /dev/null
                then
                        echo "========== $counter (Marking a manually-done port $position_msg as success at `timestamp`) =========="
+                       cat ${TMPDIR}/msg_if_target
                        echo
                        record_success $origin
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
@@ -1828,9 +1851,7 @@ then
                fi
                _MSG_CURRENT_STAGE="$instdesc process for $position_msg $counter"
                echo "========== $counter Starting $instdesc process for $position_msg at `timestamp` =========="
-               [ "${_is_target}" = y ] && echo '(Target port)'
-               [ "${_is_dependent}" = y ] && echo '(Dependent of the target port(s))'
-               [ "${_is_required}" = y ] && echo '(Required by the target port(s))'
+               cat ${TMPDIR}/msg_if_target
                cd "${PORTSDIR}/$origin"
                if [ -e "${DBDIR}/requires/$origin/status/in_build" ]
                then
index d4e7ac4..76f89ab 100644 (file)
@@ -233,8 +233,10 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-1.1.1 (04 June 2012)
+1.1.1 (22 July 2012)
 [BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
+
+[CHANGE] Functionalities of options -t and -T are changed so as to prevent deinstallation of irrelevant packages.
 .TP
 1.1.0 (28 April 2012)
 [NEW] Command of show deleted is newly added.
index 0636784..056682c 100644 (file)
@@ -233,7 +233,12 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-1.1.0 (26 April 2012)
+1.1.1 (04 June 2012)
+[BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
+
+[CHANGE] Functionalities of options -t and -T are changed so as to prevent deinstallation of irrelevant packages.
+.TP
+1.1.0 (28 April 2012)
 [NEW] Command of show deleted is newly added.
 
 [CHANGE] Origin names in messages and results of show command are changed to be accompanied with package names.
index a1d3a0a..b119bd2 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename $0`
-MYVERSION=1.0.0+toward_1.1.0_20120428010646
+MYVERSION=1.1.0+toward_1.1.1_20120604171436
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -791,6 +791,44 @@ show_list_failure ()
        done < ${DBDIR}/failed.list
 }
 
+_chk_if_target ()
+{
+       _is_all=y
+       _is_target=
+       _is_dependent=
+       if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
+       then
+               _is_all=
+               if [ ! -f "${DBDIR}/requires/$origin/dependents.pattern" ]
+               then
+                       str_escape_regexp_filter < "${DBDIR}/requires/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/dependents.pattern" 2> /dev/null || :
+               fi
+               if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_target=y
+               elif grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_required=y
+               fi
+       fi
+       _is_required=
+       if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
+       then
+               _is_all=
+               if [ ! -f "${DBDIR}/requires/$origin/requires.pattern" ]
+               then
+                       str_escape_regexp_filter < "${DBDIR}/requires/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/requires.pattern" 2> /dev/null || :
+               fi
+               if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_target=y
+               elif grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+               then
+                       _is_dependent=y
+               fi
+       fi
+}
+
 # ==================================================
 # ==================== MAIN ========================
 # ==================================================
@@ -1650,13 +1688,26 @@ then
                        iline=$(($iline+1))
                        currentpkg=`pkg_info -qO "$origin" 2> /dev/null`
                        [ -n "$currentpkg" ] || continue
+                       _chk_if_target "$origin"
+                       if [ -z "${_is_all}" -a -z "${_is_target}${_is_dependent}${_is_required}" ]
+                       then
+                               echo "-- (Skipping an irrelative package for obsolete port $origin as $currentpkg)"
+                               continue
+                       fi
                        origin_ptn=`str_escape_regexp ${origin}`
                        if [ `grep -m 1 -E "^${origin_ptn}$" "${DBDIR}/HOLD_PORTS.conflist" 2> /dev/null | wc -l` -gt 0 ]
                        then
-                               echo "-- (Skipping a hold package for port $origin as $currentpkg)"
+                               echo "-- (Skipping a hold package for obsolete port $origin as $currentpkg)"
                                continue
                        fi
                        _MSG_CURRENT_STAGE=${_MSG_CURRENT_STAGE_general}
+                       echo "========== Starting deinstallation process for obsolete port $origin as $currentpkg =========="
+                       if [ -z "${_is_all}" -a -n "${_is_target}${_is_dependent}${_is_required}" ]
+                       then
+                               [ "${_is_target}" = y ] && echo "(Target port)"
+                               [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
+                               [ "${_is_required}" = y ] && echo "(Required by the target port(s))"
+                       fi
                        echo "-- (Creating backup package for $origin as $currentpkg)"
                        tag=`echo $origin | sed 's|/|.|'`
                        if [ ! -e "${DBDIR}/status_deinst/$tag.backup" ]
@@ -1664,6 +1715,7 @@ then
                                pkg_create -b "$currentpkg" || { echo "*** Continuating forcibly by hoping success..."; continue; }
                                touch "${DBDIR}/status_deinst/$tag.backup"
                        fi
+                       echo "-- (Deleting package for $origin as $currentpkg)"
                        pkg_delete -f "$currentpkg" || { echo "*** Continuating forcibly by hoping success..."; continue; }
                        rm_a_line "$origin" "${DBDIR}/moved_or_lost.list.remained"
                        _MSG_CURRENT_STAGE=${_MSG_CURRENT_STAGE_general}
@@ -1748,47 +1800,15 @@ then
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
                        continue
                fi
-               _is_all=y
-               _is_target=
-               _is_dependent=
-               if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
-               then
-                       _is_all=
-                       if [ ! -f "${DBDIR}/requires/$origin/dependents.pattern" ]
-                       then
-                               str_escape_regexp_filter < "${DBDIR}/requires/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/dependents.pattern" 2> /dev/null || :
-                       fi
-                       if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_target=y
-                       elif grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_required=y
-                       fi
-               fi
-               _is_required=
-               if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
-               then
-                       _is_all=
-                       if [ ! -f "${DBDIR}/requires/$origin/requires.pattern" ]
-                       then
-                               str_escape_regexp_filter < "${DBDIR}/requires/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/requires.pattern" 2> /dev/null || :
-                       fi
-                       if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_target=y
-                       elif grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
-                       then
-                               _is_dependent=y
-                       fi
-               fi
+               _chk_if_target "$origin"
+               cp /dev/null "${TMPDIR}"/msg_if_target
                if [ -z "${_is_all}" ]
                then
                        if [ -n "${_is_target}${_is_dependent}${_is_required}" ]
                        then
-                               [ "${_is_target}" = y ] && echo "(Target port)"
-                               [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
-                               [ "${_is_required}" = y ] && echo "(Required by the target port(s))"
+                               [ "${_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
+                               [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ "${_is_required}" = y ] && echo "(Required by the target port(s))" >> ${TMPDIR}/msg_if_target
                        else
                                echo "========== $counter (Skipping an irrelative package for port $position_msg at `timestamp`) =========="
                                echo
@@ -1799,6 +1819,7 @@ then
                if grep -m 1 -E "^`str_escape_regexp ${origin}`$" "${DBDIR}/HOLD_PORTS.conflist" 2> /dev/null > /dev/null
                then
                        echo "========== $counter (Skipping a hold package for port $position_msg at `timestamp`) =========="
+                       cat ${TMPDIR}/msg_if_target
                        echo
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
                        continue
@@ -1806,6 +1827,7 @@ then
                if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/taboo.all.list" 2> /dev/null > /dev/null
                then
                        echo "========== $counter (Ignored a taboo port $position_msg at `timestamp`) =========="
+                       cat ${TMPDIR}/msg_if_target
                        echo
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
                        continue
@@ -1813,6 +1835,7 @@ then
                if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/manually_done.list" 2> /dev/null > /dev/null
                then
                        echo "========== $counter (Marking a manually-done port $position_msg as success at `timestamp`) =========="
+                       cat ${TMPDIR}/msg_if_target
                        echo
                        record_success $origin
                        rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
@@ -1828,9 +1851,7 @@ then
                fi
                _MSG_CURRENT_STAGE="$instdesc process for $position_msg $counter"
                echo "========== $counter Starting $instdesc process for $position_msg at `timestamp` =========="
-               [ "${_is_target}" = y ] && echo '(Target port)'
-               [ "${_is_dependent}" = y ] && echo '(Dependent of the target port(s))'
-               [ "${_is_required}" = y ] && echo '(Required by the target port(s))'
+               cat ${TMPDIR}/msg_if_target
                cd "${PORTSDIR}/$origin"
                if [ -e "${DBDIR}/requires/$origin/status/in_build" ]
                then
@@ -2107,7 +2128,7 @@ then
        echo " You should also consider whether the failed ports are really required, viz.,"
        echo "not obsolete dependencies, by using pkg_info(1) with -R option."
        echo " After resolving the problems, execute"
-       echo "        ${APPNAME} ok [resolved_port_globs]"
+       echo "        ${APPNAME} ok add [resolved_port_globs]"
        echo "and restart by"
        echo "        ${APPNAME} redo"
        echo "****************"