2 # ==============================================================================
3 # portsreinstall library script
4 # - Operations for building the temporary database -
5 # Copyright (C) 2013-2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
6 # This software is distributed under the 2-Clause BSD License.
7 # ==============================================================================
9 # ============= Register an obsolete flavored origin =============
10 database_build_register_obsolete_port ()
12 local origin dbpath pkgtag
14 dbpath=${DBDIR}/obsolete/$origin
15 [ -e "$dbpath/complete_as_node" ] && return
16 mkdir -p "${DBDIR}/obsolete/$origin"
17 pkgtag=`pkgsys_get_init_pkg_from_orig "$origin"`
18 [ -n "$pkgtag" ] || pkgtag='[not installed]'
19 echo "$pkgtag" > ${DBDIR}/obsolete/$origin/pkgtag
20 for table in dependents requirements
22 for level in direct full
24 for tag in all run build
26 srcfile=${DBDIR}/initial/$origin/${table}.${tag}.${level}
27 [ -e "$srcfile" ] && ln -f "$srcfile" "$dbpath/${table}.${tag}.${level}.src"
31 touch "$dbpath/complete_as_node"
34 # ============= Convert and register if a flavored origin is obsolete =============
35 database_build_convert_and_register_origin_if_obsolete ()
37 local origin recursedb_in recursedb output_origin iline_db origin_new date_moved why_moved
40 recursedb=${recursedb_in:-${PORTS_MOVED_DB}}
41 echo "$origin" > ${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origin
42 pkgsys_exists_port "$origin" && return
43 database_build_register_obsolete_port "$origin"
44 grep -n -m 1 -E "^`str_escape_regexp \"$origin\"`\|" "$recursedb" 2> /dev/null > ${TMPDIR}/moved.info || :
45 if [ `wc -l < ${TMPDIR}/moved.info` -eq 0 ]
47 fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports"
48 fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
49 if [ -n "$recursedb_in" ]
51 message_echo "${DEPTH_INDEX} ===> Disappeared port (MOVED broken?)"
53 message_echo "${DEPTH_INDEX} ===> Nonexistent port (your original?)"
57 iline_db=`cut -d : -f 1 "${TMPDIR}/moved.info"`
58 sed 1,${iline_db}d "${PORTS_MOVED_DB}" > ${TMPDIR}/MOVED.DB
59 origin_new=`sed -E 's/^[0-9]+://' "${TMPDIR}/moved.info" | cut -d '|' -f 2 || :`
60 date_moved=`cut -d '|' -f 3 "${TMPDIR}/moved.info" || :`
61 why_moved=`cut -d '|' -f 4 "${TMPDIR}/moved.info" || :`
62 if [ -n "$origin_new" ]
64 message_echo "${DEPTH_INDEX} ===> Moved to $origin_new at $date_moved because \"$why_moved\""
65 fileedit_add_a_line_if_new "$origin" "${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origins_old"
66 fileedit_add_a_line_if_new "$origin" "${DBDIR}/moved_ports"
67 fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
68 database_build_convert_and_register_origin_if_obsolete "$origin_new" "${TMPDIR}/MOVED.DB" || return 1
70 message_echo "${DEPTH_INDEX} ===> Deleted at $date_moved because \"$why_moved\""
71 fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports"
72 fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
78 # ============= [Sub-function] Get the true latest flavored origin =============
79 database_build_convert_and_register_origin_if_obsolete__get_origin ()
81 cat "${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origin"
84 # ============= [Sub-function] Reset the all old origins of the tested flavored origin =============
85 database_build_convert_and_register_origin_if_obsolete__reset_origins_old ()
87 rm -rf "${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origins_old"
90 # ============= [Sub-function] Save the all old origins of the tested flavored origin =============
91 database_build_convert_and_register_origin_if_obsolete__save_origins_old ()
93 cat "${TMPDIR}/database_build_convert_and_register_origin_if_obsolete:origins_old" 2> /dev/null
96 # ============= Get the make arguments for building the temporary database =============
97 database_build_setup_make_args ()
102 for key in LOCALBASE LINUXBASE PORT_DBDIR PORTSDIR DISTDIR PACKAGES PKGREPOSITORY
104 eval echo $key=\$$key
106 echo 'DISABLE_VULNERABILITIES=yes'
107 if [ $opt_apply_default_config = yes ]
109 if pkgsys_is_dialog4ports_used
116 dbdir=${DBDIR}/requires/$origin
117 [ -d "$dbdir" ] || dbdir=${DBDIR}/conf/each_port/$origin
118 cat "$dbdir/MARG.conf" 2> /dev/null || :
119 flavor=`pkgsys_get_flavor_from_origin "$origin"`
120 [ -z "$flavor" ] || echo "FLAVOR=$flavor"
124 # ============= Get the make environment variables for building the temporary database =============
125 database_build_setup_make_envs ()
129 dbdir=${DBDIR}/requires/$origin
130 [ -d "$dbdir" ] || dbdir=${DBDIR}/conf/each_port/$origin
131 cat "$dbdir/MENV.conf" 2> /dev/null | tr '\n' ' '
134 # ============= Execute make command for building the temporary database =============
135 database_build_make ()
137 local origin MAKE_ARGS MAKE_ENVS port_path flavor
140 MAKE_ARGS=`database_build_setup_make_args "$origin"`
141 MAKE_ENVS=`database_build_setup_make_envs "$origin"`
142 port_path=`pkgsys_get_portpath_from_origin "$origin"`
143 fs_fix_unionfs_image_if_hidden "$port_path"
144 env $MAKE_ENVS make -C "$port_path" "$@" $MAKE_ARGS
147 # ============= Set up a temporary database node for the initial state of a port =============
148 database_build_setup_initial_node ()
150 local origin pkg dbpath
152 dbpath=${DBDIR}/initial/$origin
153 [ -e "$dbpath/complete_as_node" ] && return
156 pkg=`pkgsys_get_installed_pkg_from_origin "$origin"`
159 echo "$pkg" > $dbpath/installed_version
160 ln -f "$dbpath/installed_version" "$dbpath/pkgtag"
161 pkg_info_qr "$pkg" | while read requirement
163 origin_requirement=`pkgsys_init_pkg_orig_by_ambiguous_matching "$requirement" || :`
164 [ -n "$origin_requirement" ] && echo "$origin_requirement"
166 done > $dbpath/requirements.all.full
167 pkg_info_qR "$pkg" | while read dependent
169 origin_dependent=`pkgsys_init_pkg_orig_by_ambiguous_matching "$dependent" || :`
170 [ -n "$origin_dependent" ] && echo "$origin_dependent"
172 done > $dbpath/dependents.all.full
173 for table in dependents requirements
175 for level in direct full
177 for tag in all run build
179 [ "${tag}.${level}" = all.full ] && continue
180 ln -f "$dbpath/${table}.all.full" "$dbpath/${table}.${tag}.${level}"
185 if [ `expr "$pkg" : "^${APPNAME}-[0-9].*"` -gt 0 ]
187 [ -d "$dbpath" ] && touch "$dbpath/SUPPRESSED_SELF"
188 elif [ `expr "$pkg" : "^pkg-[0-9].*"` -gt 0 ]
190 [ -d "$dbpath" ] && touch "$dbpath/SUPPRESSED_PKGNG"
192 touch "$dbpath/complete_as_node"
195 # ============= Set up a temporary database node for the replaced/moved information of a port =============
196 database_build_setup_replace_node ()
198 local origin_orig portoption_before portoption_after origin_trial origin dbpath tmp_msg
202 dbpath=${DBDIR}/replace/$origin_orig
203 tmp_msg=${TMPDIR}/database_build_setup_replace_node:meg
204 if [ ! -e "$dbpath/complete_as_node" ]
208 origin_trial=$origin_orig
209 if echo "$origin_orig" | grep -q -Fx -f "${DBDIR}/conf/REPLACE.filter" 2> /dev/null
211 origin_trial=`echo "$origin_orig" | sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern"`
212 if [ "x$origin_orig" != "x$origin_trial" ]
214 if [ -n "$origin_trial" ]
216 message_echo "${DEPTH_INDEX} ===> Replaced with $origin_trial by user configuration"
218 database_build_register_obsolete_port "$origin_orig"
219 message_echo "${DEPTH_INDEX} ===> Deleted by user configuration"
223 if [ -n "$origin_trial" ]
225 if database_build_convert_and_register_origin_if_obsolete "$origin_trial" >> $dbpath/message
227 origin_trial=`database_build_convert_and_register_origin_if_obsolete__get_origin`
229 if [ "x$origin_trial" != "x$origin_orig" ]
231 message_echo "${DEPTH_INDEX} ===> Going back to the original port $origin_orig"
232 if database_build_convert_and_register_origin_if_obsolete "$origin_orig"
234 origin_trial=`database_build_convert_and_register_origin_if_obsolete__get_origin`
240 fi >> $dbpath/message
243 cat "$dbpath/message" 2> /dev/null || :
244 if [ -n "$origin_trial" ]
246 database_build_make "$origin_trial" showconfig > $portoption_before 2> /dev/null || :
247 database_build_determine_port_option "$origin_trial"
248 database_build_make "$origin_trial" showconfig > $portoption_after 2> /dev/null || :
249 origin=`database_build_determine_flavored_origin "$origin_trial"`
250 if [ "x$origin_trial" != "x$origin" ]
254 message_echo "${DEPTH_INDEX} ===> Transferred to $origin"
256 fileedit_add_a_line_if_new "$origin" "${DBDIR}/obsolete_ports"
257 message_echo "${DEPTH_INDEX} ===> Lost (Something is wrong!)"
260 cat "$tmp_msg" >> $dbpath/message
264 [ "x$origin_orig" = "x$origin" ] || echo "$origin" > $dbpath/origin
265 cat "$tmp_msg" 2> /dev/null || :
266 touch "$dbpath/complete_as_node"
268 cat "$dbpath/message" 2> /dev/null || :
272 # ============= Get the inspected level for a port with the current option settings =============
273 database_build_get_inspected_level ()
275 local origin origin_dependent
278 if [ $opt_only_target_scope = no ]
281 elif ! pkgsys_exists_or_existed_from_orig "$origin" \
282 || grep -qFx "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null \
283 || [ ! -e "${DBDIR}/moved_from/$origin_dependent/installed_version" ] \
284 || grep -qFx "$origin_dependent" "${DBDIR}/stage.loop_list/ports_to_inspect" 2> /dev/null
292 # ============= Check whether a port has been inspected in a required level =============
293 database_build_is_port_already_inspected_in_required_level ()
295 local origin origin_dependent origin_actual inspected_level
298 origin_actual=`echo "$origin" | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" 2> /dev/null || :`
299 [ -n "$origin_actual" ] || origin_actual=$origin
300 inspected_level=`database_build_get_inspected_level "$origin_actual" "$origin_dependent"`
302 cat "${DBDIR}/ports.inspected.${inspected_level}.list" || :
303 cat "${DBDIR}/moved_ports" || :
304 cat "${DBDIR}/obsolete_ports" || :
305 } 2> /dev/null | grep -q -Fx "$origin_actual" || return
306 fileedit_rm_a_line "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
307 [ "x$origin" = "$origin_actual" ] || \
308 fileedit_rm_a_line "$origin_actual" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
309 echo "$origin_actual"
312 # ============= Update the current package name of a port =============
313 database_build_update_pkgname ()
315 local origin dbdir pkg savefile
317 dbdir=${DBDIR}/moved_from/$origin
319 savefile=$dbdir/current_version
320 pkg=`pkgsys_get_installed_pkg_from_origin "$origin"`
321 if [ -z "$pkg" -a -e "$dbdir/initial_orig" ]
325 pkgsys_get_installed_pkg_from_origin "$orig_init"
326 done < $dbdir/initial_orig
330 fi | sort -u > $savefile
334 # ============= Get the current package name of a port =============
335 database_build_get_pkgname ()
337 local origin savefile
339 savefile=${DBDIR}/moved_from/$origin/current_version
340 if [ -e "$savefile" ]
344 database_build_update_pkgname "$origin"
348 # ============= Get the new package name of a port =============
349 database_build_get_new_pkgname ()
351 local origin savefile
353 savefile=${DBDIR}/requires/$origin/new_version
354 if [ ! -e "$savefile" ]
356 database_build_make "$origin" package-name \
357 | tr -d '\n' > $savefile
362 # ============= Get the package list of full-run-time requirements =============
363 database_build_get_full_run_requirement_pkgs ()
365 local origin srcfile savefile
367 srcfile=${DBDIR}/requires/$origin/requirements.run.full
368 savefile=${DBDIR}/requires/$origin/pkg_requirements.run.full
369 if [ ! -e "$srcfile" ]
372 elif [ ! -e "$savefile" -o "$savefile" -ot "$srcfile" ]
376 database_build_get_new_pkgname "$origin"
377 done < $srcfile | grep -v '^[[:space:]]*$' | sort -u > $savefile
379 cat "$savefile" 2> /dev/null || :
382 # ============= Build the original message tag showing the version upgrade =============
383 database_build_create_pkgtag ()
385 local origin dbdir pkg_init pkg_new pkgtag
387 dbdir=${DBDIR}/moved_from/$origin
389 pkg_init=`database_build_get_pkgname "$origin"`
390 [ -n "$pkg_init" -a ! -e "$dbdir/installed_version" ] && \
391 echo -n "$pkg_init" > $dbdir/installed_version
392 pkg_new=`database_build_get_new_pkgname "$origin"`
394 [ -n "$pkgtag" ] || pkgtag=$pkg_new
399 elif [ "x$pkg_init" != "x$pkg_new" ]
401 if [ -n "$pkg_init" ]
403 pkgtag="$pkg_init => $pkg_new"
405 pkgtag="[new] $pkg_new"
408 echo "$pkgtag" > $dbdir/pkgtag.orig
409 echo "$pkgtag" > $dbdir/pkgtag
412 # ============= Update the message tag showing the version upgrade =============
413 database_build_update_pkgtag ()
415 local origin dbdir pkg_init pkg_bak pkg_cur detail pkgtag
417 dbdir=${DBDIR}/moved_from/$origin
419 pkg_init=`cat "$dbdir/installed_version" 2> /dev/null | tr '\n' ' ' | sed 's/ *$//'`
420 pkg_bak=`cat "$dbdir/backedup_version" 2> /dev/null | tr '\n' ' ' | sed 's/ *$//'`
421 pkg_cur=`database_build_get_pkgname "$origin" | tr '\n' ' ' | sed 's/ *$//'`
423 if [ "x$pkg_init" != "x$pkg_cur" ]
427 detail=" [currently installed version: $pkg_cur]"
428 elif [ -n "$pkg_bak" ]
430 detail=" [currently deinstalled, previously installed version: $pkg_bak]"
432 detail=" [currently deinstalled]"
435 pkgtag=`cat "$dbdir/pkgtag.orig"`
436 echo "$pkgtag$detail" > $dbdir/pkgtag
439 # ============= Check whether the currently installed package version is the latest =============
440 database_build_is_currentpkg_latest ()
442 local origin pkg_cur pkg_new
444 pkg_cur=`database_build_get_pkgname "$origin" | tr '\n' ' ' | sed 's/ *$//'`
445 pkg_new=`database_build_get_new_pkgname "$origin"`
446 [ "x$pkg_cur" = "x$pkg_new" ]
448 # ============= Configure the port option to determine the true flavor =============
449 database_build_determine_port_option ()
453 if [ $opt_apply_default_config = yes ]
455 if ! pkgsys_is_dialog4ports_used
457 printf '\t\n' | database_build_make "$origin" config-conditional > /dev/null
460 database_build_make "$origin" config-conditional
464 # ============= Get the true flavor to determine the flavored port origin =============
465 database_build_determine_flavored_origin ()
467 local origin origin_unflavored flavor_trial origin_trial flavors_ptn flavor
469 origin_unflavored=`pkgsys_get_unflavored_origin "$origin"`
470 flavor_trial=`pkgsys_get_flavor_from_origin "$origin"`
471 if [ -n "$flavor_trial" ]
473 flavors_ptn="^("`database_build_make "$origin" -V FLAVORS 2> /dev/null | sed -E 's/[[:space:]]+/|/g'`")$"
474 echo "$flavor_trial" | grep -qE "$flavors_ptn" || flavor_trial=
476 origin_trial=`pkgsys_compose_flavored_origin "$origin_unflavored" "$flavor_trial"`
477 flavor=`database_build_make "$origin_trial" -V FLAVOR 2> /dev/null || :`
478 pkgsys_compose_flavored_origin "$origin_unflavored" "$flavor"
481 # ============= Escape of inspection conflict =============
482 database_build_escape_inspect_conflict ()
486 dbpath=${DBDIR}/requires/$origin
487 if [ -e "$dbpath/CONFLICT.conf" ]
489 message_echo "${DEPTH_INDEX} ===> Escaping inspection conflict..."
490 pkgsys_eval_ports_glob `cat "$dbpath/CONFLICT.conf"` | database_build_escape "$dbpath/CONFLICT_pkgarc.lst"
494 # ============= Escape of conflicts =============
495 # A list of conflict package origins are given by stdin.
496 database_build_escape ()
498 local backup_list origin_conflict pkg_conflict pkgarc
500 while read origin_conflict
502 pkg_conflict=`pkgsys_get_installed_pkg_from_origin "$origin_conflict"`
503 [ -n "$pkg_conflict" ] || continue
504 message_echo "${DEPTH_INDEX} ===> Escaping $pkg_conflict..."
505 pkgarc=`pkgsys_create_backup_pkg "$pkg_conflict" "${DBDIR}/backup_packages" 2> /dev/null` || \
506 message_echo "${DEPTH_INDEX} ===> (WARNING: Failed to back up)"
507 pkg_delete_f "$pkg_conflict" > /dev/null 2>&1 || \
508 message_echo "${DEPTH_INDEX} ===> (WARNING: Failed to delete)"
509 [ -n "$pkgarc" ] && printf '%s\t%s\n' "$pkg_conflict" "$pkgarc" >> $backup_list
513 # ============= Restoration of escaped inspection conflict =============
514 database_build_restore_inspect_conflict ()
518 dbpath=${DBDIR}/requires/$origin
519 if [ -e "$dbpath/CONFLICT.conf" ]
521 message_echo "${DEPTH_INDEX} ===> Restoring inspection conflict..."
522 cat "$dbpath/CONFLICT_pkgarc.lst" 2> /dev/null | database_build_restore
523 rm -f "$dbpath/CONFLICT_pkgarc.lst"
527 # ============= Restoration of escaped conflicts =============
528 # The backup list is given by stdin.
529 database_build_restore ()
531 local pkg_conflict pkgarc
532 while read pkg_conflict pkgarc
534 pkg_info_e "$pkg_conflict" && continue
535 message_echo "${DEPTH_INDEX} ===> Restoring $pkg_conflict..."
536 pkg_add_f "$pkgarc" > /dev/null 2>&1 || \
537 message_echo "${DEPTH_INDEX} ===> (WARNING: Failed to restore $pkg_conflict)"
541 # ============= Recursively inspect dependencies of a port and build a node database of the information =============
542 database_build_inspect_dependencies ()
544 local origin_orig origin_dependent origin_orig_regexp origin_replace origin tag stage level dbpath dbpath_prev origin_id tmp_config origin_dependency DEPTH_INDEX_orig nlines iline dist_subdir_rpl inspected_level inspected_levels_compatible origin_tmp inspected_level_tmp conf_updated tmp_portsdb_work tmp_portopt same_as_prevset dbfile installed_version frompath variable pkg_new
547 [ -z "$origin_orig" ] && return
548 if ! origin=`database_build_is_port_already_inspected_in_required_level "$origin_orig" "$origin_dependent"`
550 DEPTH_INDEX_orig=${DEPTH_INDEX}
551 DEPTH_INDEX="${DEPTH_INDEX}--"
552 message_echo "${DEPTH_INDEX} $origin_orig"
553 database_build_convert_and_register_origin_if_obsolete__reset_origins_old
554 origin_id=`echo "$origin_orig" | tr / :`
555 # Replacement specified by the configuration file, knobs and port options
556 tmp_config=${TMPDIR}/database_build_inspect_dependencies:config
557 database_build_setup_replace_node "$origin_orig" "$tmp_config.before" "$tmp_config.after"
558 if [ -e "${DBDIR}/replace/$origin_orig/origin" ]
560 origin=`cat "${DBDIR}/replace/$origin_orig/origin"`
564 # Build the database for this port
566 inspected_levels_compatible=
569 frompath=${DBDIR}/moved_from/$origin
571 database_build_convert_and_register_origin_if_obsolete__save_origins_old | \
572 fileedit_add_lines_if_new "$frompath/old_origs"
573 # Check the package name initially installed
574 installed_version=`cat "${DBDIR}/initial/$origin_orig/installed_version" 2> /dev/null || :`
575 [ -n "$installed_version" ] && fileedit_add_a_line_if_new "$installed_version" "$frompath/installed_version"
576 [ "x$origin_orig" = "x$origin" ] || fileedit_add_a_line_if_new "$origin_orig" "$frompath/initial_orig"
577 [ -e "${DBDIR}/initial/$origin_orig/SUPPRESSED_SELF" ] && touch "$frompath/SUPPRESSED_SELF"
578 [ -e "${DBDIR}/initial/$origin_orig/SUPPRESSED_PKGNG" ] && touch "$frompath/SUPPRESSED_PKGNG"
579 if ! grep -qFx "$origin" "${DBDIR}/done_required_ports_to_inspect" 2> /dev/null
581 fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
582 fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
583 dbpath=${DBDIR}/requires/$origin
584 dbpath_prev=${DBDIR}/prevset/requires/$origin
585 if [ ! -e "$dbpath/complete_as_node" ] || \
586 ! diff "$tmp_config.before" "$tmp_config.after" > /dev/null 2> /dev/null
588 # Notify reconfiguration of the port option
590 if [ -e "$dbpath/complete_as_node" ] || \
591 grep -q -Fx -e "$origin_orig" -e "$origin" "${DBDIR}/to_be_reconf" 2> /dev/null
593 message_echo "${DEPTH_INDEX} ===> Reconfigured"
599 [ -n "$conf_updated" ] && touch "$dbpath/conf_updated"
600 if [ -d "${DBDIR}/conf/each_port/$origin" ]
602 cp -R "${DBDIR}/conf/each_port/$origin/"* "$dbpath/" > /dev/null 2>&1 || :
604 # Escape of inspection conflict
605 database_build_escape_inspect_conflict "$origin"
606 # Check the change of the port option from the default
607 tmp_portsdb_work=${TMPDIR}/database_build_inspect_dependencies:portsdb_work
608 tmp_portopt=${TMPDIR}/database_build_inspect_dependencies:portopt
609 [ -d "$tmp_portsdb_work" ] || mkdir "$tmp_portsdb_work"
611 export PORT_DBDIR=$tmp_portsdb_work
613 if database_build_make "$origin" showconfig > $tmp_portopt
615 cp "$tmp_portopt" "$dbpath"/ports_options.default
617 cat "$tmp_portopt" >&2
618 message_echo 'Error in detecting the default options.' 2>&1
622 if [ `wc -c < $dbpath/ports_options.default` -gt 0 ]
624 if database_build_make "$origin" showconfig > $tmp_portopt
626 cp "$tmp_portopt" "$dbpath"/ports_options.current
628 cat "$tmp_portopt" >&2
629 message_echo 'Error in detecting the current options.' 2>&1
633 cp /dev/null "$dbpath/ports_options.current"
635 pkgsys_save_port_oprion_timestamp "$origin"
636 # Get the lists of requirements in the flavored form
637 database_build_create_pkgtag "$origin"
638 for variable in PKG_DEPENDS EXTRACT_DEPENDS PATCH_DEPENDS FETCH_DEPENDS BUILD_DEPENDS LIB_DEPENDS
640 database_build_make "$origin" -V $variable
641 done > ${TMPDIR}/database_build_inspect_dependencies:build_depends_list
642 for variable in LIB_DEPENDS RUN_DEPENDS
644 database_build_make "$origin" -V $variable
645 done > ${TMPDIR}/database_build_inspect_dependencies:run_depends_list
648 tr ' ' '\n' < ${TMPDIR}/database_build_inspect_dependencies:${tag}_depends_list | \
649 sed -E 's#.*:([^:/]+/[^:/]+|[^:/]+/[^:/]+:[^:/]*)$#\1#' | cut -d : -f 1 | sort -u | \
650 grep -Ev "`pkgsys_pkgtools_ports_filter_regexp`" \
651 | while read origin_flavor_incomplete
654 opt_apply_default_config=yes
655 database_build_determine_port_option "$origin_flavor_incomplete"
657 database_build_determine_flavored_origin "$origin_flavor_incomplete"
658 done | grep -v '^$' | sort -u > $dbpath/requirements.$tag.orig || :
659 sed -E -f "${DBDIR}/conf/REPLACE.sed_pattern" "$dbpath/requirements.$tag.orig" \
660 | grep -v '^$' | sort -u > $dbpath/requirements.$tag.src || :
662 for stage in orig src
664 sort -u "$dbpath/requirements.run.${stage}" "$dbpath/requirements.build.${stage}" \
665 > $dbpath/requirements.all.direct.${stage}
666 mv "$dbpath/requirements.build.${stage}" "$dbpath/requirements.build.direct.${stage}"
667 mv "$dbpath/requirements.run.${stage}" "$dbpath/requirements.run.direct.${stage}"
669 # Record the completion
670 touch "$dbpath/complete_as_node"
671 fileedit_rm_a_line "$origin_orig" "${DBDIR}/to_be_reconf"
672 fileedit_rm_a_line "$origin" "${DBDIR}/to_be_reconf"
673 # Restoration of escaped inspection conflict
674 database_build_restore_inspect_conflict "$origin"
676 # Restoration of escaped inspection conflict
677 database_build_restore_inspect_conflict "$origin"
678 # Reset the complied lists of requirements
679 for level in direct full
683 rm -f "$dbpath/requirements.${tag}.${level}"
686 for origin_tmp in "$origin" "$origin_orig"
688 for inspected_level_tmp in full direct node
690 fileedit_rm_a_line "$origin_tmp" "${DBDIR}/ports.inspected.${inspected_level_tmp}.list"
694 # Inspect the requirements
695 inspected_level=`database_build_get_inspected_level "$origin" "$origin_dependent"`
696 case $inspected_level in
698 grep -v -Fx -f "${DBDIR}/installed_ports" \
699 "$dbpath/requirements.all.direct.src" > ${TMPDIR}/missing.$origin_id || :
700 inspected_levels_compatible='full direct node'
703 grep -v -Fx -f "${DBDIR}/installed_ports" \
704 "$dbpath/requirements.all.direct.src" > ${TMPDIR}/missing.$origin_id || :
705 inspected_levels_compatible='direct node'
708 cp /dev/null "${TMPDIR}/missing.$origin_id"
709 inspected_levels_compatible='node'
712 rm -rf "$dbpath/rename_requirements.sed.pattern"
713 nlines=`wc -l < ${TMPDIR}/missing.$origin_id`
715 while [ $iline -le $nlines ]
717 origin_dependency=`sed -n ${iline}p "${TMPDIR}/missing.$origin_id"`
719 grep -q -Fx "$origin_dependency" "${DBDIR}/ports.inspected.list" 2> /dev/null && \
721 database_build_inspect_dependencies "$origin_dependency" "$origin"
723 if [ -e "$dbpath/rename_requirements.sed.pattern" ]
725 for tag in run build all
727 sed -E -i .unrenamed -f "$dbpath/rename_requirements.sed.pattern" "$dbpath/requirements.${tag}.direct.src"
730 rm -f "${TMPDIR}/missing.$origin_id"
731 # Inspect the distfiles
732 dist_subdir_rpl=`database_query_get_makevar_val "$origin" DIST_SUBDIR | str_escape_replaceval_filter` || :
733 [ -n "$dist_subdir_rpl" ] && dist_subdir_rpl="$dist_subdir_rpl\/"
734 database_build_make "$origin" fetch-urlall-list \
735 | sed -E "s/.*\/([^\/]+)$/$dist_subdir_rpl\1/" \
736 | sort -u | fileedit_add_lines_if_new "${DBDIR}/distfiles.inspected"
737 # Transfer data from the previous database if existent, successful and no change
738 pkg_new=`cat "$dbpath/new_version"`
739 if [ ! -e "$dbpath/conf_updated" -a -d "$dbpath_prev" ] && pkg_info_e "$pkg_new" 2> /dev/null && \
740 ! grep -qFx "$origin" "$dbpath_prev/to_be_reconf" 2> /dev/null
743 for dbfile in new_version CONFLICT.conf BUILDCONFLICT.conf MARG.conf MENV.conf \
744 ports_options.default ports_options.current \
745 rename_requirements.sed.pattern \
746 requirements.run.direct.orig requirements.run.direct.src \
747 requirements.build.direct.orig requirements.build.direct.src
749 [ ! -e "$dbpath/$dbfile" -a ! -e "$dbpath_prev/$dbfile" ] && continue
750 if ! diff "$dbpath/$dbfile" "$dbpath_prev/$dbfile" 2> /dev/null > /dev/null
756 if [ $same_as_prevset = yes ]
758 nlines=`wc -l < $dbpath/requirements.all.direct.src`
760 while [ $iline -le $nlines ]
762 origin_dependency=`sed -n ${iline}p "$dbpath/requirements.all.direct.src"`
764 if [ ! -e "${DBDIR}/requires/$origin_dependency/same_as_prevset" ]
771 if [ $same_as_prevset = yes ]
773 for dbfile in failed.list damaged_package manually_done.list
775 if grep -qFx "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null
782 if [ $same_as_prevset = yes ]
785 cp -Rp "$dbpath_prev" "$dbpath"
786 if [ -d "${DBDIR}/prevset/notes/$origin" ]
788 rm -rf "${DBDIR}/notes/$origin"
789 mkdir -p "${DBDIR}/notes"
790 cp -Rp "${DBDIR}/prevset/notes/$origin" "${DBDIR}/notes/$origin"
793 for tag in all run build none
795 for level in full direct
797 echo "success.$tag.$level.list"
800 } | while read dbfile
802 if grep -Fxq "$origin" "${DBDIR}/prevset/$dbfile" 2> /dev/null
804 fileedit_add_a_line_if_new "$origin" "${DBDIR}/$dbfile"
807 touch "$dbpath/same_as_prevset"
808 message_echo "${DEPTH_INDEX} ===> No update from the previous reinstallation. Progress status inherited."
811 # Record the completion
812 if [ "x$origin_orig" != "x$origin" ]
814 for inspected_level_tmp in $inspected_levels_compatible
816 fileedit_add_a_line_if_new "$origin" "${DBDIR}/ports.inspected.${inspected_level_tmp}.list"
818 fileedit_add_a_line_if_new "$origin" "${DBDIR}/ports.inspected.list"
819 fileedit_add_a_line_if_new "$origin" "${DBDIR}/inspected_ports.update"
820 fileedit_rm_a_line "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
822 fileedit_add_a_line_if_new "$origin" "${DBDIR}/done_required_ports_to_inspect"
824 message_echo "${DEPTH_INDEX} ===> Already inspected merged port"
825 fileedit_rm_a_line "$origin_orig" "${DBDIR}/to_be_reconf"
826 for inspected_level_tmp in full direct node
828 fileedit_rm_a_line "$origin_orig" "${DBDIR}/ports.inspected.${inspected_level_tmp}.list"
832 # Record the completion
833 for inspected_level_tmp in $inspected_levels_compatible
835 fileedit_add_a_line_if_new "$origin_orig" "${DBDIR}/ports.inspected.${inspected_level_tmp}.list"
837 fileedit_add_a_line_if_new "$origin_orig" "${DBDIR}/ports.inspected.list"
838 fileedit_add_a_line_if_new "$origin_orig" "${DBDIR}/inspected_ports.update"
839 fileedit_rm_a_line "$origin_orig" "${DBDIR}/stage.loop_list/ports_to_inspect.remain"
840 message_echo "${DEPTH_INDEX} ===> ok"
841 DEPTH_INDEX=${DEPTH_INDEX_orig}
843 if [ -n "$origin_dependent" -a "x$origin_orig" != "x$origin" ]
845 origin_orig_regexp=`str_escape_regexp "$origin_orig"`
846 origin_replace=`str_escape_replaceval "$origin"`
847 fileedit_add_a_line_if_new "s/^$origin_orig_regexp$/$origin_replace/" "${DBDIR}/requires/$origin_dependent/rename_requirements.sed.pattern"
851 # ============= Filter ignored dependencies from a list given by the standard input =============
852 database_build_filter_ignored_requirements ()
856 pattern=${DBDIR}/requires/$origin/ignored_requirements.filter
859 grep -Fxvq -f "$pattern"
865 # ============= Build and get a list of the complete recursive dependencies of a port =============
866 database_build_get_complete_recursive_dependency ()
868 local tag origin suffix tmppath dbpath srcfile dstfile num_parents loophead dstfile_tmp tmpdstpath index_loop loop_len origin_target origin_ref dbpath_target
872 tmppath=${TMPDIR}/database_build_get_complete_recursive_dependency
873 dbpath=${DBDIR}/requires/$origin
874 srcfile=$dbpath/requirements.${tag}.direct${suffix}
875 dstfile=$dbpath/requirements.${tag}.full${suffix}
876 if [ ! -e "$srcfile" ]
878 [ -d "$dbpath" ] && rm -f "$dstfile"
881 if [ ! -e "$dstfile" ]
883 touch "$tmppath.parents"
884 num_parents=`wc -l < $tmppath.parents`
885 if grep -Fxq "$origin" "$tmppath.parents"
887 loophead=`grep -Fxn "$origin" "$tmppath.parents" | tail -n 1 | cut -d : -f 1`
888 if [ "x$opt_force_continuation_for_looped_dependency" = xno ]
890 message_echo "ERROR: The following loop was found for requirements.${tag}${suffix}:" >&2
892 message_echo "WARNING: The following loop was found for requirements.${tag}${suffix}:" >&2
894 message_echo " $origin" >&2
895 ports_in_loop=`sed -n $(($loophead+1)),\$p "$tmppath.parents"`
896 echo "$ports_in_loop" | sed 's/^/ -->/' | message_cat >&2
897 message_echo " -->$origin" >&2
898 if [ "x$opt_disallow_force_continuation_for_looped_dependency" = xyes ]
900 message_echo 'Resolve the problem manually and then retry by executing' >&2
901 message_echo " ${APPNAME} reset keepopts" >&2
902 message_echo " ${APPNAME}" >&2
905 message_echo 'Exploring a node port to terminate the loop by evaluating only build-and-run-time dependencies as essential ones.' >&2
906 echo "$origin" > $tmppath.ports_in_loop
907 echo "$ports_in_loop" >> $tmppath.ports_in_loop
908 echo "$origin" >> $tmppath.ports_in_loop
910 loop_len=`wc -l < $tmppath.ports_in_loop`
911 while [ $index_loop -lt $loop_len ]
913 origin_target=`sed -n ${index_loop}p "$tmppath.ports_in_loop"`
914 origin_ref=`sed -n $((${index_loop}+1))p "$tmppath.ports_in_loop"`
915 dbpath_target=${DBDIR}/requires/$origin_target
916 if ! grep -Fxq "$origin_ref" "$dbpath_target/requirements.run.direct${suffix}" 2> /dev/null || \
917 ! grep -Fxq "$origin_ref" "$dbpath_target/requirements.build.direct${suffix}" 2> /dev/null
919 message_echo 'INFO: The dependency of '$origin_target' on '$origin_ref' is ignored to terminate the loop.' >&2
922 index_loop=$((${index_loop}+1))
924 if [ $index_loop -eq $loop_len ]
926 message_echo 'WARNING: The loop cannot be resolved. Continuing by forcible ignorance of the dependency of '$origin_target' on '$origin_ref'. This may cause confusion in the later processes.' >&2
928 for suffix_tmp in '' .orig
930 for tag_tmp in run build
932 grep -Fxq "$origin_ref" "$dbpath_target/requirements.${tag_tmp}.direct${suffix_tmp}" 2> /dev/null && \
933 fileedit_add_a_line_if_new "$origin_ref" "$dbpath_target/ignored_requirements.${tag_tmp}${suffix_tmp}"
935 cat "$dbpath_target/ignored_requirements.run${suffix_tmp}" "$dbpath_target/ignored_requirements.build${suffix_tmp}" 2> /dev/null | sort -u > $dbpath_target/ignored_requirements.all${suffix_tmp}
937 cat "$dbpath_target/ignored_requirements.all"* 2> /dev/null | sort -u > $dbpath_target/ignored_requirements.filter
940 echo "$origin" >> $tmppath.parents
941 tmpdstpath=${TMPDIR}/requires/$origin
942 dstfile_tmp=$tmpdstpath/requirements.${tag}.full${suffix}
943 mkdir -p "$tmpdstpath"
944 database_build_filter_ignored_requirements "$origin" < $srcfile | while read origin_requirement
946 # The least requirements of build are the direct build-time requirements and the full run-time requirements of the direct build-time requirements.
948 [ "x$tag" = xbuild ] && tag_dep=run
949 recursive_dependency=`database_build_get_complete_recursive_dependency "$tag_dep" "$origin_requirement" "$suffix"`
950 [ -e "$dbpath/ignored_requirements.filter" ] && \
951 echo "$origin_requirement" | grep -Fxq -f "$dbpath/ignored_requirements.filter" 2> /dev/null && \
953 echo "$origin_requirement"
954 echo "$recursive_dependency"
956 sed -n ${num_parents}p "$tmppath.parents" > $tmppath.parents.tmp
957 mv "$tmppath.parents.tmp" "$tmppath.parents"
958 if [ ! -e "$dstfile" ]
960 sort -u "$dstfile_tmp" | grep -v '^$' > $dstfile || :
967 # ============= Inspect the necessity of requirements of a necessary port even in case of skipping unchanged ports =============
968 # Here the "necessity" means that a port must be kept installed, newly installed or reinstalled for run- or build-time operations.
969 # In other words, "unnecessary" ports are what are not yet installed and not required by any "necessary" ports neither in run- or build-time.
970 database_build_inspect_necessity_for_only_new_upgrade ()
972 local origin level dbpath tmpfile
975 dbpath=${DBDIR}/requires/$origin
976 [ ! -d "$dbpath" -o -e "$dbpath/necessary_port.${level}" ] && return
977 tmpfile=${TMPDIR}/database_build_inspect_necessity_for_only_new_upgrade:`echo "$origin" | tr / :`
978 if database_query_does_a_port_need_update "$origin"
980 sort -u "$dbpath/requirements.build.direct" "$dbpath/requirements.run.${level}" || :
982 cat "$dbpath/requirements.run.${level}" || :
983 fi 2> /dev/null | database_build_filter_ignored_requirements "$origin" > $tmpfile
984 while read origin_requirement
986 database_build_inspect_necessity_for_only_new_upgrade "$origin_requirement" "$level"
989 touch "$dbpath/necessary_port.${level}"
992 # ============= Build complement relations to new dependents for targets recursively =============
993 database_build_complement_to_new_dependents_for_targets ()
995 local origin dbdir reqdir level
997 dbdir=${DBDIR}/targets/$origin
998 reqdir=${DBDIR}/requires/$origin
999 [ -d "$dbdir" ] || return 0
1000 echo "$origin" >> ${DBDIR}/stage.loop_list/parse_target_attr_info
1001 if [ -e "$dbdir/target_itself" ] && database_query_does_a_port_need_update "$origin"
1003 for level in direct full
1005 cat "$reqdir/requirements.all.${level}" 2> /dev/null | \
1006 database_build_filter_ignored_requirements "$origin" | \
1007 while read origin_requirement
1009 fileedit_add_a_line_if_new "$origin" \
1010 "${DBDIR}/targets/$origin_requirement/complement_for_new_dependents.${level}"
1013 cat "$reqdir/requirements.all.direct" "$reqdir/requirements.all.full" 2> /dev/null | \
1014 sort -u | database_build_filter_ignored_requirements "$origin" | \
1015 while read origin_requirement
1017 database_build_complement_to_new_dependents_for_targets "$origin_requirement"
1022 # ============= Recursively complete necessary upgrades for build =============
1023 database_build_complete_necessary_upgrades_for_build ()
1025 local origin level dbpath origin_requirement dbpath_requirement
1028 dbpath=${DBDIR}/requires/$origin
1029 [ -e "$dbpath/requirements.build.${level}" ] || return 0
1030 while read origin_requirement
1032 dbpath_requirement=${DBDIR}/requires/$origin_requirement
1033 [ -e "$dbpath_requirement/necessary_upgrade.build.${level}" ] || continue
1034 [ `cat "${DBDIR}/moved_from/$origin_requirement/current_version" 2> /dev/null | wc -l` -eq 0 ] || continue
1035 touch "$dbpath_requirement/necessary_upgrade.run.${level}"
1036 database_build_complete_necessary_upgrades_for_build "$origin_requirement" "$level"
1037 done < $dbpath/requirements.build.${level}
1041 # ============= Build target attribute files recursively =============
1042 database_build_target_attributes ()
1044 local origin dbdir reqdir _is_target _is_requires_requirements _is_initial_requirements _is_requires_dependents _is_initial_dependents _is_requires_requirements_complement _is_relevant tag level database table
1046 dbdir=${DBDIR}/targets/$origin
1047 reqdir=${DBDIR}/requires/$origin
1048 [ -d "$dbdir" ] || return 0
1049 [ -e "$dbdir/COMPLETE_ATTRS" ] && return
1051 [ -e "$dbdir/target_itself" ] && _is_target=y
1052 for tag in all run build none
1054 for level in direct full
1056 _is_relevant=${_is_target}
1057 _is_requires_requirements=
1058 _is_initial_requirements=
1059 _is_requires_dependents=
1060 _is_initial_dependents=
1061 _is_requires_requirements_complement=
1062 for database in requires initial
1064 for table in requirements dependents
1066 if [ -e "$dbdir/target_${database}_${table}.${tag}.${level}" ]
1068 eval _is_${database}_${table}=y
1073 if [ -z "${_is_requires_requirements}" -a -e "$dbdir/complement_for_new_dependents.${level}" ]
1075 _is_requires_requirements_complement=y
1078 [ -n "${_is_relevant}" ] && cat > $dbdir/attrs.${tag}.${level} << eof
1079 _is_target=${_is_target}
1080 _is_requires_requirements=${_is_requires_requirements}
1081 _is_initial_requirements=${_is_initial_requirements}
1082 _is_requires_dependents=${_is_requires_dependents}
1083 _is_initial_dependents=${_is_initial_dependents}
1084 _is_requires_requirements_complement=${_is_requires_requirements_complement}
1088 touch "$dbdir/COMPLETE_ATTRS"
1091 # ============= Order the ports considering dependencies =============
1092 database_build_order_ports_considering_dependencies ()
1094 touch "${DBDIR}/reinst_order.list.tmp"
1095 (cd "${DBDIR}/requires" && \
1096 find . -depth 3 -name requirements.all.full -exec echo {} \; -exec cat {} \; -exec echo \;) | \
1097 env "DBDIR=${DBDIR}" awk -f "${LIBEXECDIR}"/order_dependencies.awk || return
1098 grep -v '^$' "${DBDIR}/reinst_order.list.tmp" > "${DBDIR}/reinst_order.list" || :
1101 # ============= [Sub-function] Common operations for resetting configurations for a port =============
1102 _database_build_reset_a_port_confdb ()
1104 local origin origin_replace db
1106 [ -d "${DBDIR}/initial/$origin" -o -d "${DBDIR}/replace/$origin" \
1107 -o -d "${DBDIR}/requires/$origin" -o -d "${DBDIR}/targets/$origin" ] || return 0
1108 touch "${DBDIR}/inspected_ports_only_partially"
1111 cat "${DBDIR}/replace/$origin/origin" 2> /dev/null || :
1112 for dbtag in initial requires
1114 for tabel in requirements dependents
1116 cat "${DBDIR}/$dbtag/$origin/$tabel.all.full" 2> /dev/null || :
1117 cat "${DBDIR}/$dbtag/$origin/$tabel.all.full.orig" 2> /dev/null || :
1118 rm -rf "${DBDIR}/$dbtag/$origin/$tabel.run.full" \
1119 "${DBDIR}/$dbtag/$origin/$tabel.build.full"
1121 rm -rf "${DBDIR}/$dbtag/$origin/is_customized"
1123 } | sort -u >> ${DBDIR}/inspected_ports.update
1124 for level in full direct node
1126 fileedit_rm_a_line "$origin" "${DBDIR}/ports.inspected.${level}.list"
1128 fileedit_rm_a_line "$origin" "${DBDIR}/obsolete_ports"
1129 fileedit_rm_a_line "$origin" "${DBDIR}/moved_ports"
1130 fileedit_rm_a_line "$origin" "${DBDIR}/ports.inspected.list"
1131 cat "${DBDIR}/replace/$origin/origin" 2> /dev/null || :
1134 # ============= Clear database directories for a flavored origin =============
1135 database_build_clear_db_dirs ()
1139 for db in requires replace targets obsolete
1141 rm -rf "${DBDIR}/$db/$origin"
1145 # ============= Remove configurations for a port permanently =============
1146 database_build_forget ()
1148 local origin origin_replace
1150 origin_replace=`_database_build_reset_a_port_confdb "$origin"`
1151 fileedit_rm_a_line "$origin" "${DBDIR}/targets_specified_so_far"
1152 [ -z "$origin_replace" ] || database_build_forget "$origin_replace"
1153 database_build_clear_db_dirs "$origin"
1156 # ============= Overlay onto the temporary database so as to re-inspect and reinstall ports whose configurations were changed =============
1157 database_build_patch_reconf ()
1159 local origin origin_replace
1161 origin_replace=`_database_build_reset_a_port_confdb "$origin"`
1162 [ -d "${DBDIR}/initial/$origin" -o -d "${DBDIR}/requires/$origin" ] && \
1163 fileedit_add_a_line_if_new "$origin" "${DBDIR}/stage.loop_list/ports_to_inspect"
1164 fileedit_add_a_line_if_new "$origin" "${DBDIR}/to_be_reconf"
1165 fileedit_rm_a_line "$origin" "${DBDIR}/done_required_ports_to_inspect"
1166 [ -z "$origin_replace" ] || database_build_patch_reconf "$origin_replace"
1167 database_build_clear_db_dirs "$origin"
1170 # ============= Post-processes after finishing to inspect initial dependencies =============
1171 database_build_post_inspect_initial_dependencies ()
1173 find "${DBDIR}/initial" -depth 2 -type d \
1174 | sed -E 's|.*/([^/]+/[^/]+)$|\1|' > ${DBDIR}/inspected_ports.initial
1177 # ============= Post-processes after finishing to inspect dependencies =============
1178 database_build_post_inspect_dependencies ()
1181 tmpfile=${TMPDIR}/database_build_post_inspect_dependencies
1182 touch "${DBDIR}/obsolete_ports" "${DBDIR}/inspected_ports.update"
1183 find "${DBDIR}/requires" -depth 2 -type d \
1184 | sed -E 's|.*/([^/]+/[^/]+)$|\1|' > ${DBDIR}/inspected_ports
1185 sort -u "${DBDIR}/inspected_ports" "${DBDIR}/inspected_ports.initial" > ${DBDIR}/inspected_ports.all
1187 cat "${DBDIR}/conf/HOLD:PORTS.parsed" || :
1188 cat "${DBDIR}/need.list" || :
1189 } 2> /dev/null | sort -u > $tmpfile.obsolete_ports.exclude
1190 grep -v -Fx -f "$tmpfile.obsolete_ports.exclude" "${DBDIR}/obsolete_ports" > ${DBDIR}/obsolete_ports.can_be_deleted || :
1191 cp /dev/null "${DBDIR}/REPLACE.complete_sed_pattern.tmp"
1192 find "${DBDIR}/replace" -depth 3 -type f -name origin | while read nodepath
1194 origin_orig=`expr "$nodepath" : '.*/\([^/][^/]*/[^/][^/]*\)/origin$'`
1195 origin=`cat "$nodepath"`
1196 origin_orig_regexp=`str_escape_regexp "$origin_orig"`
1197 origin_esc=`str_escape_replaceval "$origin"`
1198 echo "s/^$origin_orig_regexp$/$origin_esc/" >> ${DBDIR}/REPLACE.complete_sed_pattern.tmp
1200 mv "${DBDIR}/REPLACE.complete_sed_pattern.tmp" "${DBDIR}/REPLACE.complete_sed_pattern"
1201 if [ `cat "${DBDIR}/inspected_ports.update" 2> /dev/null | wc -l` -gt 0 ]
1203 grep -Fx -f "${DBDIR}/inspected_ports.all" "${DBDIR}/inspected_ports.update" \
1204 > ${DBDIR}/inspected_ports.update.tmp 2> /dev/null || :
1205 mv "${DBDIR}/inspected_ports.update.tmp" "${DBDIR}/inspected_ports.update"
1206 if [ $opt_only_target_scope = yes ]
1208 touch "${DBDIR}/inspected_ports_only_partially"
1210 rm -f "${DBDIR}/inspected_ports_only_partially"
1212 if program_chk_stage_loop_complete CONVERT_REQUIREMENTS_LIST
1214 mv "${DBDIR}/inspected_ports.update" "${DBDIR}/stage.loop_list/convert_dependency_lists"
1216 cat "${DBDIR}/inspected_ports.update" "${DBDIR}/stage.loop_list/convert_dependency_lists" \
1217 2> /dev/null | sort -u > ${DBDIR}/stage.loop_list/convert_dependency_lists.tmp
1218 mv "${DBDIR}/stage.loop_list/convert_dependency_lists.tmp" \
1219 "${DBDIR}/stage.loop_list/convert_dependency_lists"
1220 rm -f "${DBDIR}/inspected_ports.update"
1223 program_chk_stage_loop_complete CONVERT_REQUIREMENTS_LIST \
1224 && rm -f "${DBDIR}/stage.loop_list/convert_dependency_lists"
1227 sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "${DBDIR}/need.list" || :
1228 cat "${DBDIR}/need.list" || :
1229 } 2> /dev/null | sort -u > ${DBDIR}/need.with_replaced.list
1230 for table in requirements dependents itself
1232 [ -e "${DBDIR}/stage.loop_list/target_$table.specified" ] || continue
1233 sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" \
1234 "${DBDIR}/stage.loop_list/target_$table.specified" \
1235 > ${DBDIR}/stage.loop_list/target_$table.replaced.specified
1237 cp /dev/null "${DBDIR}/update_dependencies"