OSDN Git Service

Version 3.0.5
[portsreinstall/current.git] / bin / portsreinstall
index d5323f8..6fb7775 100755 (executable)
 # ============ Set up of environment =============
 APPNAME=`basename "$0"`
 
-# MYVERSION=3.0.0
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
+MYVERSION=3.0.5
+COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
 # Template for development versions
-
-COMPATIBLE_VERSIONS='^(3\.0\.0\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
-MYVERSION=3.0.0+toward_3.0.1_20130610103336
+# MYVERSION=3.0.4+toward_3.0.5_20131213231732
+# 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}
@@ -46,7 +45,6 @@ DBDIR=/var/tmp/${APPNAME}.db
 CONFFILE=${MYPREFIX}/etc/${APPNAME}.conf
 PKGTOOLSCONF=${MYPREFIX}/etc/pkgtools.conf
 
-
 # ==================================================
 # ========= PARSING OPTIONS AND ARGUMENTS ==========
 # ==================================================
@@ -110,6 +108,45 @@ shift "${COMMAND_SHIFT}"
 # ================== TOOLS SET UP ==================
 # ==================================================
 
+# ============= Termination messages during construction of the temporary database =============
+
+# Set termination messages
+temp_terminate_process_common ()
+{
+       local msg_where
+       [ $opt_batch_mode = yes ] && return
+       msg_where=`temp_get_msg_current_stage`
+       [ -n "$msg_where" ] && msg_where=" during $msg_where"
+       echo
+       if [ $errno -eq 130 ]
+       then
+               echo "INFO: Terminated at `message_timestamp`$msg_where."
+               echo
+               echo " You can restart this process from the terminated point by"
+       else
+               echo "INFO: Aborted at `message_timestamp`$msg_where."
+               echo
+               echo " You may restart this process from the aborted point by"
+       fi
+       echo "executing without options or arguments as:"
+       if [ -n "$COMMAND_RESTART" ]
+       then
+               echo "  ${APPNAME} $COMMAND_RESTART"
+       else
+               echo "  ${APPNAME}"
+       fi
+}
+
+temp_terminate_process ()
+{
+       [ $errno -eq 0 -o $opt_batch_mode = yes ] && return
+       temp_terminate_process_common
+       [ -n "$COMMAND_RESTART" ] || message_cat 3<< eof
+ Instead, if you only want to construct the temporary database so as to stop before the actual reinstallation, execute as:
+  ${APPNAME} prepare
+eof
+}
+
 # ============= Opening title =============
 
 message_credit
@@ -170,45 +207,6 @@ then
        message_echo
 fi
 
-# ============= Termination messages during construction of the temporary database =============
-
-# Set termination messages
-temp_terminate_process_common ()
-{
-       local msg_where
-       [ $opt_batch_mode = yes ] && return
-       msg_where=`temp_get_msg_current_stage`
-       [ -n "$msg_where" ] && msg_where=" during $msg_where"
-       echo
-       if [ $errno -eq 130 ]
-       then
-               echo "INFO: Terminated at `message_timestamp`$msg_where."
-               echo
-               echo " You can restart this process from the terminated point by"
-       else
-               echo "INFO: Aborted at `message_timestamp`$msg_where."
-               echo
-               echo " You may restart this process from the aborted point by"
-       fi
-       echo "executing without options or arguments as:"
-       if [ -n "$COMMAND_RESTART" ]
-       then
-               echo "  ${APPNAME} $COMMAND_RESTART"
-       else
-               echo "  ${APPNAME}"
-       fi
-}
-
-temp_terminate_process ()
-{
-       [ $errno -eq 0 -o $opt_batch_mode = yes ] && return
-       temp_terminate_process_common
-       [ -n "$COMMAND_RESTART" ] || message_cat 3<< eof
- Instead, if you only want to construct the temporary database so as to stop before the actual reinstallation, execute as:
-  ${APPNAME} prepare
-eof
-}
-
 # ============= Configurations =============
 
 # Save the previous configuration if exists
@@ -230,7 +228,7 @@ _program_exec_and_record_completion__operation ()
        need_msg=no
        rm -rf "${DBDIR}/conf"
        mkdir -p "${DBDIR}/conf"
-       [ "x`options_get_effective_opt_load_pkgtoolsconf`" != xno -a $opt_batch_mode = no ] \
+       [ "x`options_get_effective_opt_load_pkgtoolsconf 2> /dev/null`" != xno -a $opt_batch_mode = no ] \
                && need_msg=yes
        [ $need_msg = yes ] && \
                message_section_title "Parsing pkgtools.conf (by using installed portupgrade)"
@@ -346,6 +344,7 @@ then
                reinstall_exec ports-mgmt/pkg
                reinstall_restore_conflicts
                rm -f "${DBDIR}/target_all"
+               temp_set_msg_current_stage
                message_echo
        }
        program_exec_and_record_completion UPGRADE_PKGNG
@@ -368,6 +367,7 @@ then
                reinstall_exec ports-mgmt/dialog4ports
                reinstall_restore_conflicts
                rm -f "${DBDIR}/target_all"
