OSDN Git Service

[BUG FIX] Error messages from failed detection of option configuration were not output.
[portsreinstall/current.git] / bin / portsreinstall
index aea6d4c..ee70834 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh -e
 # ==================================================================================
 # portsreinstall main script
-# Copyright (C) 2010-2015 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
+# Copyright (C) 2010-2016 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
 # This software is distributed under the 2-Clause BSD License.
 # ==================================================================================
 
 # ============ Set up of environment =============
 APPNAME=`basename "$0"`
 
-# MYVERSION=3.2.1
-# COMPATIBLE_VERSIONS='^(3\.[1-2]\.[0-9]+)$'
+MYVERSION=3.3.1
+COMPATIBLE_VERSIONS='^(3\.[1-3]\.[0-9]+)$'
 # Template for development versions
-MYVERSION=3.2.0+toward_3.2.1_20150120223451
-COMPATIBLE_VERSIONS='^(3\.[1-2]\.[0-9]+\+toward_3\.[1-2]\.[0-9]+_[0-9]+|3\.[1-2]\.[0-9]+)$'
+MYVERSION=3.3.0+toward_3.3.1_20160818131629
+COMPATIBLE_VERSIONS='^(3\.[1-3]\.[0-9]+\+toward_3\.[1-3]\.[0-9]+_[0-9]+|3\.[1-3]\.[0-9]+)$'
 MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
 MYPREFIX=${MYPREFIX:-/usr/local}
 LIBDIR=${MYPREFIX}/lib/${APPNAME}
@@ -747,7 +747,7 @@ do
                origin=`str_dirpath_to_origin "$dbpath"`
                for suffix in '' .orig
                do
-                       database_build_get_complete_recursive_dependency requirements.${tag} "$origin" "$suffix" > /dev/null
+                       database_build_get_complete_recursive_dependency "$tag" "$origin" "$suffix" > /dev/null
                done
        }
        _program_exec_and_record_completion__operation ()
@@ -799,13 +799,13 @@ _program_exec_restartable_loop_operation__routine ()
        origin=`str_dirpath_to_origin "$dbpath"`
        for tag in all run build
        do
-               for level in direct full
+               for suffix in '' .orig
                do
-                       for suffix in '' .orig
+                       for level in direct full
                        do
                                srcdb=requirements.${tag}.${level}${suffix}
-                               dstdb=dependents.${tag}.${level}${suffix}
                                [ -e "$dbpath/$srcdb" ] || continue
+                               dstdb=dependents.${tag}.${level}${suffix}
                                while read origin_requirement
                                do
                                        dstpath=${DBDIR}/requires/$origin_requirement
@@ -816,6 +816,18 @@ _program_exec_restartable_loop_operation__routine ()
                                        echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_dependents_lists_unique.tmp
                                done < $dbpath/$srcdb
                        done
+                       srcdb=ignored_requirements.${tag}${suffix}
+                       [ -e "$dbpath/$srcdb" ] || continue
+                       dstdb=ignored_dependents.${tag}${suffix}
+                       while read origin_requirement
+                       do
+                               dstpath=${DBDIR}/requires/$origin_requirement
+                               echo "$dstpath/$dstdb" >> ${DBDIR}/ignored_dependents_files.tmp
+                               [ "$dstpath/$dstdb" -nt "$dbpath/$srcdb" ] && continue
+                               [ -d "$dstpath" ] || mkdir -p "$dstpath"
+                               echo "$origin" >> $dstpath/$dstdb.raw
+                               echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_ignored_dependents_lists_unique.tmp
+                       done < $dbpath/$srcdb
                done
        done
 }
@@ -825,12 +837,15 @@ _program_exec_and_record_completion__operation ()
        message_section_title "Inspection of dependents"
        dbrequires_valesc=`str_escape_replaceval "${DBDIR}/requires/"`
        program_exec_restartable_loop_operation inspect_dependent
