OSDN Git Service

Fixed a bug that obsolete or moved ports were not inspected. For this purpose, the...
[portsreinstall/current.git] / lib / libdatabase_build.sh
index 46f0a4d..bef02a7 100644 (file)
@@ -45,6 +45,7 @@ database_build_convert_and_register_origin_if_obsolete ()
        if [ `wc -l < ${TMPDIR}/moved.info` -eq 0 ]
        then
                fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports"
+               fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
                if [ -n "$recursedb_in" ]
                then
                        message_echo "${DEPTH_INDEX}  ===> Disappeared port (MOVED broken?)"
@@ -62,10 +63,13 @@ database_build_convert_and_register_origin_if_obsolete ()
                then
                        message_echo "${DEPTH_INDEX}  ===> Moved to $origin_new at $date_moved because \"$why_moved\""
                        fileedit_add_a_line_if_new "$origin" "${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origins_old"
+                       fileedit_add_a_line_if_new "$origin" "${DBDIR}/moved_ports"
+                       fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
                        database_build_convert_and_register_origin_if_obsolete "$origin_new" "${TMPDIR}/MOVED.DB" || return 1
                else
                        message_echo "${DEPTH_INDEX}  ===> Deleted at $date_moved because \"$why_moved\""
                        fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports"
+                       fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
                        return 1
                fi
        fi
@@ -296,6 +300,7 @@ database_build_is_port_already_inspected_in_required_level ()
        inspected_level=`database_build_get_inspected_level "$origin_actual" "$origin_dependent"`
        {
                cat "${DBDIR}/ports.inspected.${inspected_level}.list" || :
+               cat "${DBDIR}/moved_ports" || :
                cat "${DBDIR}/obsolete_ports" || :
        }  2> /dev/null | grep -q -Fx "$origin_actual" || return
        fileedit_rm_a_line "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
@@ -477,43 +482,62 @@ database_build_determine_flavored_origin ()
 database_build_escape_inspect_conflict ()
 {
        local origin dbpath
+       origin=$1
        dbpath=${DBDIR}/requires/$origin
        if [ -e "$dbpath/CONFLICT.conf" ]
        then
                message_echo "${DEPTH_INDEX}  ===> Escaping inspection conflict..."
-               pkgsys_eval_ports_glob `cat "$dbpath/CONFLICT.conf"` | while read origin_conflict
-               do
-                       pkg_conflict=`pkgsys_get_installed_pkg_from_origin "$origin_conflict"`
-                       [ -n "$pkg_conflict" ] || continue
-                       message_echo "${DEPTH_INDEX}  ===> Escaping $pkg_conflict..."
-                       pkgarc=`pkgsys_create_backup_pkg "$pkg_conflict" "${DBDIR}/backup_packages" 2> /dev/null` || \
-                               message_echo "${DEPTH_INDEX}  ===> (WARNING: Failed to back up)"
-                       pkg_delete_f "$pkg_conflict" > /dev/null 2>&1 || \
-                               message_echo "${DEPTH_INDEX}  ===> (WARNING: Failed to delete)"
-                       [ -n "$pkgarc" ] && printf '%s\t%s\n' "$pkg_conflict" "$pkgarc" >> $dbpath/CONFLICT_pkgarc.lst
-               done
+               pkgsys_eval_ports_glob `cat "$dbpath/CONFLICT.conf"` | database_build_escape "$dbpath/CONFLICT_pkgarc.lst"
        fi
 }
 
+# ============= Escape of conflicts =============
+# A list of conflict package origins are given by stdin.
+database_build_escape ()
+{
+       local backup_list origin_conflict pkg_conflict pkgarc
+       backup_list=$1
+       while read origin_conflict
+       do
+               pkg_conflict=`pkgsys_get_installed_pkg_from_origin "$origin_conflict"`
+               [ -n "$pkg_conflict" ] || continue
+               message_echo "${DEPTH_INDEX}  ===> Escaping $pkg_conflict..."
+               pkgarc=`pkgsys_create_backup_pkg "$pkg_conflict" "${DBDIR}/backup_packages" 2> /dev/null` || \
+                       message_echo "${DEPTH_INDEX}  ===> (WARNING: Failed to back up)"
+               pkg_delete_f "$pkg_conflict" > /dev/null 2>&1 || \
+                       message_echo "${DEPTH_INDEX}  ===> (WARNING: Failed to delete)"
+               [ -n "$pkgarc" ] && printf '%s\t%s\n' "$pkg_conflict" "$pkgarc" >> $backup_list
+       done
+}
+
 # ============= Restoration of escaped inspection conflict =============
 database_build_restore_inspect_conflict ()
 {
        local origin dbpath
+       origin=$1
        dbpath=${DBDIR}/requires/$origin
        if [ -e "$dbpath/CONFLICT.conf" ]
        then
                message_echo "${DEPTH_INDEX}  ===> Restoring inspection conflict..."
-               cat "$dbpath/CONFLICT_pkgarc.lst" 2> /dev/null | while read pkg_conflict pkgarc
-               do
-                       pkg_info_e "$pkg_conflict" && continue
-                       message_echo "${DEPTH_INDEX}  ===> Restoring $pkg_conflict..."
-                       pkg_add_f "$pkgarc" > /dev/null 2>&1 || \
-                               message_echo "${DEPTH_INDEX}  ===> (WARNING: Failed to restore $pkg_conflict)"
-               done
+               cat "$dbpath/CONFLICT_pkgarc.lst" 2> /dev/null | database_build_restore
                rm -f "$dbpath/CONFLICT_pkgarc.lst"
        fi
 }
 
