#!/bin/sh -e
# ==================================================================================
# portsreinstall main script
-# Copyright (C) 2010-2014 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.0.6
-# COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
+MYVERSION=3.3.1
+COMPATIBLE_VERSIONS='^(3\.[1-3]\.[0-9]+)$'
# Template for development versions
-MYVERSION=3.0.5+toward_3.0.6_20140607194853
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.[0-9]+_[0-9]+|3\.0\.[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}
PROGRAM_DEPENDS=''
_program_exec_and_record_completion__operation ()
{
+ local tmp_installed_ports tmp_installed_pkgs
message_section_title "Collecting all installed packages"
- pkg_info_qoa > ${DBDIR}/installed_ports
- pkg_info_gen_pkg_origin_table
+ if [ -e "${DBDIR}/installed_ports.inspected" ]
+ then
+ if ! [ "${DBDIR}/installed_ports" -ot "${DBDIR}/initial" -a "${DBDIR}/installed_ports:pkg_vs_origin.tbl" -ot "${DBDIR}/initial" ]
+ then
+ find "${DBDIR}/initial" -depth 2 -type d \
+ | sed -E 's|.*/([^/]+/[^/]+)$|\1|' > ${DBDIR}/installed_ports || :
+ while read origin
+ do
+ pkg=`cat "${DBDIR}/initial/$origin/installed_version" 2>/dev/null` || continue
+ printf '%s\t%s\n' "$origin" "$pkg"
+ done < ${DBDIR}/installed_ports > ${DBDIR}/installed_ports:pkg_vs_origin.tbl
+ fi
+ else
+ pkg_info_qoa > ${DBDIR}/installed_ports
+ pkg_info_gen_pkg_origin_table
+ fi
str_escape_regexp_filter < "${DBDIR}/installed_ports" \
| sed 's/^/^/; s/$/$/' > ${DBDIR}/installed_ports.grep_pattern
message_echo
local DEPTH_INDEX
message_section_title "Preliminary inspection of tools which have to be up-to-date"
{
- [ "$PKGSYS_USE_PKGNG" = yes ] && echo 'ports-mgmt/pkg'
- pkgsys_is_dialog4ports_used && echo 'ports-mgmt/dialog4ports'
+ [ "$PKGSYS_USE_PKGNG" = yes ] && pkgsys_portsmgmt_pkg
+ pkgsys_is_dialog4ports_used && pkgsys_portsmgmt_dialog4ports
[ -n "$MYPORTORIGIN" ] && echo "$MYPORTORIGIN"
} 2> /dev/null > ${DBDIR}/stage.loop_list/tools_to_inspect
DEPTH_INDEX='--'
}
program_exec_and_record_completion PRELIMINARY_INSPECTION_OF_TOOLS
-# Upgrade of ports-mgmt/pkg if new
+# Upgrade of pkg(8) if new
# (No need depend on PARSE_CONF because REINSTALLATION will take the task.)
if [ \( "$COMMAND_MODE" = do -o "$COMMAND_MODE" = redo \) \
-a $opt_dry_run = no -a $opt_suppress_pkgtools_upadte = no \
_program_exec_and_record_completion__operation ()
{
local _MSG_CURRENT_STAGE_general
- _MSG_CURRENT_STAGE_general="pkgng upgrade"
+ _MSG_CURRENT_STAGE_general="pkg(8) upgrade"
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
- message_section_title "Upgrade of ports-mgmt/pkg if new"
+ message_section_title "Upgrade of `pkgsys_portsmgmt_pkg` if new"
touch "${DBDIR}/target_all"
- reinstall_exec ports-mgmt/pkg
+ reinstall_exec `pkgsys_portsmgmt_pkg`
reinstall_restore_conflicts
rm -f "${DBDIR}/target_all"
temp_set_msg_current_stage
program_exec_and_record_completion UPGRADE_PKGNG
fi
-# Upgrade of ports-mgmt/dialog4ports if new
+# Upgrade of dialog4ports(1) if new
# (No need depend on PARSE_CONF because REINSTALLATION will take the task.)
if [ \( "$COMMAND_MODE" = do -o "$COMMAND_MODE" = redo \) \
-a $opt_dry_run = no -a $opt_suppress_pkgtools_upadte = no ] \
_program_exec_and_record_completion__operation ()
{
local _MSG_CURRENT_STAGE_general
- _MSG_CURRENT_STAGE_general="pkgng dialog4ports"
+ _MSG_CURRENT_STAGE_general="dialog4ports(1) upgrade"
temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
- message_section_title "Upgrade of dialog4ports if new"
+ message_section_title "Upgrade of `pkgsys_portsmgmt_dialog4ports` if new"
touch "${DBDIR}/target_all"
- reinstall_exec ports-mgmt/dialog4ports
+ reinstall_exec `pkgsys_portsmgmt_dialog4ports`
reinstall_restore_conflicts
rm -f "${DBDIR}/target_all"
temp_set_msg_current_stage
[ -n "$to" ] && echo "$to"
done
fi > $tmpfile_updated_ports
+ sort -u "${DBDIR}/conf/NOPKG:PORTS.parsed" 2> /dev/null > ${TMPDIR}/NOPKG:PORTS.parsed.new || :
+ sort -u "${DBDIR}/conf.prev/NOPKG:PORTS.parsed" 2> /dev/null > ${TMPDIR}/NOPKG:PORTS.parsed.old || :
+ diff "${TMPDIR}/NOPKG:PORTS.parsed.old" "${TMPDIR}/NOPKG:PORTS.parsed.new" | sed -n 's/^[<>] //p' >> $tmpfile_updated_ports
if fileedit_manipulate_old_new_lines \
"${DBDIR}/conf.prev/REPLACE.csv" "${DBDIR}/conf/REPLACE.csv" "$tmpfile_old" "$tmpfile_new"
then
for tag in all run build
do
( cd "${DBDIR}/requires" && \
- find . -depth 3 -type f -name requirements.${tag}.full | sed 's|^./||;s|/[^/]*$||' ) \
+ find . -depth 3 -type f -name requirements.${tag}.full -or -name requirements.${tag}.full.orig ) \
+ | sort -u \
+ | sed 's|^./||;s|/[^/]*$||' \
| grep -v -E -f "${DBDIR}/update_dependencies.grep_pattern" \
| str_escape_regexp_filter | sed 's/^/^/; s/$/$/' \
> ${TMPDIR}/convert_requirements_list:full_complete.grep_pattern || :
( cd "${DBDIR}/requires" && \
- find . -depth 3 -type f -name requirements.${tag}.direct | sed 's|^./||;s|/[^/]*$||' ) \
+ find . -depth 3 -type f -name requirements.${tag}.direct -or -name requirements.${tag}.direct.orig ) \
+ | sort -u \
+ | sed 's|^./||;s|/[^/]*$||' \
| grep -v -E -f "${TMPDIR}/convert_requirements_list:full_complete.grep_pattern" \
- > ${DBDIR}/stage.loop_list/complete_${tag}time_reqlists || :
+ > ${DBDIR}/stage.loop_list/complete_recursive_${tag}time_reqlists || :
done
for inspected_level_tmp in direct node
do
PROGRAM_DEPENDS='CONVERT_REQUIREMENTS_LIST'
_program_exec_restartable_loop_operation__routine ()
{
- local tag dbpath origin
+ local tag dbpath origin suffix
tag=${_REQUIREMENT_LISTS_tag}
dbpath=$1
origin=`str_dirpath_to_origin "$dbpath"`
- database_build_get_complete_recursive_dependency requirements.${tag} "$origin" > /dev/null
+ for suffix in '' .orig
+ do
+ database_build_get_complete_recursive_dependency "$tag" "$origin" "$suffix" > /dev/null
+ done
}
_program_exec_and_record_completion__operation ()
{
local tag
tag=${_REQUIREMENT_LISTS_tag}
message_section_title "Completion of ${tag}-time requirement lists"
- program_exec_restartable_loop_operation complete_${tag}time_reqlists
+ program_exec_restartable_loop_operation complete_recursive_${tag}time_reqlists
message_echo
}
- program_exec_and_record_completion REQUIREMENT_LISTS:${_REQUIREMENT_LISTS_tag}
+ program_exec_and_record_completion RECURSIVE_REQUIREMENT_LISTS:${_REQUIREMENT_LISTS_tag}
done
# Trim dependency lists by removing uninspected ports
PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES CONVERT_REQUIREMENTS_LIST TRIM_DEPENDENCY_LISTS_RM_UNINSPECTED_PORTS'
_program_exec_restartable_loop_operation__routine ()
{
- local dbpath origin tag level srcdb dstdb
+ local dbpath origin tag level suffix srcdb dstdb
dbpath=$1
origin=`str_dirpath_to_origin "$dbpath"`
for tag in all run build
do
- for level in direct full
+ for suffix in '' .orig
do
- srcdb=requirements.${tag}.${level}
- dstdb=dependents.${tag}.${level}
+ for level in direct full
+ do
+ srcdb=requirements.${tag}.${level}${suffix}
+ [ -e "$dbpath/$srcdb" ] || continue
+ dstdb=dependents.${tag}.${level}${suffix}
+ while read origin_requirement
+ do
+ dstpath=${DBDIR}/requires/$origin_requirement
+ echo "$dstpath/$dstdb" >> ${DBDIR}/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_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}/dependents_files.tmp
+ 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_dependents_lists_unique.tmp
+ echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_ignored_dependents_lists_unique.tmp
done < $dbpath/$srcdb
done
done
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
}
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
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"
program_exec_and_record_completion PARSE_TARGET_ATTR_INFO
# Inspection of necessity
-PROGRAM_DEPENDS='TARGET_ATTR_INFO_POSTPROCESS REQUIREMENT_LISTS:run-time REQUIREMENT_LISTS:build-time INSPECT_ALL_DEPENDENCIES'
+PROGRAM_DEPENDS='TARGET_ATTR_INFO_POSTPROCESS RECURSIVE_REQUIREMENT_LISTS:run RECURSIVE_REQUIREMENT_LISTS:build INSPECT_ALL_DEPENDENCIES'
_program_exec_restartable_loop_operation__routine ()
{
local origin
# 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
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 ()
# 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
# 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
-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"
# 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
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"
}
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
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"