-       sort -u "${DBDIR}/stage.loop_list/make_dependents_lists_unique.tmp" 2> /dev/null \
-               > ${DBDIR}/stage.loop_list/make_dependents_lists_unique || :
-       sort -u "${DBDIR}/dependents_files.tmp" 2> /dev/null > ${DBDIR}/dependents_files || :
-       [ -e "${DBDIR}/make_dependents_lists_unique.prev" ] && \
-               fileedit_manipulate_old_lines "${DBDIR}/dependents_files.prev" "${DBDIR}/dependents_files" \
-               | xargs rm -f
+       for dbtype in dependents ignored_dependents
+       do
+               sort -u "${DBDIR}/stage.loop_list/make_${dbtype}_lists_unique.tmp" 2> /dev/null \
+                       > ${DBDIR}/stage.loop_list/make_${dbtype}_lists_unique || :
+               sort -u "${DBDIR}/${dbtype}_files.tmp" 2> /dev/null > ${DBDIR}/${dbtype}_files || :
+               [ -e "${DBDIR}/make_${dbtype}_lists_unique.prev" ] && \
+                       fileedit_manipulate_old_lines "${DBDIR}/${dbtype}_files.prev" "${DBDIR}/${dbtype}_files" \
+                       | xargs rm -f
+       done
        message_echo
 }
 program_exec_and_record_completion INSPECT_DEPENDENTS
@@ -854,6 +869,25 @@ _program_exec_and_record_completion__operation ()
 }
 program_exec_and_record_completion MAKE_DEPENDENTS_LISTS_UNIQUE
 
+# Remove duplicated lines in ignored dependents lists
+PROGRAM_DEPENDS='CONVERT_REQUIREMENTS_LIST INSPECT_DEPENDENTS'
+_program_exec_restartable_loop_operation__routine ()
+{
+       local dbpath tag level dstdb
+       dstdb=$1
+       cat "$dstdb" "$dstdb.raw" 2> /dev/null | sort -u > $dstdb.tmp
+       mv "$dstdb.tmp" "$dstdb"
+       rm -f "$dstdb.raw"
+}
+_program_exec_and_record_completion__operation ()
+{
+       local dbrequires_valesc
+       message_section_title "Removing duplicated items in ignored dependents lists"
+       program_exec_restartable_loop_operation make_ignored_dependents_lists_unique
+       message_echo
+}
+program_exec_and_record_completion MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE
+
 # Preparation of target attribute information
 for _TARGET_ATTR_INFO_table in requirements dependents itself
 do
@@ -900,7 +934,7 @@ do
 done
 
 # Post-process after the preparation of target attribute information
