OSDN Git Service

Fixed a bug of error end when no obsolete package is installed.
[portsreinstall/current.git] / lib / libcommand_do.sh
index 8924600..6ff92ba 100644 (file)
@@ -7,23 +7,23 @@
 # ==============================================================================
 
 # ============= Operation of redo command before the database reconstruction =============
-command_do_do__command_all_exec_before_build_database ()
+command_do_do__command_all_exec_command_specific_preconfiguration ()
 {
        program_deregister_stage_complete FORGET::PREPARATION_INSPECT_MASTER
        program_deregister_stage_complete ALL_COMPLETE
 }
 
 # ============= Operation of redo command before the database reconstruction =============
-command_do_redo__command_all_exec_before_build_database ()
+command_do_redo__command_all_exec_command_specific_preconfiguration ()
 {
        program_deregister_stage_complete REDO_INIT
        if [ $opt_reset_targets = yes ]
        then
                program_deregister_stage_complete DETERMINE_SPECIFIED_TARGETS
-               program_deregister_stage_complete INSPECT_ALL_DEPENDENCIES
+               program_deregister_stage_complete PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
                rm -rf "${DBDIR}/targets"
        fi
-       command_do_do__command_all_exec_before_build_database
+       command_do_do__command_all_exec_command_specific_preconfiguration
 }
 
 # ============= Meta process for redo =============
@@ -42,7 +42,7 @@ command_do_meta_process_for_redo ()
 }
 
 # ============= Determine specified targets =============
-command_do_determin_specified_targets ()
+command_do_determine_specified_targets ()
 {
        local PROGRAM_DEPENDS
        PROGRAM_DEPENDS=''
@@ -169,12 +169,30 @@ command_do_determine_all_target_ports ()
                        cat "${DBDIR}/stage.loop_list/target_requirements.specified" || :
                        cat "${DBDIR}/targets_specified_so_far" || :
                }  2> /dev/null | sort -u > "${DBDIR}/stage.loop_list/ports_to_inspect"
-               cp /dev/null "${DBDIR}/done_required_ports_to_inspect"
+               while read origin
+               do
+                       [ -d "${PORTSDIR}/$origin" ] || echo "$origin"
+               done < ${DBDIR}/stage.loop_list/ports_to_inspect > ${DBDIR}/obsoletes_to_escape_for_inspection
                message_echo
        }
        program_exec_and_record_completion DETERMINE_ALL_TARGET_PORTS
 }
 
+# ============= Prepare for inspecting all dependencies =============
+command_do_prepare_for_inspect_all_dependencies ()
+{
+       local PROGRAM_DEPENDS
+       PROGRAM_DEPENDS='PARSE_CONF  DETERMINE_ALL_TARGET_PORTS'
+       _program_exec_and_record_completion__operation ()
+       {
+               message_section_title "Preparing for inspection of all dependencies"
+               database_build_escape "${DBDIR}/escaped_obsoletes" < ${DBDIR}/obsoletes_to_escape_for_inspection
+               cp /dev/null "${DBDIR}/done_required_ports_to_inspect"
+               message_echo
+       }
+       program_exec_and_record_completion PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
+}
+
 # ============= Check ports of which the port options are changed and reset their databases =============
 # Return status 0 for no need to update of inspected ports and 1 for needed to do it
 command_do_reset_changed_portdb ()
@@ -201,7 +219,7 @@ command_do_reset_changed_portdb ()
        cp /dev/null "$tmp_ls.uninspected.dbfile"
        cp /dev/null "$tmp_ls.uninspected.origin"
        cp /dev/null "$tmp_ls.nonexistent.db"
-       pkgsys_conv_portorigins_to_portoptiondbs < $tmp_ls.diff > $tmp_ls.glob
+       pkgsys_conv_portoptiondbs_to_globs < $tmp_ls.diff > $tmp_ls.glob
        str_escape_replaceval_filter < $tmp_ls.diff > $tmp_ls.diff.rpl
        paste "$tmp_ls.diff" "$tmp_ls.diff.rpl" "$tmp_ls.glob" | while read -r dbfile dbfile_rpl glob
        do
@@ -218,7 +236,7 @@ command_do_reset_changed_portdb ()
                then
                        message_echo "Change detected on $origin: Resetting"
                        database_build_patch_reconf "$origin"
