OSDN Git Service

Minor modifications on option -c and related functionalities and so on are made.
authorMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Fri, 10 Aug 2012 04:05:40 +0000 (13:05 +0900)
committerMamoru Sakaue / MwGhennndo <glmwghennndo@users.sourceforge.jp>
Fri, 10 Aug 2012 04:05:40 +0000 (13:05 +0900)
modified:   portsreinstall
modified:   portsreinstall.8
modified:   portsreinstall.8~
modified:   portsreinstall~

portsreinstall
portsreinstall.8
portsreinstall.8~
portsreinstall~

index 0c51ebc..76d956d 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename "$0"`
-MYVERSION=1.1.0+toward_2.0.0_20120808022938
+MYVERSION=1.1.0+toward_2.0.0_20120810130509
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -282,8 +282,11 @@ then
        echo "        the currently installed ${APPNAME}."
        echo " -c : Suppress cleaning the temporal database even if its obsolete."
        echo "        By default, the temporal database is automatically cleaned up if"
-       echo "        it is older than the ports tree."
+       echo "        it is older than the ports tree or ${APPNAME} itself is to be"
+       echo "        updated."
        echo "        This option replace this behavior with termination with warnings."
+       echo "        This option should not be used unless the user has special"
+       echo "        intentions."
        echo
        echo "[ARGUMENTS]"
        echo " command: (For optional operations or confirmation)"
@@ -415,7 +418,7 @@ then
 fi
 
 command=$1
-[ -n "$command" ] && shift
+[ -z "$command" ] || shift
 
 # ====================================================
 # ================== FUNCTIONS =======================
@@ -507,7 +510,7 @@ record_success ()
        then
                add_a_line_if_new "$origin" "${DBDIR}/success.list"
                rm_a_line "$origin" "${DBDIR}/success_but_dependencies_failed.list"
-               [ -e "${DBDIR}/requires/$origin/necessary_update" ] && mv "${DBDIR}/requires/$origin/necessary_update" "${DBDIR}/requires/$origin/necessary_update_completed"
+               [ ! -e "${DBDIR}/requires/$origin/necessary_update" ] || mv "${DBDIR}/requires/$origin/necessary_update" "${DBDIR}/requires/$origin/necessary_update_completed"
        else
                rm_a_line "$origin" "${DBDIR}/success.list"
                add_a_line_if_new "$origin" "${DBDIR}/success_but_dependencies_failed.list"
@@ -574,7 +577,7 @@ register_globs ()
        do
                if expr "@$glob" : '^@[^/][^/]*/[^/][^/]*$' > /dev/null 2> /dev/null
                then
-                       [ -d "${PORTSDIR}/$glob" ] && { echo $glob; continue; }
+                       [ ! -d "${PORTSDIR}/$glob" ] || { echo $glob; continue; }
                fi
                ports_glob "$glob" > ${TMPDIR}/register_globs:ports_glob
                origin=`ports_glob "$glob"`
@@ -690,7 +693,7 @@ convert_origin_if_moved ()
        origin_src=$1
        recursedb_in=$2
        recursedb=${recursedb_in:-${PORTS_MOVED_DB}}
-       [ -d "${PORTSDIR}/$origin" ] && return
+       [ ! -d "${PORTSDIR}/$origin" ] || return 0
        add_to_obsolete_if_not_yet "$origin"
        grep -n -m 1 -E "^`str_escape_regexp $origin`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || :
        if [ `cat "${TMPDIR}/moved.info" | wc -l` -eq 0 ]
@@ -701,7 +704,7 @@ convert_origin_if_moved ()
                else
                        echo "${DEPTH_INDEX}  ===> Nonexistent port (your original?)"
                fi
-               [ -n "$origin_src" ] && add_to_obsolete_if_not_yet "$origin_src"
+               [ -z "$origin_src" ] || add_to_obsolete_if_not_yet "$origin_src"
                return 1
        else
                iline_db=`cut -d : -f 1 "${TMPDIR}/moved.info"`
@@ -802,7 +805,7 @@ inspect_dependencies ()
                        MAKE_ENVS=`cat "$target_dir/MENV.conflist" 2> /dev/null || :`
                        env ${MAKE_ENVS} make config-conditional ${MAKE_ARGS}
                        pkg=`pkg_info -qO "$origin"`
-                       [ -n "$pkg" ] && echo $pkg > $target_dir/installed_version
+                       [ -z "$pkg" ] || echo $pkg > $target_dir/installed_version
                        pkg_new=`(cd "${PORTSDIR}/$origin" && env ${MAKE_ENVS} make package-name ${MAKE_ARGS})`
                        pkgtag=$pkg
                        [ -n "$pkgtag" ] || pkgtag=$pkg_new
@@ -833,8 +836,12 @@ inspect_dependencies ()
                        do
                                origin_dependency=`sed -n ${iline}p "${TMPDIR}/missing.$origin_id"`
                                iline=$(($iline+1))
-                               grep -m 1 -E "^`str_escape_regexp $origin_dependency`$" "${DBDIR}/target.inspected.list" > /dev/null 2> /dev/null && continue
-                               inspect_dependencies "$origin_dependency"
+                               if grep -m 1 -E "^`str_escape_regexp $origin_dependency`$" "${DBDIR}/target.inspected.list" > /dev/null 2> /dev/null
+                               then
+                                       :
+                               else
+                                       inspect_dependencies "$origin_dependency"
+                               fi
                        done
                        rm "${TMPDIR}/missing.$origin_id"
                        env ${MAKE_ENVS} make fetch-urlall-list ${MAKE_ARGS} | sed -E 's|.*/([^/]+)$|\1|' | sort | uniq >> ${DBDIR}/distfiles.list
@@ -868,7 +875,7 @@ timestamp ()
 
 warn_update_ports ()
 {
-       [ ${_STATUS_DB_OBSOLETE} = no ] && return
+       [ ${_STATUS_DB_OBSOLETE} = yes ] || return 0
        echo "WARNING: The Ports tree was updated after construction of the temporal database for ${APPNAME}." >&2
        echo "      You should consider executing " >&2
        echo "               ${APPNAME} clean" >&2
@@ -1016,7 +1023,7 @@ echo
 [ "$load_pkgtoolsconf" = undef -o ! -e "${DBDIR}/COMPLETE_IMPORT_PKGTOOLS_CONF" ] || echo "WARNING: -p, -P or -Q option is specified but ignored by following the previous settings." >&2
 
 # Check whether the temporal database is newer than the ports tree
-if [ "${PORTS_INDEX_DB}" -nt "${DBDIR}" ]
+if [ "${PORTS_INDEX_DB}" -nt "${DBDIR}"/MYVERSION ]
 then
        if [ $supress_obsolete_db_clean = no ]
        then
@@ -1063,9 +1070,12 @@ then
                                if ( cd "${PORTSDIR}/$self_origin" && make reinstall )
                                then
                                        ( cd "${PORTSDIR}/$self_origin" && make clean )
-                                       echo "INFO: Cleaning the temporal database by the new version..."
-                                       rm -rf "${DBDIR}"
-                                       echo
+                                       if [ $supress_obsolete_db_clean = yes -a -d "${DBDIR}" ]
+                                       then
+                                               echo "INFO: Cleaning the temporal database..."
+                                               rm -rf "${DBDIR}"
+                                               echo
+                                       fi
                                        echo "INFO: Restarting with the new version..."
                                        echo
                                        . "${TMPDIR}"/restart_command.sh
@@ -1128,7 +1138,7 @@ ok)
                ;;
        esac
        echo "Now the following ports have been manually resolved:"
-       [ -r "${DBDIR}/manually_done.list" ] && cat  "${DBDIR}/manually_done.list"
+       [ ! -r "${DBDIR}/manually_done.list" ] || cat  "${DBDIR}/manually_done.list"
        exit
        ;;
 taboo)
@@ -1246,7 +1256,7 @@ show)
                ;;
        esac
        [ -n "${_for_each_matching_port}" -o -r "${DBDIR}/$list" ] || exit 0
-       [ -e "${DBDIR}"/saved_options.sh ] && . "${DBDIR}"/saved_options.sh
+       [ ! -e "${DBDIR}"/saved_options.sh ] || . "${DBDIR}"/saved_options.sh
        if [ -n "${_for_each_matching_port}" ]
        then
                shift
@@ -1315,7 +1325,7 @@ redo)
        warn_update_ports
        touch "${DBDIR}/MODE_REDO"
        rm -f "${DBDIR}/COMPLETE_CLEANUP_REINST_STATUS"
-       [ $renew_options = yes ] && rm -f "${DBDIR}/COMPLETE_SAVE_OPTIONS"
+       [ $renew_options = no ] || rm -f "${DBDIR}/COMPLETE_SAVE_OPTIONS"
        if [ -n "$target_required_ports$target_dependent_ports$target_required_ports_form2$target_dependent_ports_form2" ]
        then
                rm -f "${DBDIR}/COMPLETE_PARSE_OPTION_TARGET_PORTS"
@@ -1336,11 +1346,43 @@ do)
        ;;
 esac
 
+# ------- Termination messages during construction of the temporal database -------
+
+terminate_process_common ()
+{
+       local msg_where
+       [ -z "${_MSG_CURRENT_STAGE}" ] || msg_where=" during ${_MSG_CURRENT_STAGE}"
+       echo
+       if [ $errno -eq 130 ]
+       then
+               echo "INFO: Terminated at `timestamp`$msg_where"
+               echo
+               echo " You can restart this process from the terminated point by"
+       else
+               echo "INFO: Aborted at `timestamp`$msg_where"
+               echo
+               echo " You may restart this process from the aborted point by"
+       fi
+       echo "executing without options or arguments as:"
+       echo "  ${APPNAME}"
+}
+
+terminate_process ()
+{
+       terminate_process_common
+       echo " Instead, if you only want to construct the temporal database so as to stop"
+       echo "before the actual reinstallation, execute as:"
+       echo "  ${APPNAME} prepare"
+       terminate_process ()
+       {
+       }
+}
+
 # ------- Load from pkgtools.conf(5) -------
 
 if [ ! -e "${DBDIR}/COMPLETE_SAVE_OPTIONS" ]
 then
-       [ -e "${DBDIR}"/saved_options.sh ] && echo "(Previous option settings for '-s', '-q' and '-d' are reset.)"
+       [ ! -e "${DBDIR}"/saved_options.sh ] || echo "(Previous option settings for '-s', '-q' and '-d' are reset.)"
        cat > ${DBDIR}/saved_options.sh << eof
 target_dependent_ports=$target_dependent_ports
 target_required_ports=$target_required_ports
@@ -1394,7 +1436,7 @@ then
                echo "-- Starting to parse pkgtools.conf at `timestamp` (by using installed portupgrade)"
                portupgrade_pkg=`pkg_info -qO ports-mgmt/portupgrade`
                [ -n "$portupgrade_pkg" ] || portupgrade_pkg=`pkg_info -qO ports-mgmt/portupgrade-devel`
-               [ `expr "$portupgrade_pkg" : '^portupgrade-devel-'` -ne 0 ] && echo "WARNING: Combination with portupgrade-devel-* has not tested."
+               [ `expr "$portupgrade_pkg" : '^portupgrade-devel-'` -eq 0 ] || echo "WARNING: Combination with portupgrade-devel-* has not tested."
                istart=`grep -m 1 -n -e '^def init_global$' "${PORTUPGRADE}" | cut -d : -f 1` || :
                [ -n "$istart" ] || { echo "ERROR: The current installed version of portupgrade is unsupported." >&2; }
                sed 1,$(($istart-1))d "${PORTUPGRADE}" > ${TMPDIR}/portupgrade.0
@@ -1582,7 +1624,10 @@ then
                done
                touch "${DBDIR}/COMPLETE_REFLECTCONF_ALT_MOVED"
        fi
-       [ "${DBDIR}/MOVED.conflist" -nt "${PORTS_MOVED_DB}" ] && PORTS_MOVED_DB=${DBDIR}/MOVED.conflist
+       if [ "${DBDIR}/MOVED.conflist" -nt "${PORTS_MOVED_DB}" ]
+       then
+               PORTS_MOVED_DB=${DBDIR}/MOVED.conflist
+       fi
        
        build_conflist_target_list HOLD
        build_conflist_target_list TABOO
@@ -1634,36 +1679,6 @@ fi
 
 # ------- Database construction -------
 
-terminate_process_common ()
-{
-       local msg_where
-       [ -n "${_MSG_CURRENT_STAGE}" ] && msg_where=" during ${_MSG_CURRENT_STAGE}"
-       echo
-       if [ $errno -eq 130 ]
-       then
-               echo "INFO: Terminated at `timestamp`$msg_where"
-               echo
-               echo " You can restart this process from the terminated point by"
-       else
-               echo "INFO: Aborted at `timestamp`$msg_where"
-               echo
-               echo " You may restart this process from the aborted point by"
-       fi
-       echo "executing without options or arguments as:"
-       echo "  ${APPNAME}"
-}
-
-terminate_process ()
-{
-       terminate_process_common
-       echo " Instead, if you only want to construct the temporal database so as to stop"
-       echo "before the actual reinstallation, execute as:"
-       echo "  ${APPNAME} prepare"
-       terminate_process ()
-       {
-       }
-}
-
 # Target ports
 if [ ! -e "${DBDIR}/COMPLETE_INSTALLED_PORTS" ]
 then
@@ -1896,7 +1911,7 @@ fi
 if [ ! -e "${DBDIR}/COMPLETE_ORDERED_ALL_DEPENDENCIES" ]
 then
        echo "Starting order of dependencies at `timestamp`"
-       [ -f "${DBDIR}/reinst_order.list.tmp" ] && echo "INFO: Restarting from the previously terminated point"
+       [ ! -f "${DBDIR}/reinst_order.list.tmp" ] || echo "INFO: Restarting from the previously terminated point"
        touch "${DBDIR}/reinst_order.list.tmp"
        cd "${DBDIR}/requires"
        cat > ${TMPDIR}/order_dependencies.awk << eof
@@ -2097,11 +2112,11 @@ then
                        echo "========== Starting deinstallation process for obsolete port $origin as $currentpkg =========="
                        if [ -z "${currentorigin_is_all}" -a -n "${currentorigin_is_relevant}" ]
                        then
-                               [ "${currentorigin_is_target}" = y ] && echo "(Target port)"
-                               [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
-                               [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))"
-                               [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))"
-                               [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))"
+                               [ -z "${currentorigin_is_target}" ] || echo "(Target port)"
+                               [ -z "${currentorigin_is_dependent}" ] || echo "(Dependent of the target port(s))"
+                               [ -z "${currentorigin_is_required}" ] || echo "(Requirement of the target port(s))"
+                               [ -z "${currentorigin_is_former_dependent}" ] || echo "(Former dependent of the target port(s))"
+                               [ -z "${currentorigin_is_former_required}" ] || echo "(Former requirement of the target port(s))"
                        fi
                        echo "-- (Creating backup package for $origin as $currentpkg)"
                        tag=`echo $origin | sed 's|/|.|'`
@@ -2124,7 +2139,7 @@ then
 fi
 
 # Reinstallation of remained ports
-[ -e "${DBDIR}/MODE_REDO" ] && rm -f "${DBDIR}/COMPLETE_REINSTALLATION" "${DBDIR}/COMPLETE_CLEANUP_OBSLETE_DISTFILES" "${DBDIR}/COMPLETE_REBUILD_PKGDB"
+[ ! -e "${DBDIR}/MODE_REDO" ] || rm -f "${DBDIR}/COMPLETE_REINSTALLATION" "${DBDIR}/COMPLETE_CLEANUP_OBSLETE_DISTFILES" "${DBDIR}/COMPLETE_REBUILD_PKGDB"
 if [ ! -e "${DBDIR}/COMPLETE_REINSTALLATION" ]
 then
        _MSG_CURRENT_STAGE_general="reinstallation"
@@ -2201,11 +2216,11 @@ then
                then
                        if [ -n "${currentorigin_is_relevant}" ]
                        then
-                               [ "${currentorigin_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_target}" ] || echo "(Target port)" > ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_dependent}" ] || echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_required}" ] || echo "(Requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_former_dependent}" ] || echo "(Former dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_former_required}" ] || echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
                        else
                                echo "========== $counter (Skipping an irrelevant package for port $position_msg at `timestamp`) =========="
                                echo
index 15eaa58..297a6b4 100644 (file)
@@ -187,8 +187,9 @@ This option supresses update, deinstallation and reinstallation of the currently
 .TP
 \fB\-c\fR
 Suppress cleaning the temporal database even if its obsolete.
-By default, the temporal database is automatically cleaned up if it is older than the ports tree.
+By default, the temporal database is automatically cleaned up if it is older than the ports tree or portsreinstall itself is to be updated.
 This option replace this behavior with termination with warnings.
+This option should not be used unless the user has special intentions.
 .SH DETAILS
 This utility realizes smart reinstallation of a large number of ports by allowing you to run when when the machine is free and terminate when busy.
 Concretely, you can stop the process by CTRL+C anytime and restart quickly.
@@ -291,7 +292,7 @@ Configuration file of portupgrade(1).
 
 [CHANGED] The specification of \fBshow\fR command is changed to exclude irrelevant packages/ports and output messages about the matching targets when options \fB\-r\fR, \fB\-R\fR, \fB\-t\fR and \fB\-T\fR are enabled.
 
-[CHANGED] The default behavior in case that the temporal database is older than the ports tree is changed from warnings to automatic reconstruction.
+[CHANGED] The default behavior in case that the temporal database is older than the ports tree is changed from warnings to automatic reconstruction; the old behavior is recovered by option \fB\-c\fR.
 
 [BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
 
index 4e169b4..b4b0700 100644 (file)
@@ -187,8 +187,9 @@ This option supresses update, deinstallation and reinstallation of the currently
 .TP
 \fB\-c\fR
 Suppress cleaning the temporal database even if its obsolete.
-By default, the temporal database is automatically cleaned up if it is older than the ports tree.
+By default, the temporal database is automatically cleaned up if it is older than the ports tree or portsreinstall itself is to be updated.
 This option replace this behavior with termination with warnings.
+This option should not be used unless the user has special intentions.
 .SH DETAILS
 This utility realizes smart reinstallation of a large number of ports by allowing you to run when when the machine is free and terminate when busy.
 Concretely, you can stop the process by CTRL+C anytime and restart quickly.
@@ -274,7 +275,7 @@ Configuration file of portupgrade(1).
 .SH HISTORY
 \fBportsreinstall\fR has been developed as below.
 .TP
-1.2.0 (7 August 2012)
+2.0.0 (8 August 2012)
 [NEW] Options \fB\-X\fR, \fB\-r\fR and \fB\-R\fR are added so as to compensate a fact that \fB\-x\fR, \fB\-t\fR and \fB\-T\fR cannot specify package names with commas.
 
 [NEW] Commands of \fBshow requirements\fR and  \fBshow dependents\fR are added.
index 63ac483..a74ad59 100755 (executable)
@@ -10,7 +10,7 @@
 # ================================================
 
 APPNAME=`basename "$0"`
-MYVERSION=1.1.0+toward_1.2.0_20120807154627
+MYVERSION=1.1.0+toward_2.0.0_20120808081529
 
 PREFIX=${PREFIX:-/usr/local}
 CONFFILE=${PREFIX}/etc/${APPNAME}.conf
@@ -282,8 +282,11 @@ then
        echo "        the currently installed ${APPNAME}."
        echo " -c : Suppress cleaning the temporal database even if its obsolete."
        echo "        By default, the temporal database is automatically cleaned up if"
-       echo "        it is older than the ports tree."
+       echo "        it is older than the ports tree or ${APPNAME} itself is to be"
+       echo "        updated."
        echo "        This option replace this behavior with termination with warnings."
+       echo "        This option should not be used unless the user has special"
+       echo "        intentions."
        echo
        echo "[ARGUMENTS]"
        echo " command: (For optional operations or confirmation)"
@@ -415,7 +418,7 @@ then
 fi
 
 command=$1
-[ -n "$command" ] && shift
+[ -z "$command" ] || shift
 
 # ====================================================
 # ================== FUNCTIONS =======================
@@ -507,7 +510,7 @@ record_success ()
        then
                add_a_line_if_new "$origin" "${DBDIR}/success.list"
                rm_a_line "$origin" "${DBDIR}/success_but_dependencies_failed.list"
-               [ -e "${DBDIR}/requires/$origin/necessary_update" ] && mv "${DBDIR}/requires/$origin/necessary_update" "${DBDIR}/requires/$origin/necessary_update_completed"
+               [ ! -e "${DBDIR}/requires/$origin/necessary_update" ] || mv "${DBDIR}/requires/$origin/necessary_update" "${DBDIR}/requires/$origin/necessary_update_completed"
        else
                rm_a_line "$origin" "${DBDIR}/success.list"
                add_a_line_if_new "$origin" "${DBDIR}/success_but_dependencies_failed.list"
@@ -574,7 +577,7 @@ register_globs ()
        do
                if expr "@$glob" : '^@[^/][^/]*/[^/][^/]*$' > /dev/null 2> /dev/null
                then
-                       [ -d "${PORTSDIR}/$glob" ] && { echo $glob; continue; }
+                       [ ! -d "${PORTSDIR}/$glob" ] || { echo $glob; continue; }
                fi
                ports_glob "$glob" > ${TMPDIR}/register_globs:ports_glob
                origin=`ports_glob "$glob"`
@@ -690,7 +693,7 @@ convert_origin_if_moved ()
        origin_src=$1
        recursedb_in=$2
        recursedb=${recursedb_in:-${PORTS_MOVED_DB}}
-       [ -d "${PORTSDIR}/$origin" ] && return
+       [ ! -d "${PORTSDIR}/$origin" ] || return 0
        add_to_obsolete_if_not_yet "$origin"
        grep -n -m 1 -E "^`str_escape_regexp $origin`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || :
        if [ `cat "${TMPDIR}/moved.info" | wc -l` -eq 0 ]
@@ -701,7 +704,7 @@ convert_origin_if_moved ()
                else
                        echo "${DEPTH_INDEX}  ===> Nonexistent port (your original?)"
                fi
-               [ -n "$origin_src" ] && add_to_obsolete_if_not_yet "$origin_src"
+               [ -z "$origin_src" ] || add_to_obsolete_if_not_yet "$origin_src"
                return 1
        else
                iline_db=`cut -d : -f 1 "${TMPDIR}/moved.info"`
@@ -802,7 +805,7 @@ inspect_dependencies ()
                        MAKE_ENVS=`cat "$target_dir/MENV.conflist" 2> /dev/null || :`
                        env ${MAKE_ENVS} make config-conditional ${MAKE_ARGS}
                        pkg=`pkg_info -qO "$origin"`
-                       [ -n "$pkg" ] && echo $pkg > $target_dir/installed_version
+                       [ -z "$pkg" ] || echo $pkg > $target_dir/installed_version
                        pkg_new=`(cd "${PORTSDIR}/$origin" && env ${MAKE_ENVS} make package-name ${MAKE_ARGS})`
                        pkgtag=$pkg
                        [ -n "$pkgtag" ] || pkgtag=$pkg_new
@@ -833,8 +836,12 @@ inspect_dependencies ()
                        do
                                origin_dependency=`sed -n ${iline}p "${TMPDIR}/missing.$origin_id"`
                                iline=$(($iline+1))
-                               grep -m 1 -E "^`str_escape_regexp $origin_dependency`$" "${DBDIR}/target.inspected.list" > /dev/null 2> /dev/null && continue
-                               inspect_dependencies "$origin_dependency"
+                               if grep -m 1 -E "^`str_escape_regexp $origin_dependency`$" "${DBDIR}/target.inspected.list" > /dev/null 2> /dev/null
+                               then
+                                       :
+                               else
+                                       inspect_dependencies "$origin_dependency"
+                               fi
                        done
                        rm "${TMPDIR}/missing.$origin_id"
                        env ${MAKE_ENVS} make fetch-urlall-list ${MAKE_ARGS} | sed -E 's|.*/([^/]+)$|\1|' | sort | uniq >> ${DBDIR}/distfiles.list
@@ -868,7 +875,7 @@ timestamp ()
 
 warn_update_ports ()
 {
-       [ ${_STATUS_DB_OBSOLETE} = no ] && return
+       [ ${_STATUS_DB_OBSOLETE} = yes ] || return 0
        echo "WARNING: The Ports tree was updated after construction of the temporal database for ${APPNAME}." >&2
        echo "      You should consider executing " >&2
        echo "               ${APPNAME} clean" >&2
@@ -1016,7 +1023,7 @@ echo
 [ "$load_pkgtoolsconf" = undef -o ! -e "${DBDIR}/COMPLETE_IMPORT_PKGTOOLS_CONF" ] || echo "WARNING: -p, -P or -Q option is specified but ignored by following the previous settings." >&2
 
 # Check whether the temporal database is newer than the ports tree
-if [ "${PORTS_INDEX_DB}" -nt "${DBDIR}" ]
+if [ "${PORTS_INDEX_DB}" -nt "${DBDIR}"/MYVERSION ]
 then
        if [ $supress_obsolete_db_clean = no ]
        then
@@ -1063,9 +1070,12 @@ then
                                if ( cd "${PORTSDIR}/$self_origin" && make reinstall )
                                then
                                        ( cd "${PORTSDIR}/$self_origin" && make clean )
-                                       echo "INFO: Cleaning the temporal database by the new version..."
-                                       rm -rf "${DBDIR}"
-                                       echo
+                                       if [ $supress_obsolete_db_clean = yes -a -d "${DBDIR}" ]
+                                       then
+                                               echo "INFO: Cleaning the temporal database..."
+                                               rm -rf "${DBDIR}"
+                                               echo
+                                       fi
                                        echo "INFO: Restarting with the new version..."
                                        echo
                                        . "${TMPDIR}"/restart_command.sh
@@ -1128,7 +1138,7 @@ ok)
                ;;
        esac
        echo "Now the following ports have been manually resolved:"
-       [ -r "${DBDIR}/manually_done.list" ] && cat  "${DBDIR}/manually_done.list"
+       [ ! -r "${DBDIR}/manually_done.list" ] || cat  "${DBDIR}/manually_done.list"
        exit
        ;;
 taboo)
@@ -1246,7 +1256,7 @@ show)
                ;;
        esac
        [ -n "${_for_each_matching_port}" -o -r "${DBDIR}/$list" ] || exit 0
-       [ -e "${DBDIR}"/saved_options.sh ] && . "${DBDIR}"/saved_options.sh
+       [ ! -e "${DBDIR}"/saved_options.sh ] || . "${DBDIR}"/saved_options.sh
        if [ -n "${_for_each_matching_port}" ]
        then
                shift
@@ -1315,7 +1325,7 @@ redo)
        warn_update_ports
        touch "${DBDIR}/MODE_REDO"
        rm -f "${DBDIR}/COMPLETE_CLEANUP_REINST_STATUS"
-       [ $renew_options = yes ] && rm -f "${DBDIR}/COMPLETE_SAVE_OPTIONS"
+       [ $renew_options = no ] || rm -f "${DBDIR}/COMPLETE_SAVE_OPTIONS"
        if [ -n "$target_required_ports$target_dependent_ports$target_required_ports_form2$target_dependent_ports_form2" ]
        then
                rm -f "${DBDIR}/COMPLETE_PARSE_OPTION_TARGET_PORTS"
@@ -1336,11 +1346,43 @@ do)
        ;;
 esac
 
+# ------- Termination messages during construction of the temporal database -------
+
+terminate_process_common ()
+{
+       local msg_where
+       [ -z "${_MSG_CURRENT_STAGE}" ] || msg_where=" during ${_MSG_CURRENT_STAGE}"
+       echo
+       if [ $errno -eq 130 ]
+       then
+               echo "INFO: Terminated at `timestamp`$msg_where"
+               echo
+               echo " You can restart this process from the terminated point by"
+       else
+               echo "INFO: Aborted at `timestamp`$msg_where"
+               echo
+               echo " You may restart this process from the aborted point by"
+       fi
+       echo "executing without options or arguments as:"
+       echo "  ${APPNAME}"
+}
+
+terminate_process ()
+{
+       terminate_process_common
+       echo " Instead, if you only want to construct the temporal database so as to stop"
+       echo "before the actual reinstallation, execute as:"
+       echo "  ${APPNAME} prepare"
+       terminate_process ()
+       {
+       }
+}
+
 # ------- Load from pkgtools.conf(5) -------
 
 if [ ! -e "${DBDIR}/COMPLETE_SAVE_OPTIONS" ]
 then
-       [ -e "${DBDIR}"/saved_options.sh ] && echo "(Previous option settings for '-s', '-q' and '-d' are reset.)"
+       [ ! -e "${DBDIR}"/saved_options.sh ] || echo "(Previous option settings for '-s', '-q' and '-d' are reset.)"
        cat > ${DBDIR}/saved_options.sh << eof
 target_dependent_ports=$target_dependent_ports
 target_required_ports=$target_required_ports
@@ -1394,7 +1436,7 @@ then
                echo "-- Starting to parse pkgtools.conf at `timestamp` (by using installed portupgrade)"
                portupgrade_pkg=`pkg_info -qO ports-mgmt/portupgrade`
                [ -n "$portupgrade_pkg" ] || portupgrade_pkg=`pkg_info -qO ports-mgmt/portupgrade-devel`
-               [ `expr "$portupgrade_pkg" : '^portupgrade-devel-'` -ne 0 ] && echo "WARNING: Combination with portupgrade-devel-* has not tested."
+               [ `expr "$portupgrade_pkg" : '^portupgrade-devel-'` -eq 0 ] || echo "WARNING: Combination with portupgrade-devel-* has not tested."
                istart=`grep -m 1 -n -e '^def init_global$' "${PORTUPGRADE}" | cut -d : -f 1` || :
                [ -n "$istart" ] || { echo "ERROR: The current installed version of portupgrade is unsupported." >&2; }
                sed 1,$(($istart-1))d "${PORTUPGRADE}" > ${TMPDIR}/portupgrade.0
@@ -1582,7 +1624,10 @@ then
                done
                touch "${DBDIR}/COMPLETE_REFLECTCONF_ALT_MOVED"
        fi
-       [ "${DBDIR}/MOVED.conflist" -nt "${PORTS_MOVED_DB}" ] && PORTS_MOVED_DB=${DBDIR}/MOVED.conflist
+       if [ "${DBDIR}/MOVED.conflist" -nt "${PORTS_MOVED_DB}" ]
+       then
+               PORTS_MOVED_DB=${DBDIR}/MOVED.conflist
+       fi
        
        build_conflist_target_list HOLD
        build_conflist_target_list TABOO
@@ -1634,36 +1679,6 @@ fi
 
 # ------- Database construction -------
 
-terminate_process_common ()
-{
-       local msg_where
-       [ -n "${_MSG_CURRENT_STAGE}" ] && msg_where=" during ${_MSG_CURRENT_STAGE}"
-       echo
-       if [ $errno -eq 130 ]
-       then
-               echo "INFO: Terminated at `timestamp`$msg_where"
-               echo
-               echo " You can restart this process from the terminated point by"
-       else
-               echo "INFO: Aborted at `timestamp`$msg_where"
-               echo
-               echo " You may restart this process from the aborted point by"
-       fi
-       echo "executing without options or arguments as:"
-       echo "  ${APPNAME}"
-}
-
-terminate_process ()
-{
-       terminate_process_common
-       echo " Instead, if you only want to construct the temporal database so as to stop"
-       echo "before the actual reinstallation, execute as:"
-       echo "  ${APPNAME} prepare"
-       terminate_process ()
-       {
-       }
-}
-
 # Target ports
 if [ ! -e "${DBDIR}/COMPLETE_INSTALLED_PORTS" ]
 then
@@ -1896,7 +1911,7 @@ fi
 if [ ! -e "${DBDIR}/COMPLETE_ORDERED_ALL_DEPENDENCIES" ]
 then
        echo "Starting order of dependencies at `timestamp`"
-       [ -f "${DBDIR}/reinst_order.list.tmp" ] && echo "INFO: Restarting from the previously terminated point"
+       [ ! -f "${DBDIR}/reinst_order.list.tmp" ] || echo "INFO: Restarting from the previously terminated point"
        touch "${DBDIR}/reinst_order.list.tmp"
        cd "${DBDIR}/requires"
        cat > ${TMPDIR}/order_dependencies.awk << eof
@@ -2097,11 +2112,11 @@ then
                        echo "========== Starting deinstallation process for obsolete port $origin as $currentpkg =========="
                        if [ -z "${currentorigin_is_all}" -a -n "${currentorigin_is_relevant}" ]
                        then
-                               [ "${currentorigin_is_target}" = y ] && echo "(Target port)"
-                               [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
-                               [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))"
-                               [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))"
-                               [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))"
+                               [ -z "${currentorigin_is_target}" ] || echo "(Target port)"
+                               [ -z "${currentorigin_is_dependent}" ] || echo "(Dependent of the target port(s))"
+                               [ -z "${currentorigin_is_required}" ] || echo "(Requirement of the target port(s))"
+                               [ -z "${currentorigin_is_former_dependent}" ] || echo "(Former dependent of the target port(s))"
+                               [ -z "${currentorigin_is_former_required}" ] || echo "(Former requirement of the target port(s))"
                        fi
                        echo "-- (Creating backup package for $origin as $currentpkg)"
                        tag=`echo $origin | sed 's|/|.|'`
@@ -2124,7 +2139,7 @@ then
 fi
 
 # Reinstallation of remained ports
-[ -e "${DBDIR}/MODE_REDO" ] && rm -f "${DBDIR}/COMPLETE_REINSTALLATION" "${DBDIR}/COMPLETE_CLEANUP_OBSLETE_DISTFILES" "${DBDIR}/COMPLETE_REBUILD_PKGDB"
+[ ! -e "${DBDIR}/MODE_REDO" ] || rm -f "${DBDIR}/COMPLETE_REINSTALLATION" "${DBDIR}/COMPLETE_CLEANUP_OBSLETE_DISTFILES" "${DBDIR}/COMPLETE_REBUILD_PKGDB"
 if [ ! -e "${DBDIR}/COMPLETE_REINSTALLATION" ]
 then
        _MSG_CURRENT_STAGE_general="reinstallation"
@@ -2201,11 +2216,11 @@ then
                then
                        if [ -n "${currentorigin_is_relevant}" ]
                        then
-                               [ "${currentorigin_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
-                               [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_target}" ] || echo "(Target port)" > ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_dependent}" ] || echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_required}" ] || echo "(Requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_former_dependent}" ] || echo "(Former dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+                               [ -z "${currentorigin_is_former_required}" ] || echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
                        else
                                echo "========== $counter (Skipping an irrelevant package for port $position_msg at `timestamp`) =========="
                                echo