-PROGRAM_DEPENDS='MAKE_DEPENDENTS_LISTS_UNIQUE TARGET_ATTR_INFO:requirements TARGET_ATTR_INFO:dependents'
+PROGRAM_DEPENDS='MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE TARGET_ATTR_INFO:requirements TARGET_ATTR_INFO:dependents'
 _program_exec_and_record_completion__operation ()
 {
        message_section_title "Post-process after the preparation of target attribute information"
@@ -984,7 +1018,7 @@ program_exec_and_record_completion INSPECT_NECESSITY
 # Inspection of necessary upgrades
 for _NECESSARY_UPDATES_level in direct full
 do
-       PROGRAM_DEPENDS='INSPECT_NECESSITY INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE'
+       PROGRAM_DEPENDS='INSPECT_NECESSITY INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE'
        _program_exec_restartable_loop_operation__routine ()
        {
                local markerpath level dbpath origin tag
@@ -996,11 +1030,12 @@ do
                for tag in all run build none
                do
                        touch "$dbpath/necessary_upgrade.$tag.${level}"
-                       [ -e "$dbpath/dependents.$tag.${level}" ] || continue
-                       while read origin_dependent
-                       do
-                               touch "${DBDIR}/requires/$origin_dependent/necessary_upgrade.$tag.${level}"
-                       done < $dbpath/dependents.$tag.${level}
+                       [ -e "$dbpath/dependents.$tag.${level}" -o "$dbpath/ignored_dependents.$tag" ] || continue
+                       cat "$dbpath/dependents.$tag.${level}" "$dbpath/ignored_dependents.$tag" 2> /dev/null | \
+                               while read origin_dependent
+                               do
+                                       touch "${DBDIR}/requires/$origin_dependent/necessary_upgrade.$tag.${level}"
+                               done
                done
        }
        _program_exec_and_record_completion__operation ()
@@ -1017,11 +1052,11 @@ done
 # Preparation for inspection of new leaf ports
 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
 then
-       PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE PARSE_CONF'
+       PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE PARSE_CONF'
        _program_exec_and_record_completion__operation ()
        {
                message_section_title "Preparation for inspection of new leaf ports"
-               find "${DBDIR}/requires" -depth 3 -type f -name dependents.all.full \
+               find "${DBDIR}/requires" -depth 3 -type f -name dependents.all.full -or -name ignored_dependents.all \
                        | sed -E 's|.*/([^/]+/[^/]+)/[^/]+$|\1|' \
                        | sort -u > ${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:nonleaf_ports
                sort -u "${DBDIR}/inspected_ports" > ${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:inspected_ports
@@ -1040,7 +1075,7 @@ fi
 # Inspection of new primary leaf ports
 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
 then
-       PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE PREPARE_INSPECT_LEAF_PORTS PARSE_CONF'
+       PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE PREPARE_INSPECT_LEAF_PORTS PARSE_CONF'
        _program_exec_restartable_loop_operation__routine ()
        {
                local origin origin_ini origin_esc dbpath origin_req
@@ -1062,9 +1097,10 @@ then
                                -a `cat "${DBDIR}/initial/$origin/dependents.all.full" 2> /dev/null | wc -l` -eq 0 ] \
                                && return
                fi
-               if [ -e "$dbpath/requirements.all.full" ]
+               if [ -e "$dbpath/requirements.all.full" -o -e "$dbpath/ignored_requirements.all" ]
                then
-                       grep -v -E -f "${DBDIR}/conf/HOLD_PORTS.grep_pattern" "$dbpath/requirements.all.full" | \
+                       cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null | \
+                               grep -v -E -f "${DBDIR}/conf/HOLD_PORTS.grep_pattern" | \
                                fileedit_add_lines_if_new "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || :
                fi
                fileedit_add_a_line_if_new "^$origin_esc$" "${DBDIR}/grep.leaf_ports.pattern"
@@ -1085,7 +1121,7 @@ fi
 # Inspection of requirements of new leaf ports
 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
 then
-       PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE INSPECT_PRIMARY_LEAF_PORTS PARSE_CONF'
+       PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE INSPECT_PRIMARY_LEAF_PORTS PARSE_CONF'
        _program_exec_and_record_completion__operation ()
        {
                local num_leaves num_leaves_prev num_inspect num_leaves_new
@@ -1101,9 +1137,9 @@ then
                                dbpath=${DBDIR}/requires/$origin
                                origin_esc=`str_escape_regexp "$origin"`
                                grep -q -E "^$origin_esc$" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
-                               grep -E -v -f "${DBDIR}/grep.leaf_ports.pattern" \
-                                       "$dbpath/dependents.all.full" > /dev/null 2>&1 && return
-                               cat "$dbpath/requirements.all.full" 2> /dev/null \
+                               cat "$dbpath/dependents.all.full" "$dbpath/ignored_dependents.all"  2> /dev/null \
+                                       | grep -Eq -v -f "${DBDIR}/grep.leaf_ports.pattern" && return
+                               cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null \
                                        >> ${DBDIR}/leaf_ports_secondary_candidates.new_requirements || :
                                fileedit_add_a_line_if_new "^$origin_esc$" "${DBDIR}/grep.leaf_ports.pattern"
                        }
@@ -1193,8 +1229,8 @@ then
                reqptn_file=${DBDIR}/leaf_ports.requirements_of_unselected.grep_pattern
                cat "$src_unselected" 2> /dev/null | while read origin
                do
-                       cat "${DBDIR}/requires/$origin/requirements.all.full" || :
-               done | sort -u | str_escape_regexp_filter \
+                       cat "${DBDIR}/requires/$origin/requirements.all.full" "${DBDIR}/requires/$origin/ignored_requirements.all" || :
+               done 2> /dev/null | sort -u | str_escape_regexp_filter \
                        | sed 's/^/^/;s/$/$/' > $reqptn_file
                database_query_add_initial_origins < $src > $src_with_initial_origins
                message_echo
@@ -1344,7 +1380,7 @@ _program_exec_and_record_completion__operation ()
 program_exec_and_record_completion CLEANUP_REINST_STATUS
 
 # Completion of building the temporary database
-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 COLLECT_LEAF_PORTS_TO_DELETE'
+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_exec_and_record_completion__operation ()
 {
        message_section_title "The temporary database is completely built up"