+               temp_set_msg_current_stage
                message_echo
        }
        program_exec_and_record_completion UPGRADE_DIALOG4PORTS
@@ -390,6 +390,7 @@ then
                reinstall_exec "$MYPORTORIGIN"
                reinstall_restore_conflicts
                rm -f "${DBDIR}/target_all"
+               temp_set_msg_current_stage
                message_echo
        }
        program_exec_and_record_completion UPGRADE_SELF
@@ -503,6 +504,7 @@ program_exec_and_record_completion REDO_INIT
 PROGRAM_DEPENDS=''
 _program_exec_and_record_completion__operation ()
 {
+       local tag level dbsuffix
        message_section_title "Determining specified targets"
        cat "${DBDIR}/stage.loop_list/target_itself.specified" \
                "${DBDIR}/stage.loop_list/target_dependents.specified" \
@@ -540,24 +542,30 @@ _program_exec_and_record_completion__operation ()
                sort -u "${DBDIR}/need.list" "${DBDIR}/targets_specified_so_far" \
                        > ${DBDIR}/targets_specified_so_far.tmp
                mv "${DBDIR}/targets_specified_so_far.tmp" "${DBDIR}/targets_specified_so_far"
-               dbsuffix=`options_get_dependency_type`.`options_get_dependency_level`
-               {
-                       cat "${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset"
-                       cat "${DBDIR}/stage.loop_list/target_dependents.specified" | while read origin
-                       do
-                               nodedir=${DBDIR}/requires/$origin
-                               cat "$nodedir/dependents.$dbsuffix" 2> /dev/null
-                       done
-                       cat "${DBDIR}/stage.loop_list/target_requirements.specified" | while read origin
+               for tag in all run build none
+               do
+                       for level in direct full
                        do
-                               nodedir=${DBDIR}/requires/$origin
-                               cat "$nodedir/requirements.$dbsuffix" 2> /dev/null
+                               dbsuffix=$tag.$level
+                               {
+                                       cat "${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset"
+                                       cat "${DBDIR}/stage.loop_list/target_dependents.specified" | while read origin
+                                       do
+                                               nodedir=${DBDIR}/requires/$origin
+                                               cat "$nodedir/dependents.$dbsuffix" 2> /dev/null
+                                       done
+                                       cat "${DBDIR}/stage.loop_list/target_requirements.specified" | while read origin
+                                       do
+                                               nodedir=${DBDIR}/requires/$origin
+                                               cat "$nodedir/requirements.$dbsuffix" 2> /dev/null
+                                       done
+                               } | sort -u | while read origin
+                               do
+                                       fileedit_rm_a_line "$origin" "${DBDIR}/success.$dbsuffix.list"
+                                       fileedit_rm_a_line "$origin" "${DBDIR}/todo_after_requirements_succeed.$dbsuffix.list"
+                                       rm -f "${DBDIR}/requires/$origin/succeeded_once"
+                               done
                        done
-               } | sort -u | while read origin
-               do
-                       fileedit_rm_a_line "$origin" "${DBDIR}/success.$dbsuffix.list"
-                       fileedit_rm_a_line "$origin" "${DBDIR}/todo_after_requirements_succeed.$dbsuffix.list"
-                       rm -f "${DBDIR}/requires/$origin/succeeded_once"
                done
        fi
        message_echo
@@ -650,12 +658,17 @@ _program_exec_restartable_loop_operation__routine ()
                                for tag in all run build
                                do
                                        target=${DBDIR}/$dbtag/$origin/${table}.${tag}.${level}
-                                       [ -e "$target.src" ] || continue
-                                       sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \
-                                               | grep -v '^$' | sort -u > $target.tmp
-                                       [ -e "$target" ] && ! diff "$target.tmp" "$target" > /dev/null \
-                                               && echo "$origin" >> ${DBDIR}/update_dependencies
-                                       mv "$target.tmp" "$target"
+                                       if [ -e "$target.src" ]
+                                       then
+                                               sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \
+                                                       | grep -v '^$' | sort -u > $target.tmp
+                                               [ -e "$target" ] && ! diff "$target.tmp" "$target" > /dev/null \
+                                                       && echo "$origin" >> ${DBDIR}/update_dependencies
+                                               mv "$target.tmp" "$target"
+                                       else
+                                               [ -e "$target" ] && echo "$origin" >> ${DBDIR}/update_dependencies
+                                               rm -f "$target"
+                                       fi
                                done
                        done
                done
@@ -1258,7 +1271,7 @@ _program_exec_and_record_completion__operation ()
 program_exec_and_record_completion LIST_DEINST_PKGS
 
 # Collect entire distfiles list
-if [ $opt_suppress_inspect_entire_distinfo = yes ]
+if [ $opt_inspect_entire_distinfo = yes ]
 then
        PROGRAM_DEPENDS=''
        _program_exec_and_record_completion__operation ()
@@ -1332,6 +1345,7 @@ _program_exec_and_record_completion__operation ()
        message_section_title "Reinstallation"
        program_exec_restartable_loop_operation reinst_todo
        reinstall_restore_conflicts
+       temp_set_msg_current_stage
        message_echo
 }
 program_exec_and_record_completion REINSTALLATION