+# ============= Restoration of escaped conflicts =============
+# The backup list is given by stdin.
+database_build_restore ()
+{
+       local pkg_conflict pkgarc
+       while read pkg_conflict pkgarc
+       do
+               pkg_info_e "$pkg_conflict" && continue
+               message_echo "${DEPTH_INDEX}  ===> Restoring $pkg_conflict..."
+               pkg_add_f "$pkgarc" > /dev/null 2>&1 || \
+                       message_echo "${DEPTH_INDEX}  ===> (WARNING: Failed to restore $pkg_conflict)"
+       done
+}
+
 # ============= Recursively inspect dependencies of a port and build a node database of the information =============
 database_build_inspect_dependencies ()
 {
@@ -528,9 +552,8 @@ database_build_inspect_dependencies ()
                message_echo "${DEPTH_INDEX} $origin_orig"
                database_build_convert_and_register_origin_if_obsolete__reset_origins_old
                origin_id=`echo "$origin_orig" | tr / :`
-               database_build_setup_initial_node "$origin_orig"
                # Replacement specified by the configuration file, knobs and port options
-               tmp_config=${TMPDIR}/database_build_inspect_dependencies:confi
+               tmp_config=${TMPDIR}/database_build_inspect_dependencies:config
                database_build_setup_replace_node "$origin_orig" "$tmp_config.before" "$tmp_config.after"
                if [ -e "${DBDIR}/replace/$origin_orig/origin" ]
                then
@@ -556,6 +579,7 @@ database_build_inspect_dependencies ()
                        if ! grep -qFx "$origin" "${DBDIR}/done_required_ports_to_inspect" 2> /dev/null
                        then
                                fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
+                               fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
                                dbpath=${DBDIR}/requires/$origin
                                dbpath_prev=${DBDIR}/prevset/requires/$origin
                                if [ ! -e "$dbpath/complete_as_node" ] || \
@@ -933,7 +957,7 @@ database_build_get_complete_recursive_dependency ()
                mv "$tmppath.parents.tmp" "$tmppath.parents"
                if [ ! -e "$dstfile" ]
                then
-                       sort -u "$dstfile_tmp" | grep -v '^$' > $dstfile
+                       sort -u "$dstfile_tmp" | grep -v '^$' > $dstfile || :
                        rm "$dstfile_tmp"
                fi
        fi
@@ -1083,6 +1107,7 @@ _database_build_reset_a_port_confdb ()
                fileedit_rm_a_line "$origin" "${DBDIR}/ports.inspected.${level}.list"
        done
        fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
+       fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
        fileedit_rm_a_line "$origin" "${DBDIR}/ports.inspected.list"
        cat "${DBDIR}/replace/$origin/origin" 2> /dev/null || :
 }
@@ -1123,6 +1148,13 @@ database_build_patch_reconf ()
        database_build_clear_db_dirs "$origin"
 }
 
+# ============= Post-processes after finishing to inspect initial dependencies =============
+database_build_post_inspect_initial_dependencies ()
+{
+       find "${DBDIR}/initial" -depth 2 -type d \
+               | sed -E 's|.*/([^/]+/[^/]+)$|\1|' > ${DBDIR}/inspected_ports.initial
+}
+
 # ============= Post-processes after finishing to inspect dependencies =============
 database_build_post_inspect_dependencies ()
 {
@@ -1131,8 +1163,6 @@ database_build_post_inspect_dependencies ()
        touch "${DBDIR}/obsolete_ports" "${DBDIR}/inspected_ports.update"
        find "${DBDIR}/requires" -depth 2 -type d \
                | sed -E 's|.*/([^/]+/[^/]+)$|\1|' > ${DBDIR}/inspected_ports
-       find "${DBDIR}/initial" -depth 2 -type d \
-               | sed -E 's|.*/([^/]+/[^/]+)$|\1|' > ${DBDIR}/inspected_ports.initial
        sort -u "${DBDIR}/inspected_ports" "${DBDIR}/inspected_ports.initial" > ${DBDIR}/inspected_ports.all
        {
                cat "${DBDIR}/conf/HOLD:PORTS.parsed" || :