2 # ==============================================================================
3 # portsreinstall library script
4 # - Operations for queries to the temporary database -
5 # Copyright (C) 2013-2022 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
6 # This software is distributed under the 2-Clause BSD License.
7 # ==============================================================================
9 # ============= Show a list of failed ports with their reasons =============
10 database_query_show_list_failure ()
13 tmp_valid=${TMPDIR}/database_query_show_list_failure:valid
14 if [ `cat "${DBDIR}/failed.list" 2> /dev/null | wc -l` -eq 0 ]
16 message_echo "INFO: No item is registered in this list."
19 env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern" "${DBDIR}/failed.list" 2> /dev/null \
22 env LANG=C grep -q -Fx "$origin" "${DBDIR}/stage.loop_list/ports_to_delete" 2> /dev/null \
25 if [ `cat "$tmp_valid" 2> /dev/null | wc -l` -eq 0 ]
27 message_echo "INFO: No valid item is registered in this list."
32 note=`cat "${DBDIR}/notes/$origin/note_failtre" 2> /dev/null || :`
34 env LANG=C grep -q -Fx "$origin" "${DBDIR}/manually_done.list" 2> /dev/null && resolved=yes
35 pkgtag=`cat "${DBDIR}/moved_from/$origin/pkgtag" 2> /dev/null || :`
36 if [ $opt_batch_mode = no ]
40 yes ) resolved=', resolved';;
44 detail="while [$note]"
46 detail="by unrecorded reasons"
50 echo "$origin ($pkgtag) (error $detail$resolved)"
52 echo "$origin (error $detail$resolved)"
55 printf "%s\t%s\t%s\t%s\n" "$origin" "$pkgtag" "$note" "$resolved"
61 # ============= Show a list of failed restoration of conflict =============
62 database_query_show_list_failed_conflicts_restoration ()
64 if [ `cat "${DBDIR}/deleted_conflicts" 2> /dev/null | wc -l` -eq 0 ]
66 message_echo "INFO: No item is registered in this list."
69 env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" \
70 | while read origin pkg
72 pkg_regexp=`str_escape_regexp "$pkg"`
73 against=`env LANG=C grep -E "^$pkg_regexp:" "${DBDIR}/forbidden_conflicts" 2> /dev/null | cut -d : -f 2,3 | sort -u`
74 if [ $opt_batch_mode = no ]
78 echo -n "$origin ($pkg)"
85 against=`echo "$against" | sed 's/:/(/;s/$/)/' | tr '\n' ' '`
86 str_linearize_list_and "$against"
91 against=`echo "$against" | tr '\n' '|' | sed 's/,$//'`
92 printf '%s\t%s\t%s\n' "$origin" "$pkg" "$against"
98 # ============= Show installed ports which have been neither upgraded or reinstalled from the initial state =============
99 database_query_show_list_fossil ()
101 local srclist origin pkg
102 srclist=`ls "${DBDIR}"/fossil_pkgs/fossil_since_* | head -n 1`
103 [ -e "$srclist" ] || return 0
106 pkg=`pkgsys_get_init_pkg_from_orig "$origin"`
107 pkg_info_e "$pkg" || continue
108 printf '%s\t%s\n' "$origin" "$pkg"
112 # ============= Insert initial flavored origins to a list of flavored origins =============
113 database_query_add_initial_origins ()
119 [ -e "${DBDIR}/moved_from/$origin/initial_orig" ] || continue
120 cat "${DBDIR}/moved_from/$origin/initial_orig"
125 # ============= Get target attributes =============
126 database_query_get_target_attributes ()
128 local prefix origin _is_all _is_target _is_requires_requirements _is_initial_requirements _is_requires_dependents _is_initial_dependents _is_requires_requirements_complement _is_relevant infofile tag level
133 _is_requires_requirements=
134 _is_initial_requirements=
135 _is_requires_dependents=
136 _is_initial_dependents=
137 _is_requires_requirements_complement=
139 if [ ! -e "${DBDIR}/target_all" -a -n "$opt_target_itself$opt_target_dependents$opt_target_requirements" ]
142 tag=`options_get_dependency_type`
144 [ $opt_only_target_scope = yes ] && level=direct
145 infofile=${DBDIR}/targets/$origin/attrs.${tag}.${level}
146 if [ -e "$infofile" ]
153 eval ${prefix}_is_all=\$\{_is_all\}
154 eval ${prefix}_is_target=\$\{_is_target\}
155 eval ${prefix}_is_requires_requirements=\$\{_is_requires_requirements\}
156 eval ${prefix}_is_initial_requirements=\$\{_is_initial_requirements\}
157 eval ${prefix}_is_requires_dependents=\$\{_is_requires_dependents\}
158 eval ${prefix}_is_initial_dependents=\$\{_is_initial_dependents\}
159 eval ${prefix}_is_requires_requirements_complement=\$\{_is_requires_requirements_complement\}
160 eval ${prefix}_is_relevant=\$\{_is_relevant\}
163 # ============= Check whether (re/de)installation of a port is suppressed =============
164 database_query_is_a_port_suppressed ()
166 local origin flags flag
169 [ $opt_suppress_self_upadte = yes ] && flags=SUPPRESSED_SELF
170 [ $opt_suppress_pkgtools_upadte = yes ] && flags="$flags SUPPRESSED_PKGNG"
173 for db in initial moved_from
175 [ -e "${DBDIR}/$db/$origin/$flag" ] && return
181 # ============= Check whether a port needs to be updated or upgraded =============
182 database_query_does_a_port_need_update ()
184 local origin dbpath frompath new_version current_version
186 dbpath=${DBDIR}/requires/$origin
187 frompath=${DBDIR}/moved_from/$origin
188 [ -e "$dbpath/conf_updated" ] && return
189 [ -e "$dbpath/new_version" ] || return
190 new_version=`cat "$dbpath/new_version"`
191 current_version=`cat "$frompath/current_version"`
192 [ "x$current_version" != "x$new_version" ]
195 # ============= Check before operations of a command which need the temporary database completely prepared =============
196 database_query_chk_preparation_completion ()
198 program_chk_stage_complete PREPARATION && return
199 message_echo "ERROR: Database has to be built completely before executing this command." >&2
203 # ============= Get a make variable value of a port =============
204 database_query_get_makevar_val ()
206 local origin variable dbdir cache value
209 dbdir=${DBDIR}/requires/$origin
210 cache=$dbdir/makevar/$variable
215 value=`database_build_make "$origin" -V "$variable"`
216 if [ -d "$dbdir" ] && misc_is_superuser_privilege
218 [ -d "$dbdir/makevar" ] || mkdir "$dbdir/makevar"
219 echo "$value" > $cache.tmp
220 mv "$cache.tmp" "$cache"
226 # ============= Get a configured value of a port =============
227 database_query_get_config_val ()
229 local origin variable dbdir cache value
232 dbfile=${DBDIR}/conf/each_port/$origin/$variable.conf
233 cat "$dbfile" 2> /dev/null || :
236 # ============= Check whether configurations for a port is default =============
237 database_query_is_default_conf ()
239 local origin mode dbpath tmp_msg is_customized is_requiremnt_replaced files tmp_old tmp_new origin_requirement tmp_msg_customized
242 dbpath=${DBDIR}/requires/$origin
243 if [ ! -e "$dbpath/is_customized" ]
245 tmp_msg=${TMPDIR}/database_query_is_default_conf:msg
246 cp /dev/null "$tmp_msg"
248 if [ `ls "${DBDIR}/conf/each_port/$origin" 2> /dev/null | wc -l` -gt 0 ]
250 files=`ls "${DBDIR}/conf/each_port/$origin" | sed -E 's/^([^.]+).*/\1/' | str_concat_items_for_sentence`
251 echo "Knobs and miscellaneous customization by $files," >> $tmp_msg
254 if ! diff -q "$dbpath/ports_options.default" "$dbpath/ports_options.current" > /dev/null 2>&1
256 echo "Non-default port options," >> $tmp_msg
259 if env LANG=C grep -q -Fx "$origin" "${DBDIR}/conf/NOPKG:PORTS.parsed" 2> /dev/null
261 echo "Explicit specification as non-default in ${APPNAME}.conf," >> $tmp_msg
264 tmp_old=${TMPDIR}/database_query_is_default_conf:old
265 tmp_new=${TMPDIR}/database_query_is_default_conf:new
266 is_requiremnt_replaced=no
267 if fileedit_manipulate_old_new_lines "$dbpath/requirements.all.direct.orig" "$dbpath/requirements.all.direct" \
268 "$tmp_old" "$tmp_new"
270 echo "Replacement in requirements:" >> $tmp_msg
271 echo "-------- FROM --------" >> $tmp_msg
272 sed 's/^/ /' "$tmp_old" >> $tmp_msg
273 echo "-------- TO --------" >> $tmp_msg
274 sed 's/^/ /' "$tmp_new" >> $tmp_msg
275 echo "----------------------" >> $tmp_msg
278 for origin_requirement in `cat "$dbpath/requirements.all.direct" 2> /dev/null`
280 database_query_is_default_conf "$origin_requirement" quiet && continue
281 echo "Non-default requirement $origin_requirement," >> $tmp_msg
284 { [ $is_customized = yes ] && cat "$tmp_msg"; } > $dbpath/is_customized.tmp
285 mv "$dbpath/is_customized.tmp" "$dbpath/is_customized"
287 [ `wc -c < $dbpath/is_customized` -eq 0 ] && return
288 if [ "x$mode" != xquiet ]
290 tmp_msg_customized=${TMPDIR}/database_query_is_default_conf:msg_customized
291 message_echo "INFO: This port is configured to be non-default because of"
292 sed 's/^/ /' "$dbpath/is_customized" > $tmp_msg_customized
293 message_cat "$tmp_msg_customized"
294 message_echo " so the prebuilt package is not used."
299 # ============= Output of lists in which each matching port is registered =============
300 database_query_show_list_inclusion_of_matching_port ()
302 local grandtitle lists pkgnamedb deptag level isfirst origin_target pkg_target table_target
309 message_echo "[$grandtitle]"
310 message_dependency_scope "$deptag" "$level"
313 for origin_target in `pkgsys_eval_ports_glob "$@"`
316 for table_target in $pkgnamedb
318 pkg_target=`cat "${DBDIR}/$table_target/$origin_target/pkgtag" 2> /dev/null` || :
319 [ -n "$pkg_target" ] && break
321 [ -n "$pkg_target" ] || continue
324 for subject in `echo "$lists" | tr \| ' '`
326 database_query_exists_in_list "$origin_target" "$subject" "$deptag" "$level" \
327 && match="$match $subject"
329 if [ $opt_batch_mode = no ]
331 echo -n "$origin_target ($pkg_target): "
332 echo "$match" | sed 's/^ *//;s/ /, /g'
334 printf '%s\t%s\t' "$origin_target" "$pkg_target"
335 echo "$match" | sed 's/^ *//;s/ /,/g'
338 if [ "$isfirst" = y ]
340 message_echo "ERROR: No inspected port matches the glob(s)." >&2
346 # ============= Output of "show" command for port lists =============
347 database_query_show_port_lists ()
349 local grandtitle title list listdb pkgnamedb deptag level isfirst origin_target pkg_target table_target list_target
358 message_echo "[$grandtitle]"
359 message_dependency_scope "$deptag" "$level"
362 for origin_target in `pkgsys_eval_ports_glob "$@"`
365 for table_target in $pkgnamedb
367 pkg_target=`cat "${DBDIR}/$table_target/$origin_target/pkgtag" 2> /dev/null` || :
368 [ -n "$pkg_target" ] && break
370 [ -n "$pkg_target" ] || continue
371 [ "$isfirst" = y ] || message_echo
373 [ $opt_batch_mode = no ] && printf "$title\n" "$origin_target ($pkg_target)"
375 for table_target in $listdb
377 list_target=${DBDIR}/$table_target/$origin_target/$list
378 [ -e "$list_target" ] && break
380 [ -e "$list_target" ] || continue
381 if [ $opt_batch_mode = no ]
386 for table in $pkgnamedb
388 pkg=`cat "${DBDIR}/$table/$origin/pkgtag" 2> /dev/null` || :
389 [ -n "$pkg" ] && break
391 [ -n "$pkg" ] || continue
392 echo "$origin ($pkg)"
398 for table in $pkgnamedb
400 pkg=`cat "${DBDIR}/$table/$origin/pkgtag" 2> /dev/null` || :
401 [ -n "$pkg" ] && break
403 [ -n "$pkg" ] || continue
404 printf '%s\t%s\t%s\t%s\n' "$origin_target" "$pkg_target" "$origin" "$pkg"
408 if [ "$isfirst" = y ]
410 message_echo "ERROR: No inspected port matches the glob(s)." >&2
416 # ============= Output of "show" command for log files =============
417 database_query_show_log ()
419 local grandtitle title list listdb pkgnamedb isfirst origin_target pkg_target table_target list_target
426 message_echo "[$grandtitle]"
429 for origin_target in `pkgsys_eval_ports_glob "$@"`
432 for table_target in $pkgnamedb
434 pkg_target=`cat "${DBDIR}/$table_target/$origin_target/pkgtag" 2> /dev/null` || :
435 [ -n "$pkg_target" ] && break
437 [ -n "$pkg_target" ] || continue
438 [ "$isfirst" = y ] || message_echo
440 [ $opt_batch_mode = no ] && printf "$title\n" "$origin_target ($pkg_target)"
442 for table_target in $listdb
444 list_target=${DBDIR}/$table_target/$origin_target/$list
445 [ -e "$list_target" ] && break
447 [ -e "$list_target" ] || continue
451 if [ "$isfirst" = y ]
453 message_echo "ERROR: No inspected port matches the glob(s)." >&2
459 # ============= Output of "show" command for two column lists =============
460 database_query_show_two_column_lists ()
462 local grandtitle title list listdb pkgnamedb isfirst origin_target pkg_target table_target list_target
469 message_echo "[$grandtitle]"
472 for origin_target in `pkgsys_eval_ports_glob "$@"`
475 for table_target in $pkgnamedb
477 pkg_target=`cat "${DBDIR}/$table_target/$origin_target/pkgtag" 2> /dev/null` || :
478 [ -n "$pkg_target" ] && break
480 [ -n "$pkg_target" ] || continue
481 [ "$isfirst" = y ] || message_echo
483 [ $opt_batch_mode = no ] && printf "$title\n" "$origin_target ($pkg_target)"
485 for table_target in $listdb
487 list_target=${DBDIR}/$table_target/$origin_target/$list
488 [ -e "$list_target" ] && break
490 [ -e "$list_target" ] || continue
491 if [ $opt_batch_mode = no ]
493 sed 's/[[:space:]]/: /' < $list_target
498 if [ "$isfirst" = y ]
500 message_echo "ERROR: No inspected port matches the glob(s)." >&2
506 # ============= Output of "show" command for a single list =============
507 database_query_show_single_list ()
509 local list pkgnamedb flag_filter_skip_unchanged flag_filter_only_target flag_negative_listdb tmpflag_exists put_blankline origin matches_negative matches_positive flag pkg table
510 local currentorigin_is_alll currentorigin_is_target currentorigin_is_requires_requirements
511 local currentorigin_is_initial_requirements currentorigin_is_requires_dependents
512 local currentorigin_is_initial_dependents currentorigin_is_requires_requirements_complement currentorigin_is_relevant
515 flag_filter_skip_unchanged=$3
516 flag_filter_only_target=$4
517 flag_negative_listdb=$5
518 tmpflag_exists=${TMPDIR}/database_query_show_single_list::exists_item
519 if [ `cat "${DBDIR}/$list" 2> /dev/null | wc -l` -eq 0 ]
521 message_echo "INFO: No item is registered in this list."
524 if ! program_chk_stage_complete PREPARATION
526 message_echo "WARNING: The temporary database is incomplete. The raw list is shown." >&2
530 rm -f "$tmpflag_exists"
532 if [ -n "$flag_filter_only_target" \
533 -a -n "$opt_target_itself$opt_target_dependents$opt_target_requirements" ]
535 message_echo "WARNING: Ports outside of the target scope are excluded." >&2
538 if [ -n "$flag_filter_skip_unchanged" -a $opt_skip_unchanged = yes ]
540 message_echo "WARNING: Ports which have been the newest with their all requirements from the first are excluded." >&2
543 [ -n "$put_blankline" ] && message_echo
547 for negative_listdb in $flag_negative_listdb
549 if env LANG=C grep -qFx "$origin" "${DBDIR}/$negative_listdb" 2> /dev/null
555 [ $matches_negative = yes ] && continue
556 if [ -n "$flag_filter_skip_unchanged" -a $opt_skip_unchanged = yes ]
559 for flag in $flag_filter_skip_unchanged
561 if [ -e "${DBDIR}/requires/$origin/$flag" ]
567 [ $matches_positive = no ] && continue
569 if [ -n "$flag_filter_only_target" ]
571 database_query_get_target_attributes currentorigin "$origin"
572 [ -n "${currentorigin_is_relevant}" ] || continue
573 database_query_is_a_port_suppressed "$origin" && continue
576 for table in $pkgnamedb
578 pkg=`cat "${DBDIR}/$table/$origin/pkgtag" 2> /dev/null` || :
579 [ -n "$pkg" ] && break
581 [ -n "$pkg" ] || continue
582 touch "$tmpflag_exists"
583 if [ $opt_batch_mode = no ]
585 echo "$origin ($pkg)"
587 printf '%s\t%s\n' "$origin" "$pkg"
589 done < ${DBDIR}/$list
590 [ -e "$tmpflag_exists" ] && return
591 message_echo "INFO: No item is registered in this list."
595 # ============= Check whether the upgrade is necessary for a port =============
596 database_query_is_necessary_upgrade ()
598 local origin nodedir dbsuffix tmpfile_new tmpfile_old tmpfile_diff
600 nodedir=${DBDIR}/requires/$origin
601 [ -e "$nodedir/installed_by_pkg" ] && return 1
602 dbsuffix=`options_get_dependency_type`.`options_get_dependency_level`
603 tmpfile_new=${TMPDIR}/database_query_is_necessary_upgrade:failed_requirements.new
604 tmpfile_old=${TMPDIR}/database_query_is_necessary_upgrade:failed_requirements.old
605 tmpfile_diff=${TMPDIR}/database_query_is_necessary_upgrade:failed_requirements.diff
606 [ -e "$nodedir/failed_requirements.${dbsuffix}.previous" ] || return
607 sort -u "$nodedir/failed_requirements.${dbsuffix}" > $tmpfile_new 2> /dev/null || :
608 sort -u "$nodedir/failed_requirements.${dbsuffix}.previous" > $tmpfile_old 2> /dev/null || :
609 fileedit_exists_old_lines "$tmpfile_old" "$tmpfile_new"
612 # ============= Show moved or replaced ports to alternatives =============
613 database_query_show_list_moved ()
615 cat "${DBDIR}/moved_ports" 2> /dev/null | while read origin
618 while [ -n "$lastorigin" -a -e "${DBDIR}/replace/$lastorigin/origin" ]
620 lastorigin=`cat "${DBDIR}/replace/$lastorigin/origin"`
622 [ -n "$lastorigin" ] || continue
624 for table in $pkgnamedb
626 pkg=`cat "${DBDIR}/$table/$origin/pkgtag" 2> /dev/null` || :
627 [ -n "$pkg" ] && break
629 [ -n "$pkg" ] || pkg='not installed'
631 for table in moved_from obsolete initial
633 lastpkg=`cat "${DBDIR}/$table/$lastorigin/pkgtag" 2> /dev/null` || :
634 [ -n "$lastpkg" ] && break
636 [ -n "$lastpkg" ] || lastpkg='not installed'
637 if [ $opt_batch_mode = no ]
639 echo "$origin ($pkg) => $lastorigin ($lastpkg)"
641 printf '%s\t%s\t%s\t%s\n' "$origin" "$pkg" "$lastorigin" "$lastpkg"
646 # ============= Actual operations of "show" command for a single list =============
647 database_query_show_single_list_exec ()
649 local subject deptag level dbsuffix flag_filter_skip_unchanged flag_filter_only_target flag_negative_listdb pkgnamedb
653 dbsuffix=$deptag.$level
654 flag_filter_skip_unchanged=
655 flag_filter_only_target=
656 flag_negative_listdb=
657 pkgnamedb='moved_from obsolete initial'
660 message_echo "The following ports remain in the (re)installation queue for the current do/redo process:"
661 message_echo "It is noted that ports to be skipped can be included here."
662 message_dependency_scope "$deptag" "$level"
664 list=stage.loop_list/reinst_todo.remain
665 [ ${DBDIR}/reinst_order.list -nt ${DBDIR}/$list ] && list=reinst_order.list
666 flag_filter_skip_unchanged=necessary_upgrade.$dbsuffix
667 flag_filter_only_target=y
670 message_echo "The following ports have been successfully (re)installed or newly installed:"
671 message_dependency_scope "$deptag" "$level"
673 list=success.$dbsuffix.list
674 flag_filter_skip_unchanged=necessary_upgrade_completed.$dbsuffix
675 flag_filter_only_target=y
678 message_echo "The following ports need (re)installation after success of the all requirements:"
679 message_dependency_scope "$deptag" "$level"
681 list=todo_after_requirements_succeed.$dbsuffix.list
682 flag_filter_skip_unchanged="necessary_upgrade.$dbsuffix necessary_upgrade_completed.$dbsuffix"
683 flag_filter_only_target=y
684 flag_negative_listdb=leaf_ports_to_delete.selected
687 message_echo "The following ports had problems which have been manually resolved:"
689 list=manually_done.list
692 message_echo "The following ports are configured default and installed by prebuilt packages"
694 list=installation_complete_by_pkg.list
697 message_echo "The following ports are configured default and installed by ports"
699 list=inst_by_port_with_default_conf.list
702 message_echo "The following ports are configured non-default and installed by ports"
704 list=inst_by_port_with_custom_conf.list
707 message_echo "The following ports experienced failures and kept to be old or uninstalled:"
709 database_query_show_list_failure
713 message_echo "The following ports are neither upgraded or reinstalled from the initial state:"
715 database_query_show_list_fossil
719 message_echo "The following ports are temporarily deleted due to conflict:"
721 database_query_show_list_failed_conflicts_restoration
725 message_echo "The following ports are moved/replaced to new alternatives:"
727 database_query_show_list_moved
731 message_echo "The following ports are registered as taboo:"
736 message_echo "The following ports are registered to freeze:"
741 message_echo "The following ports are registered as necessary:"
746 message_echo "The following ports are registered as unnecessary:"
751 message_echo "The following leaf, obsolete or unneeded ports had been once deleted but are to be or have been restored:"
753 list=stage.loop_list/ports_to_restore
754 pkgnamedb='moved_from obsolete initial'
755 flag_filter_only_target=y
758 message_echo "The following leaf, obsolete or unneeded ports are to be or have been deleted:"
760 list=stage.loop_list/ports_to_delete
761 pkgnamedb='moved_from obsolete initial'
762 flag_filter_only_target=y
767 message_echo "The following ports are all detected leaf ports:"
770 message_echo "The following ports are all $deptag leaf ports:"
771 list=leaf_ports_to_delete.$deptag
774 pkgnamedb='moved_from obsolete initial'
775 flag_filter_only_target=y
780 message_echo "The following ports are all detected obsolete ports:"
781 list=obsolete_ports.can_be_deleted
783 message_echo "The following ports are all $deptag obsolete ports:"
784 list=obsolete_ports_to_delete.$deptag
787 pkgnamedb='moved_from obsolete initial'
788 flag_filter_only_target=y
791 database_query_show_single_list "$list" "$pkgnamedb" \
792 "$flag_filter_skip_unchanged" "$flag_filter_only_target" "$flag_negative_listdb"
795 # ============= Check whether a port is registered in a list =============
796 database_query_exists_in_list ()
798 local origin subject deptag level tmp_list dbsuffix origin_esc
803 tmp_list=${TMPDIR}/database_query_exists_in_list:list
804 dbsuffix=$deptag.$level
805 origin_esc=`str_escape_regexp "$origin"`
808 list=stage.loop_list/reinst_todo.remain
809 [ ${DBDIR}/reinst_order.list -nt ${DBDIR}/$list ] && list=reinst_order.list
812 list=success.$dbsuffix.list
815 list=todo_after_requirements_succeed.$dbsuffix.list
818 list=manually_done.list
821 list=installation_complete_by_pkg.list
824 list=inst_by_port_with_default_conf.list
827 list=inst_by_port_with_custom_conf.list
833 list=`ls "${DBDIR}"/fossil_pkgs/fossil_since_* | head -n 1`
836 env LANG=C grep -v -E -f "${DBDIR}/ports_to_delete.grep_pattern_col1" "${DBDIR}/deleted_conflicts" 2> /dev/null \
837 | env LANG=C grep -q -E "^${origin_esc}[[:space:]]"
853 list=stage.loop_list/ports_to_restore
856 list=stage.loop_list/ports_to_delete
859 env LANG=C grep -q -Fx "$origin" "${DBDIR}/$list" 2> /dev/null
862 # ============= Check whether the requirements of installed packages match the port configuration =============
863 database_query_dependency_matching ()
865 local origin pkg tmp_inst tmp_db
867 [ -d "${DBDIR}/requires/$origin" ] || return
868 tmp_inst=${TMPDIR}/database_query_dependency_matching.installed
869 tmp_db=${TMPDIR}/database_query_dependency_matching.configured
870 pkg=`database_build_get_new_pkgname "$origin"`
871 [ -n "$pkg" ] || return
872 pkg_info_e "$pkg" || return
873 pkg_info_qr "$pkg" | env LANG=C grep -v '^[[:space:]]*$' | sort -u > $tmp_inst
874 database_build_get_full_run_requirement_pkgs "$origin" > $tmp_db
875 diff "$tmp_inst" "$tmp_db" > /dev/null 2>/dev/null
878 # ============= Check whether any of the requirements are locked because being missing ports to freeze =============
879 database_query_are_requirements_not_locked ()
883 cat "${DBDIR}/requires/$origin/requirements.all.direct" 2> /dev/null | while read origin_requirement
885 pkg_requirement=`pkgsys_get_installed_pkg_from_origin "$origin_requirement"` || :
886 if env LANG=C grep -q -Fx "$origin_requirement" "${DBDIR}/freeze.all.list" 2> /dev/null
888 [ -n "$pkg_requirement" ] || return
889 elif [ -z "$pkg_requirement" ]
891 database_query_are_requirements_not_locked "$origin_requirement" || return
897 # ============= Check whether any of progress is made in the current run =============
898 database_query_is_any_progress ()
900 [ `cat "${DBDIR}/new_success_in_current_run" 2> /dev/null | wc -l` -gt 0 ]
903 # ============= Get the all initial origins, separated by line feed =============
904 database_query_initial_orgins ()
906 local origin origin_init
908 if [ -e "${DBDIR}/moved_from/$origin/old_origs" ]
910 for origin_init in `cat "${DBDIR}/moved_from/$origin/old_origs"`
912 [ -e "${DBDIR}/initial/$origin_init/installed_version" ] && echo "$origin_init"
915 [ -e "${DBDIR}/initial/$origin/installed_version" ] && echo "$origin"
920 # ============= Get an unflavored or flavored equivalence of an origin with the same package name, which is deemed the same version =============
921 # If the input is unflavored and a flavored equivalence is inspected as a required port, the flavored origin is returned.
922 # If the input is flavored and an unflavored equivalence is inspected as a required port, the unflavored origin is returned.
923 # Otherwise, a blank value is returned.
924 database_query_get_equivalent_orgin ()
926 local origin origin_esc pkg_origin pkg_origin_esc flavor origin_unflavored_esc origin_search
928 origin_esc=`str_escape_regexp "$origin"`
929 pkg_origin=`env LANG=C grep -E "[[:space:]]$origin_esc$" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" | cut -f 2 || :`
930 [ -n "$pkg_origin" ] || return 0
931 pkg_origin_esc=`str_escape_regexp "$pkg_origin"`
932 flavor=`pkgsys_get_flavor_from_origin "$origin"`
933 origin_search=$origin_unflavored_esc$
934 [ -n "$flavor" ] || origin_search=$origin_esc@
935 env LANG=C grep -E "^$pkg_origin_esc[[:space:]]$origin_search" "${DBDIR}/installed_ports:pkg_vs_origin.tbl" | cut -f 2 | head -n 1 || :