-                       program_deregister_stage_complete INSPECT_ALL_DEPENDENCIES
+                       program_deregister_stage_complete PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
                        program_deregister_stage_complete ALL_COMPLETE
                        touch "$tmp_ls.updated"
                else
@@ -243,7 +261,7 @@ command_do_reset_changed_portdb ()
 command_do_inspection_of_all_dependencies ()
 {
        local PROGRAM_DEPENDS
-       PROGRAM_DEPENDS='PARSE_CONF DETERMINE_ALL_TARGET_PORTS'
+       PROGRAM_DEPENDS='PREPARE_FOR_INSPECT_ALL_DEPENDENCIES'
        _program_exec_restartable_loop_operation__routine ()
        {
                local origin
@@ -459,6 +477,21 @@ command_do_inspection_of_dependents ()
        program_exec_and_record_completion INSPECT_DEPENDENTS
 }
 
+# ============= Restore escaped obsolete packages for inspection =============
+command_do_restore_escaped_obsoletes ()
+{
+       local PROGRAM_DEPENDS
+       PROGRAM_DEPENDS='INSPECT_DEPENDENTS'
+       _program_exec_and_record_completion__operation ()
+       {
+               message_section_title "Restoring escaped obsolete packages for inspection"
+               cat "${DBDIR}/escaped_obsoletes" 2> /dev/null | database_build_restore
+               rm -f "${DBDIR}/escaped_obsoletes"
+               message_echo
+       }
+       program_exec_and_record_completion RESTORE_ESCAPED_OBSOLETE_PACKAGES_FOR_INSPECTION
+}
+
 # ============= Remove duplicated lines in dependents lists =============
 command_do_remove_duplicated_lines_in_dependents_lists ()
 {
@@ -1072,7 +1105,7 @@ command_do_clean_up_of_reinstallation_status_for_preparation ()
 command_do_completion_of_building_the_temporary_database ()
 {
        local PROGRAM_DEPENDS
-       PROGRAM_DEPENDS='REDO_INIT SETUP_REINST_TODO CLEANUP_REINST_STATUS PARSE_CONF INSPECT_ALL_DEPENDENCIES NECESSARY_UPDATES:direct NECESSARY_UPDATES:full PARSE_TARGET_ATTR_INFO MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE COLLECT_LEAF_PORTS_TO_DELETE'
+       PROGRAM_DEPENDS='REDO_INIT SETUP_REINST_TODO CLEANUP_REINST_STATUS PARSE_CONF INSPECT_ALL_DEPENDENCIES RESTORE_ESCAPED_OBSOLETE_PACKAGES_FOR_INSPECTION NECESSARY_UPDATES:direct NECESSARY_UPDATES:full PARSE_TARGET_ATTR_INFO MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE COLLECT_LEAF_PORTS_TO_DELETE'
        _program_exec_and_record_completion__operation ()
        {
                message_section_title "The temporary database is completely built up"
@@ -1104,6 +1137,7 @@ command_do_reinstallation_of_remained_ports ()
        _program_exec_restartable_loop_operation__routine ()
        {
                reinstall_exec "$@"
+               temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
        }
        _program_exec_and_record_completion__operation ()
        {
@@ -1112,6 +1146,7 @@ command_do_reinstallation_of_remained_ports ()
                temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
                message_section_title "Reinstallation"
                program_exec_restartable_loop_operation reinst_todo
+               [ "x$PROGRAM_STEP_COUNTER_LAST_SKIPPED" = xyes ] && message_stage_title "$PROGRAM_STEP_COUNTER"
                reinstall_restore_conflicts
                temp_set_msg_current_stage
                message_echo
@@ -1135,6 +1170,7 @@ command_do_restore_needed_obsolete_and_leaf_packages ()
                temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
                message_section_title "Restoration of unselected obsolete/leaf packages"
                program_exec_restartable_loop_operation ports_to_restore
+               [ "x$PROGRAM_STEP_COUNTER_LAST_SKIPPED" = xyes ] && message_stage_title "$PROGRAM_STEP_COUNTER"
                temp_set_msg_current_stage
                message_echo
        }
@@ -1157,6 +1193,7 @@ command_do_deinstallation_of_unused_obsolete_and_leaf_packages ()
                temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
                message_section_title "Deinstallation of unused obsolete/leaf packages"
                program_exec_restartable_loop_operation ports_to_delete
+               [ "x$PROGRAM_STEP_COUNTER_LAST_SKIPPED" = xyes ] && message_stage_title "$PROGRAM_STEP_COUNTER"
                temp_set_msg_current_stage
                message_echo
        }
@@ -1230,7 +1267,7 @@ command_do_prepare ()
        command_do_meta_process_for_redo
        
        # Determine specified targets
-       command_do_determin_specified_targets
+       command_do_determine_specified_targets
        
        # Show specified targets
        command_do_show_specified_targets
@@ -1241,6 +1278,9 @@ command_do_prepare ()
        # Loop considering cases that port options are changed after inspection
        while true
        do
+               # Prepare for inspecting all dependencies
+               command_do_prepare_for_inspect_all_dependencies
+               
                # Inspection of all dependencies
                command_do_inspection_of_all_dependencies
                
@@ -1260,6 +1300,9 @@ command_do_prepare ()
                command_do_reset_changed_portdb && break
        done
        
+       # Restore escaped obsolete packages for inspection
+       command_do_restore_escaped_obsoletes
+       
        # Remove duplicated lines in dependents lists
        command_do_remove_duplicated_lines_in_dependents_lists
        
@@ -1352,21 +1395,34 @@ command_do_main ()
                        message_echo
                fi
                
-               # Reinstallation of remained ports
-               command_do_reinstallation_of_remained_ports
-               
                if [ $opt_fetch_only = yes ]
                then
+                       # Reinstallation of remained ports
+                       command_do_reinstallation_of_remained_ports
+                       
                        message_echo "Completed the fetch only mode."
                        exit
+               elif [ $opt_delete_then_reinstall = no ]
+               then
+                       # Reinstallation of remained ports
+                       command_do_reinstallation_of_remained_ports
+                       
+                       # Restoration of obsolete and leaf packages which have been deinstalled but unselected from the deletion list again 
+                       command_do_restore_needed_obsolete_and_leaf_packages
+                       
+                       # Deinstallation of unused obsolete and leaf packages
+                       command_do_deinstallation_of_unused_obsolete_and_leaf_packages
+               else
+                       # Deinstallation of unused obsolete and leaf packages
+                       command_do_deinstallation_of_unused_obsolete_and_leaf_packages
+                       
+                       # Reinstallation of remained ports
+                       command_do_reinstallation_of_remained_ports
+                       # Restoration of obsolete and leaf packages which have been deinstalled but unselected from the deletion list again 
+                       
+                       command_do_restore_needed_obsolete_and_leaf_packages
                fi
                
-               # Restoration of obsolete and leaf packages which have been deinstalled but unselected from the deletion list again 
-               command_do_restore_needed_obsolete_and_leaf_packages
-               
-               # Deinstallation of unused obsolete and leaf packages
-               command_do_deinstallation_of_unused_obsolete_and_leaf_packages
-               
                # Clean up obsolete or unused distfiles
                command_do_clean_up_obsolete_or_unused_distfiles
                
@@ -1389,7 +1445,7 @@ command_do_is_everything_resolved ()
        for subject in failure redo conflict
        do
                database_query_show_single_list_exec "$subject" \
-                       `options_get_dependency_type` `options_get_dependency_level` > dev/null 2> /dev/null && return 1
+                       `options_get_dependency_type` `options_get_dependency_level` > /dev/null 2> /dev/null && return 1
        done
        :
 }
@@ -1417,17 +1473,17 @@ command_do_ending_process ()
                if [ $opt_no_opening_message = yes ]
                then
                        message_echo "Done as ${APPNAME}"
-                       return
+               else
+                       message_section_title "COMPLETELY DONE"
                fi
-               message_section_title "COMPLETELY DONE"
                if [ $opt_fetch_only = no -a $opt_dry_run = no ]
-                       then
+               then
                        PROGRAM_DEPENDS='REBUILD_PKGDB CLEANUP_OBSLETE_DISTFILES '
                        _program_exec_and_record_completion__operation ()
                        {
                        }
                        program_exec_and_record_completion ALL_COMPLETE
-                       message_echo "- E N D -"
+                       [ $opt_no_opening_message = yes ] || message_echo "- E N D -"
                else
                        message_echo "INFO: Redo for the real (re)installation."
                fi