2 # ==============================================================================
3 # portsreinstall library script
4 # - "do"/"redo" command operation -
5 # Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
6 # This software is distributed under the 2-Clause BSD License.
7 # ==============================================================================
9 # ============= Operation of redo command before the database reconstruction =============
10 command_do_do__command_all_exec_command_specific_preconfiguration ()
12 program_deregister_stage_complete FORGET::PREPARATION_INSPECT_MASTER
13 program_deregister_stage_complete ALL_COMPLETE
16 # ============= Operation of redo command before the database reconstruction =============
17 command_do_redo__command_all_exec_command_specific_preconfiguration ()
19 program_deregister_stage_complete REDO_INIT
20 if [ $opt_reset_targets = yes ]
22 program_deregister_stage_complete DETERMINE_SPECIFIED_TARGETS
23 program_deregister_stage_complete PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
24 rm -rf "${DBDIR}/targets"
26 command_do_do__command_all_exec_command_specific_preconfiguration
29 # ============= Meta process for redo =============
30 command_do_meta_process_for_redo ()
34 _program_exec_and_record_completion__operation ()
36 rm -f "${DBDIR}/new_success_in_current_run"
37 [ "x$COMMAND_MODE" = xredo ] || return 0
38 message_echo "[REDO mode]"
41 program_exec_and_record_completion REDO_INIT
44 # ============= Determine specified targets =============
45 command_do_determine_specified_targets ()
49 _program_exec_and_record_completion__operation ()
51 local tag level dbsuffix
52 message_section_title "Determining specified targets"
53 cat "${DBDIR}/stage.loop_list/target_itself.specified" \
54 "${DBDIR}/stage.loop_list/target_dependents.specified" \
55 "${DBDIR}/stage.loop_list/target_requirements.specified" \
56 "${DBDIR}/need.list" \
57 "${DBDIR}/targets_specified_so_far" 2> /dev/null \
58 | sort -u > ${DBDIR}/targets_specified_so_far.tmp
59 mv "${DBDIR}/targets_specified_so_far.tmp" "${DBDIR}/targets_specified_so_far"
60 rm -f "${DBDIR}/stage.loop_list/target_itself.specified" \
61 "${DBDIR}/stage.loop_list/target_dependents.specified" \
62 "${DBDIR}/stage.loop_list/target_requirements.specified"
63 if [ -n "$opt_target_itself$opt_target_dependents$opt_target_requirements" ]
65 options_select_new_ports_if_duplicated O \
66 "${DBDIR}/stage.loop_list/target_itself.specified" "$opt_target_itself"
67 options_select_new_ports_if_duplicated t \
68 "${DBDIR}/stage.loop_list/target_dependents.specified" "$opt_target_dependents"
69 options_select_new_ports_if_duplicated T \
70 "${DBDIR}/stage.loop_list/target_requirements.specified" "$opt_target_requirements"
71 if [ `cat "${DBDIR}/stage.loop_list/target_itself.specified" \
72 "${DBDIR}/stage.loop_list/target_dependents.specified" \
73 "${DBDIR}/stage.loop_list/target_requirements.specified" | wc -l` -eq 0 ]
75 message_echo "ERROR: No matching port for target globs." >&2
79 cat "${DBDIR}/stage.loop_list/target_itself.specified" \
80 "${DBDIR}/stage.loop_list/target_dependents.specified" \
81 "${DBDIR}/stage.loop_list/target_requirements.specified" \
82 | sort -u > ${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset
83 cat "${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset" "${DBDIR}/need.list" 2> /dev/null \
84 | sort -u > ${DBDIR}/need.list.tmp
85 mv "${DBDIR}/need.list.tmp" "${DBDIR}/need.list"
86 sort -u "${DBDIR}/need.list" "${DBDIR}/targets_specified_so_far" \
87 > ${DBDIR}/targets_specified_so_far.tmp
88 mv "${DBDIR}/targets_specified_so_far.tmp" "${DBDIR}/targets_specified_so_far"
89 for tag in all run build none
91 for level in direct full
95 cat "${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset"
96 cat "${DBDIR}/stage.loop_list/target_dependents.specified" | while read origin
98 nodedir=${DBDIR}/requires/$origin
99 cat "$nodedir/dependents.$dbsuffix" 2> /dev/null
101 cat "${DBDIR}/stage.loop_list/target_requirements.specified" | while read origin
103 nodedir=${DBDIR}/requires/$origin
104 cat "$nodedir/requirements.$dbsuffix" 2> /dev/null
106 } | sort -u | while read origin
108 fileedit_rm_a_line "$origin" "${DBDIR}/success.$dbsuffix.list"
109 fileedit_rm_a_line "$origin" "${DBDIR}/todo_after_requirements_succeed.$dbsuffix.list"
110 rm -f "${DBDIR}/requires/$origin/succeeded_once"
117 program_exec_and_record_completion DETERMINE_SPECIFIED_TARGETS
120 # ============= Show specified targets =============
121 command_do_show_specified_targets ()
123 if [ -n "$opt_target_itself$opt_target_dependents$opt_target_requirements" -a $opt_batch_mode = no ]
125 message_echo "INFO: (Re/de-)installation will be carried out only for the targets:"
127 if [ `wc -l < ${DBDIR}/stage.loop_list/target_itself.specified` -gt 0 ]
129 message_echo "[Targets only]"
130 echo "----------------------------------------"
131 cat "${DBDIR}/stage.loop_list/target_itself.specified"
132 echo "----------------------------------------"
135 if [ `wc -l < ${DBDIR}/stage.loop_list/target_dependents.specified` -gt 0 ]
137 message_echo "[Targets with their `options_get_dependency_msgterm` dependents]"
138 echo "----------------------------------------"
139 cat "${DBDIR}/stage.loop_list/target_dependents.specified"
140 echo "----------------------------------------"
143 if [ `wc -l < ${DBDIR}/stage.loop_list/target_requirements.specified` -gt 0 ]
145 message_echo "[Targets with their `options_get_dependency_msgterm` requirements]"
146 echo "----------------------------------------"
147 cat "${DBDIR}/stage.loop_list/target_requirements.specified"
148 echo "----------------------------------------"
154 # ============= Determine all target ports =============
155 command_do_determine_all_target_ports ()
157 local PROGRAM_DEPENDS
158 PROGRAM_DEPENDS='DETERMINE_SPECIFIED_TARGETS COLLECT_ALL_INSTALLED_PACKAGES'
159 _program_exec_and_record_completion__operation ()
161 message_section_title "Determining all target ports"
163 if [ $opt_only_target_scope = no ]
165 cat "${DBDIR}/installed_ports" 2> /dev/null || :
167 cat "${DBDIR}/stage.loop_list/target_itself.specified" || :
168 cat "${DBDIR}/stage.loop_list/target_dependents.specified" || :
169 cat "${DBDIR}/stage.loop_list/target_requirements.specified" || :
170 cat "${DBDIR}/targets_specified_so_far" || :
171 } 2> /dev/null | sort -u > "${DBDIR}/stage.loop_list/ports_to_inspect"
174 [ -d "${PORTSDIR}/$origin" ] || echo "$origin"
175 done < ${DBDIR}/stage.loop_list/ports_to_inspect > ${DBDIR}/obsoletes_to_escape_for_inspection
178 program_exec_and_record_completion DETERMINE_ALL_TARGET_PORTS
181 # ============= Prepare for inspecting all dependencies =============
182 command_do_prepare_for_inspect_all_dependencies ()
184 local PROGRAM_DEPENDS
185 PROGRAM_DEPENDS='PARSE_CONF DETERMINE_ALL_TARGET_PORTS'
186 _program_exec_and_record_completion__operation ()
188 message_section_title "Preparing for inspection of all dependencies"
189 database_build_escape "${DBDIR}/escaped_obsoletes" < ${DBDIR}/obsoletes_to_escape_for_inspection
190 cp /dev/null "${DBDIR}/done_required_ports_to_inspect"
193 program_exec_and_record_completion PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
196 # ============= Check ports of which the port options are changed and reset their databases =============
197 # Return status 0 for no need to update of inspected ports and 1 for needed to do it
198 command_do_reset_changed_portdb ()
201 program_chk_stage_complete INSPECT_DEPENDENTS || return
202 pkgsys_exists_saved_port_oprions_timestamps || return
203 message_section_title "Inspecting changes of port options"
204 tmp_ls=${TMPDIR}/command_do_reset_changed_portdb
205 rm -f "$tmp_ls.updated"
206 if [ ! -d "${PORT_DBDIR}" ]
208 message_echo "WARNING: ${PORT_DBDIR} is missing. All port options are recognized as default."
210 pkgsys_get_saved_port_oprions_timestamps_all > $tmp_ls.db
211 pkgsys_get_current_port_oprions_timestamp > $tmp_ls.log
212 pkgsys_get_changed_port_oprions "$tmp_ls.db" "$tmp_ls.log" > $tmp_ls.diff
213 if ! [ `wc -l < $tmp_ls.diff` -gt 0 ]
218 message_echo "INFO: There are some changes. Inspecting the detail..."
219 cp /dev/null "$tmp_ls.uninspected.dbfile"
220 cp /dev/null "$tmp_ls.uninspected.origin"
221 cp /dev/null "$tmp_ls.nonexistent.db"
222 pkgsys_conv_portoptiondbs_to_globs < $tmp_ls.diff > $tmp_ls.glob
223 str_escape_replaceval_filter < $tmp_ls.diff > $tmp_ls.diff.rpl
224 paste "$tmp_ls.diff" "$tmp_ls.diff.rpl" "$tmp_ls.glob" | while read -r dbfile dbfile_rpl glob
226 pkgsys_eval_ports_glob "$glob" > $tmp_ls.origins
227 if [ `wc -l < $tmp_ls.origins` -gt 0 ]
229 sed -E "s/^/$dbfile_rpl /" < $tmp_ls.origins
231 echo $dbfile >> $tmp_ls.nonexistent.db
233 done | while read dbfile origin
235 if [ -d "${DBDIR}/requires/$origin" ]
237 message_echo "Change detected on $origin: Resetting"
238 database_build_patch_reconf "$origin"
239 program_deregister_stage_complete PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
240 program_deregister_stage_complete ALL_COMPLETE
241 touch "$tmp_ls.updated"
243 echo "$dbfile" >> $tmp_ls.uninspected.dbfile
244 echo "$origin" >> $tmp_ls.uninspected.origin
247 message_echo "INFO: Recording for not inspected ports..."
248 pkgsys_conv_portorigin_to_port_oprion_timestamp_logname < $tmp_ls.uninspected.origin > $tmp_ls.uninspected.logname
249 str_escape_regexp_filter < $tmp_ls.uninspected.dbfile | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.uninspected.dbfile_ptn
250 paste "$tmp_ls.uninspected.dbfile_ptn" "$tmp_ls.uninspected.logname" | while read -r dbfile_ptn logname
252 grep -E "$dbfile_ptn" < $tmp_ls.log > ${DBDIR}/ls_dbdir/$logname.log 2> /dev/null || :
254 str_escape_regexp_filter < $tmp_ls.nonexistent.db | sed 's/^/^/;s/$/[[:space:]]/' > $tmp_ls.nonexistent.db_ptn
255 grep -E -f "$tmp_ls.nonexistent.db_ptn" < $tmp_ls.log | pkgsys_register_list_nonexistent_portopriondb
257 [ ! -e "$tmp_ls.updated" ]
260 # ============= Inspection of all dependencies =============
261 command_do_inspection_of_all_dependencies ()
263 local PROGRAM_DEPENDS
264 PROGRAM_DEPENDS='PREPARE_FOR_INSPECT_ALL_DEPENDENCIES'
265 _program_exec_restartable_loop_operation__routine ()
269 database_build_inspect_dependencies "$origin"
271 _program_exec_and_record_completion__operation ()
274 message_section_title "Inspecting dependencies of the all installed packages"
275 [ $opt_only_target_scope = no -a -n "$opt_target_itself$opt_target_dependents$opt_target_requirements" ] && \
276 message_echo "INFO: Ports which seem irrelevant to the targets are also inspected in order to get complete information."
278 program_exec_restartable_loop_operation ports_to_inspect
279 database_build_post_inspect_dependencies
280 database_maintain_clear_prevset
283 program_exec_and_record_completion INSPECT_ALL_DEPENDENCIES
286 # ============= Convert dependency-lists to actual ones =============
287 command_do_convert_dependency_lists_to_actual_ones ()
289 local PROGRAM_DEPENDS
290 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES'
291 _program_exec_restartable_loop_operation__routine ()
293 local origin table dbtag level tag target
295 for table in dependents requirements
297 for dbtag in requires obsolete
299 for level in direct full
301 for tag in all run build
303 target=${DBDIR}/$dbtag/$origin/${table}.${tag}.${level}
304 if [ -e "$target.src" ]
306 sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \
307 | grep -v '^$' | sort -u > $target.tmp
308 [ -e "$target" ] && ! diff -q "$target.tmp" "$target" > /dev/null \
309 && echo "$origin" >> ${DBDIR}/update_dependencies
310 mv "$target.tmp" "$target"
312 [ -e "$target" ] && echo "$origin" >> ${DBDIR}/update_dependencies
320 _program_exec_and_record_completion__operation ()
322 message_section_title "Conversion of dependency-lists to actual ones"
323 program_exec_restartable_loop_operation convert_dependency_lists
324 sort -u "${DBDIR}/update_dependencies" > ${DBDIR}/update_dependencies.tmp
325 mv "${DBDIR}/update_dependencies.tmp" "${DBDIR}/update_dependencies"
326 for tag in all run build
328 ( cd "${DBDIR}/requires" && \
329 find . -depth 3 -type f -name requirements.${tag}.full -or -name requirements.${tag}.full.orig ) \
331 | sed 's|^./||;s|/[^/]*$||' \
332 | grep -v -Fx -f "${DBDIR}/update_dependencies" \
333 > ${TMPDIR}/convert_requirements_list:full_complete.grep_pattern || :
334 ( cd "${DBDIR}/requires" && \
335 find . -depth 3 -type f -name requirements.${tag}.direct -or -name requirements.${tag}.direct.orig ) \
337 | sed 's|^./||;s|/[^/]*$||' \
338 | grep -v -Fx -f "${TMPDIR}/convert_requirements_list:full_complete.grep_pattern" \
339 > ${DBDIR}/stage.loop_list/complete_recursive_${tag}time_reqlists || :
341 for inspected_level_tmp in direct node
343 cat "${DBDIR}/ports.inspected.${inspected_level_tmp}.list" || :
344 done 2> /dev/null | sort -u > ${DBDIR}/stage.loop_list/trim_dependency_lists_rm_uninspected_ports
345 find "${DBDIR}/requires" -depth 2 -type d > ${DBDIR}/stage.loop_list/inspect_dependent
346 [ -e "${DBDIR}/dependents_files" ] && \
347 mv "${DBDIR}/dependents_files" "${DBDIR}/dependents_files.prev"
348 rm -f "${DBDIR}/stage.loop_list/make_dependents_lists_unique.tmp" "${DBDIR}/dependents_files.tmp"
351 program_exec_and_record_completion CONVERT_REQUIREMENTS_LIST
354 # ============= Completion of recursive requirement lists =============
355 command_do_completion_of_recursive_requirement_lists ()
357 local PROGRAM_DEPENDS _REQUIREMENT_LISTS_tag
358 for _REQUIREMENT_LISTS_tag in all run build
360 PROGRAM_DEPENDS='CONVERT_REQUIREMENTS_LIST'
361 _program_exec_restartable_loop_operation__routine ()
363 local tag dbpath origin suffix
364 tag=${_REQUIREMENT_LISTS_tag}
366 origin=`str_dirpath_to_origin "$dbpath"`
367 for suffix in '' .orig
369 database_build_get_complete_recursive_dependency "$tag" "$origin" "$suffix" > /dev/null
372 _program_exec_and_record_completion__operation ()
375 tag=${_REQUIREMENT_LISTS_tag}
376 message_section_title "Completion of ${tag}-time requirement lists"
377 program_exec_restartable_loop_operation complete_recursive_${tag}time_reqlists
380 program_exec_and_record_completion RECURSIVE_REQUIREMENT_LISTS:${_REQUIREMENT_LISTS_tag}
384 # ============= Trim dependency lists by removing uninspected ports =============
385 command_do_trim_dependency_lists_by_removing_uninspected_ports ()
387 local PROGRAM_DEPENDS
388 if [ $opt_only_target_scope = yes ]
390 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES CONVERT_REQUIREMENTS_LIST'
391 _program_exec_restartable_loop_operation__routine ()
393 local dbpath tag level srcdb
395 for tag in all run build
397 for level in direct full
399 srcdb=requirements.${tag}.${level}
400 [ -e "$dbpath/$srcdb" ] || continue
401 grep -Fx -f "${DBDIR}/inspected_ports" "$dbpath/$srcdb" > $dbpath/$srcdb.tmp || :
402 mv "$dbpath/$srcdb.tmp" "$dbpath/$srcdb"
406 _program_exec_and_record_completion__operation ()
408 message_section_title "Trimming dependency lists by removing uninspected ports"
409 program_exec_restartable_loop_operation trim_dependency_lists_rm_uninspected_ports
412 program_exec_and_record_completion TRIM_DEPENDENCY_LISTS_RM_UNINSPECTED_PORTS
416 # ============= Inspection of dependents =============
417 command_do_inspection_of_dependents ()
419 local PROGRAM_DEPENDS
420 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES CONVERT_REQUIREMENTS_LIST TRIM_DEPENDENCY_LISTS_RM_UNINSPECTED_PORTS'
421 _program_exec_restartable_loop_operation__routine ()
423 local dbpath origin tag level suffix srcdb dstdb
425 origin=`str_dirpath_to_origin "$dbpath"`
426 for tag in all run build
428 for suffix in '' .orig
430 for level in direct full
432 srcdb=requirements.${tag}.${level}${suffix}
433 [ -e "$dbpath/$srcdb" ] || continue
434 dstdb=dependents.${tag}.${level}${suffix}
435 while read origin_requirement
437 dstpath=${DBDIR}/requires/$origin_requirement
438 echo "$dstpath/$dstdb" >> ${DBDIR}/dependents_files.tmp
439 [ "$dstpath/$dstdb" -nt "$dbpath/$srcdb" ] && continue
441 echo "$origin" >> $dstpath/$dstdb.raw
442 echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_dependents_lists_unique.tmp
443 done < $dbpath/$srcdb
445 srcdb=ignored_requirements.${tag}${suffix}
446 [ -e "$dbpath/$srcdb" ] || continue
447 dstdb=ignored_dependents.${tag}${suffix}
448 while read origin_requirement
450 dstpath=${DBDIR}/requires/$origin_requirement
451 echo "$dstpath/$dstdb" >> ${DBDIR}/ignored_dependents_files.tmp
452 [ "$dstpath/$dstdb" -nt "$dbpath/$srcdb" ] && continue
454 echo "$origin" >> $dstpath/$dstdb.raw
455 echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_ignored_dependents_lists_unique.tmp
456 done < $dbpath/$srcdb
460 _program_exec_and_record_completion__operation ()
462 local dbrequires_valesc
463 message_section_title "Inspection of dependents"
464 dbrequires_valesc=`str_escape_replaceval "${DBDIR}/requires/"`
465 program_exec_restartable_loop_operation inspect_dependent
466 for dbtype in dependents ignored_dependents
468 sort -u "${DBDIR}/stage.loop_list/make_${dbtype}_lists_unique.tmp" 2> /dev/null \
469 > ${DBDIR}/stage.loop_list/make_${dbtype}_lists_unique || :
470 sort -u "${DBDIR}/${dbtype}_files.tmp" 2> /dev/null > ${DBDIR}/${dbtype}_files || :
471 [ -e "${DBDIR}/make_${dbtype}_lists_unique.prev" ] && \
472 fileedit_manipulate_old_lines "${DBDIR}/${dbtype}_files.prev" "${DBDIR}/${dbtype}_files" \
477 program_exec_and_record_completion INSPECT_DEPENDENTS
480 # ============= Restore escaped obsolete packages for inspection =============
481 command_do_restore_escaped_obsoletes ()
483 local PROGRAM_DEPENDS
484 PROGRAM_DEPENDS='INSPECT_DEPENDENTS'
485 _program_exec_and_record_completion__operation ()
487 message_section_title "Restoring escaped obsolete packages for inspection"
488 database_build_restore < ${DBDIR}/escaped_obsoletes
491 program_exec_and_record_completion RESTORE_ESCAPED_OBSOLETE_PACKAGES_FOR_INSPECTION
494 # ============= Remove duplicated lines in dependents lists =============
495 command_do_remove_duplicated_lines_in_dependents_lists ()
497 local PROGRAM_DEPENDS
498 PROGRAM_DEPENDS='CONVERT_REQUIREMENTS_LIST INSPECT_DEPENDENTS'
499 _program_exec_restartable_loop_operation__routine ()
501 local dbpath tag level dstdb
503 cat "$dstdb" "$dstdb.raw" 2> /dev/null | sort -u > $dstdb.tmp
504 mv "$dstdb.tmp" "$dstdb"
507 _program_exec_and_record_completion__operation ()
509 local dbrequires_valesc
510 message_section_title "Removing duplicated items in dependents lists"
511 program_exec_restartable_loop_operation make_dependents_lists_unique
514 program_exec_and_record_completion MAKE_DEPENDENTS_LISTS_UNIQUE
517 # ============= Remove duplicated lines in ignored dependents lists =============
518 command_do_remove_duplicated_lines_in_ignored_dependents_lists ()
520 local PROGRAM_DEPENDS
521 PROGRAM_DEPENDS='CONVERT_REQUIREMENTS_LIST INSPECT_DEPENDENTS'
522 _program_exec_restartable_loop_operation__routine ()
524 local dbpath tag level dstdb
526 cat "$dstdb" "$dstdb.raw" 2> /dev/null | sort -u > $dstdb.tmp
527 mv "$dstdb.tmp" "$dstdb"
530 _program_exec_and_record_completion__operation ()
532 local dbrequires_valesc
533 message_section_title "Removing duplicated items in ignored dependents lists"
534 program_exec_restartable_loop_operation make_ignored_dependents_lists_unique
537 program_exec_and_record_completion MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE
540 # ============= Preparation of target attribute information =============
541 command_do_preparation_of_target_attribute_information ()
543 local PROGRAM_DEPENDS _TARGET_ATTR_INFO_table
544 for _TARGET_ATTR_INFO_table in requirements dependents itself
546 [ `cat "${DBDIR}/stage.loop_list/target_${_TARGET_ATTR_INFO_table}.replaced.specified" 2> /dev/null \
547 | wc -l` -gt 0 ] || continue
548 PROGRAM_DEPENDS='DETERMINE_SPECIFIED_TARGETS CONVERT_REQUIREMENTS_LIST'
549 _program_exec_restartable_loop_operation__routine ()
551 local origin dbtargets_valesc table
553 dbtargets_valesc=`str_escape_replaceval "${DBDIR}/targets/"`
554 table=${_TARGET_ATTR_INFO_table}
555 for database in requires initial
557 dbpath=${DBDIR}/$database/$origin
558 dstpath=${DBDIR}/targets/$origin
560 touch "$dstpath/target_itself"
561 echo "$origin" >> ${DBDIR}/all_targets.lst
562 [ $table = itself ] && continue
563 for tag in all run build
565 for level in direct full
567 srcdb=${table}.${tag}.${level}
568 dstdb=target_${database}_${table}.${tag}.${level}
569 [ -e "$dbpath/$srcdb" ] || continue
570 cat "$dbpath/$srcdb" >> ${DBDIR}/all_targets.lst
571 sed -E "s/^/$dbtargets_valesc/; s|$|/$dstdb|" "$dbpath/$srcdb" \
572 | fileedit_add_a_line_to_files_if_new "$origin"
577 _program_exec_and_record_completion__operation ()
580 table=${_TARGET_ATTR_INFO_table}
581 message_section_title "Preparation of target attribute information for dependency [$table]"
582 program_exec_restartable_loop_operation target_$table.replaced.specified
585 program_exec_and_record_completion TARGET_ATTR_INFO:${_TARGET_ATTR_INFO_table}
589 # ============= Post-process after the preparation of target attribute information =============
590 command_do_post_process_after_the_preparation_of_target_attribute_information ()
592 local PROGRAM_DEPENDS
593 PROGRAM_DEPENDS='MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE TARGET_ATTR_INFO:requirements TARGET_ATTR_INFO:dependents'
594 _program_exec_and_record_completion__operation ()
596 message_section_title "Post-process after the preparation of target attribute information"
597 sort -u "${DBDIR}/all_targets.lst" 2> /dev/null \
598 | grep -Fx -f "${DBDIR}/inspected_ports" \
599 | sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" 2> /dev/null \
600 > ${DBDIR}/all_targets.lst.tmp || :
601 mv "${DBDIR}/all_targets.lst.tmp" "${DBDIR}/all_targets.lst"
602 find "${DBDIR}/targets" -depth 2 -type d > ${DBDIR}/stage.loop_list/build_complement_to_new_dependents_for_targets 2> /dev/null || :
604 cat "${DBDIR}/all_targets.lst" "${DBDIR}/need.with_replaced.list" 2> /dev/null || :
605 find "${DBDIR}/moved_from" -depth 3 -type f -name installed_version \
606 | sed -E 's|.*/([^/]+/[^/]+)/[^/]*$|\1|'
607 } | sort -u > ${DBDIR}/stage.loop_list/inspect_necessity
608 cp /dev/null "${DBDIR}/stage.loop_list/parse_target_attr_info"
609 find -E "${DBDIR}/requires" -depth 3 -type f -regex '.*/necessary_port\.(direct|full)$' -delete
612 program_exec_and_record_completion TARGET_ATTR_INFO_POSTPROCESS
615 # ============= Build of data on complement to new dependents for target attribute information =============
616 command_do_build_of_data_on_complement_to_new_dependents_for_target_attribute_information ()
618 local PROGRAM_DEPENDS
619 PROGRAM_DEPENDS='TARGET_ATTR_INFO_POSTPROCESS TARGET_ATTR_INFO:requirements TARGET_ATTR_INFO:dependents CONVERT_REQUIREMENTS_LIST'
620 _program_exec_restartable_loop_operation__routine ()
624 origin=`str_dirpath_to_origin "$dbpath"`
625 database_build_complement_to_new_dependents_for_targets "$origin"
627 _program_exec_and_record_completion__operation ()
629 message_section_title "Build of data on complement to new dependents for target attribute information"
630 program_exec_restartable_loop_operation build_complement_to_new_dependents_for_targets
631 sort -u "${DBDIR}/stage.loop_list/parse_target_attr_info" > ${DBDIR}/stage.loop_list/parse_target_attr_info.tmp
632 mv "${DBDIR}/stage.loop_list/parse_target_attr_info.tmp" "${DBDIR}/stage.loop_list/parse_target_attr_info"
635 program_exec_and_record_completion COMPLEMENT_TO_NEW_DEPENDENTS_FOR_TARGET_ATTR_INFO
638 # ============= Parse target attribute information =============
639 command_do_parse_target_attribute_information ()
641 local PROGRAM_DEPENDS
642 PROGRAM_DEPENDS='COMPLEMENT_TO_NEW_DEPENDENTS_FOR_TARGET_ATTR_INFO'
643 _program_exec_restartable_loop_operation__routine ()
647 origin=`str_dirpath_to_origin "$dbpath"`
648 database_build_target_attributes "$origin"
650 _program_exec_and_record_completion__operation ()
652 message_section_title "Parsing target attribute information"
653 program_exec_restartable_loop_operation parse_target_attr_info
656 program_exec_and_record_completion PARSE_TARGET_ATTR_INFO
659 # ============= Inspection of necessity =============
660 command_do_inspection_of_necessity ()
662 local PROGRAM_DEPENDS
663 PROGRAM_DEPENDS='TARGET_ATTR_INFO_POSTPROCESS RECURSIVE_REQUIREMENT_LISTS:run RECURSIVE_REQUIREMENT_LISTS:build INSPECT_ALL_DEPENDENCIES'
664 _program_exec_restartable_loop_operation__routine ()
668 for level in direct full
670 database_build_inspect_necessity_for_only_new_upgrade "$origin" "$level"
673 _program_exec_and_record_completion__operation ()
675 message_section_title "Inspection of necessity"
676 program_exec_restartable_loop_operation inspect_necessity
677 for level in direct full
679 find "${DBDIR}/requires" -depth 3 -type f -name "necessary_port.${level}" \
680 > ${DBDIR}/stage.loop_list/necessary_ports.${level}
684 program_exec_and_record_completion INSPECT_NECESSITY
687 # ============= Inspection of necessary upgrades =============
688 command_do_inspection_of_necessary_upgrades ()
690 local PROGRAM_DEPENDS _NECESSARY_UPDATES_level
691 for _NECESSARY_UPDATES_level in direct full
693 PROGRAM_DEPENDS='INSPECT_NECESSITY INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE'
694 _program_exec_restartable_loop_operation__routine ()
696 local markerpath level dbpath origin tag
698 level=${_NECESSARY_UPDATES_level}
699 dbpath=`dirname "$markerpath"`
700 origin=`str_dirpath_to_origin "$dbpath"`
701 database_query_does_a_port_need_update "$origin" || return 0
702 for tag in all run build none
704 touch "$dbpath/necessary_upgrade.$tag.${level}"
705 [ -e "$dbpath/dependents.$tag.${level}" -o "$dbpath/ignored_dependents.$tag" ] || continue
706 cat "$dbpath/dependents.$tag.${level}" "$dbpath/ignored_dependents.$tag" 2> /dev/null | \
707 while read origin_dependent
709 touch "${DBDIR}/requires/$origin_dependent/necessary_upgrade.$tag.${level}"
713 _program_exec_and_record_completion__operation ()
716 level=${_NECESSARY_UPDATES_level}
717 message_section_title "Inspection of necessary upgrades at the $level level"
718 program_exec_restartable_loop_operation necessary_ports.${level}
721 program_exec_and_record_completion NECESSARY_UPDATES:${_NECESSARY_UPDATES_level}
725 # ============= Preparation for inspection of new leaf ports =============
726 command_do_preparation_for_inspection_of_new_leaf_ports ()
728 local PROGRAM_DEPENDS
729 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
731 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE PARSE_CONF'
732 _program_exec_and_record_completion__operation ()
734 message_section_title "Preparation for inspection of new leaf ports"
735 find "${DBDIR}/requires" -depth 3 -type f -name dependents.all.full -or -name ignored_dependents.all \
736 | sed -E 's|.*/([^/]+/[^/]+)/[^/]+$|\1|' \
737 | sort -u > ${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:nonleaf_ports
738 sort -u "${DBDIR}/inspected_ports" > ${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:inspected_ports
739 fileedit_manipulate_new_lines \
740 "${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:nonleaf_ports" \
741 "${TMPDIR}/PREPARE_INSPECT_LEAF_PORTS:inspected_ports" \
742 | grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null \
743 > ${DBDIR}/stage.loop_list/leaf_ports_primary_candidates || :
744 cp /dev/null "${DBDIR}/leaf_ports.filter"
745 cp /dev/null "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates"
748 program_exec_and_record_completion PREPARE_INSPECT_LEAF_PORTS
752 # ============= Inspection of new primary leaf ports =============
753 command_do_inspection_of_new_primary_leaf_ports ()
755 local PROGRAM_DEPENDS
756 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
758 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE PREPARE_INSPECT_LEAF_PORTS PARSE_CONF'
759 _program_exec_restartable_loop_operation__routine ()
761 local origin origin_ini dbpath origin_req
763 pkgsys_is_pkgtool "$origin" && return
764 dbpath=${DBDIR}/requires/$origin
765 grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
766 if ! grep -q -Fx "$origin" "${DBDIR}/noneed.list" 2> /dev/null
768 if [ -e "$dbpath/initial_orig" ]
770 origin_ini=`cat "$dbpath/initial_orig"`
771 [ -e "${DBDIR}/initial/$origin_ini/installed_version" \
772 -a `cat "${DBDIR}/initial/$origin_ini/dependents.all.full" 2> /dev/null | wc -l` -eq 0 ] \
775 [ -e "${DBDIR}/initial/$origin/installed_version" \
776 -a `cat "${DBDIR}/initial/$origin/dependents.all.full" 2> /dev/null | wc -l` -eq 0 ] \
779 if [ -e "$dbpath/requirements.all.full" -o -e "$dbpath/ignored_requirements.all" ]
781 cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null | \
782 grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null| \
783 fileedit_add_lines_if_new "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || :
785 fileedit_add_a_line_if_new "$origin" "${DBDIR}/leaf_ports.filter"
787 _program_exec_and_record_completion__operation ()
789 local num_leaves num_leaves_prev
790 message_section_title "Inspection of new primary leaf ports"
791 program_exec_restartable_loop_operation leaf_ports_primary_candidates
792 wc -l < ${DBDIR}/leaf_ports.filter | tr -d ' ' > ${DBDIR}/num_leaves
793 cp /dev/null "${DBDIR}/leaf_ports_secondary_candidates.new_requirements"
794 message_echo " `cat "${DBDIR}/num_leaves"` primary leaf port(s) is/are found."
797 program_exec_and_record_completion INSPECT_PRIMARY_LEAF_PORTS
801 # ============= Inspection of requirements of new leaf ports =============
802 command_do_inspection_of_requirements_of_new_leaf_ports ()
804 local PROGRAM_DEPENDS
805 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
807 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE INSPECT_PRIMARY_LEAF_PORTS PARSE_CONF'
808 _program_exec_and_record_completion__operation ()
810 local num_leaves num_leaves_prev num_inspect num_leaves_new
811 message_section_title "Inspection of requirements of new leaf ports"
812 message_echo "INFO: The inspection proceeds by iterative method."
815 _program_exec_restartable_loop_operation__routine ()
819 pkgsys_is_pkgtool "$origin" && return
820 dbpath=${DBDIR}/requires/$origin
821 grep -q -Fx "$origin" "${DBDIR}/need.with_replaced.list" 2> /dev/null && return
822 cat "$dbpath/dependents.all.full" "$dbpath/ignored_dependents.all" 2> /dev/null \
823 | grep -Fxq -v -f "${DBDIR}/leaf_ports.filter" 2> /dev/null && return
824 cat "$dbpath/requirements.all.full" "$dbpath/ignored_requirements.all" 2> /dev/null \
825 >> ${DBDIR}/leaf_ports_secondary_candidates.new_requirements || :
826 fileedit_add_a_line_if_new "$origin" "${DBDIR}/leaf_ports.filter"
828 program_exec_restartable_loop_operation leaf_ports_secondary_candidates
829 num_leaves_prev=`cat "${DBDIR}/num_leaves"`
830 num_leaves=`wc -l < ${DBDIR}/leaf_ports.filter | tr -d ' '`
831 num_leaves_new=`echo $(($num_leaves-$num_leaves_prev)) | tr -d ' '`
832 if [ $num_leaves_new -eq 0 ]
834 message_echo " No more leaf port is found."
835 message_echo " $num_leaves leaf port(s) is/are found in total."
839 grep -Fx -v -f "${DBDIR}/leaf_ports.filter" \
840 "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates" || :
841 cat "${DBDIR}/leaf_ports_secondary_candidates.new_requirements" || :
842 } 2> /dev/null | grep -v -Fx -f "${DBDIR}/conf/HOLD:PORTS.parsed" 2> /dev/null | sort -u \
843 > ${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates.tmp || :
844 program_reset_loop_for_stage INSPECT_REQUIREMENTS_OF_LEAF_PORTS
845 mv "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates.tmp" \
846 "${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates"
847 cp /dev/null "${DBDIR}/leaf_ports_secondary_candidates.new_requirements"
848 echo "$num_leaves" > ${DBDIR}/num_leaves
849 num_inspect=`wc -l < ${DBDIR}/stage.loop_list/leaf_ports_secondary_candidates | tr -d ' '`
850 message_echo " $num_leaves_new leaf port(s) is/are newly found; continue for $num_inspect candidate(s)."
852 grep -Fx -f "${DBDIR}/leaf_ports.filter" "${DBDIR}/inspected_ports" 2> /dev/null | sort -u > ${DBDIR}/leaf_ports || :
855 program_exec_and_record_completion INSPECT_REQUIREMENTS_OF_LEAF_PORTS
859 # ============= Order the ports considering dependencies =============
860 command_do_order_the_ports_considering_dependencies ()
862 local PROGRAM_DEPENDS
863 PROGRAM_DEPENDS='CONVERT_REQUIREMENTS_LIST'
864 _program_exec_and_record_completion__operation ()
866 message_section_title "Ordering dependencies"
867 if ! database_build_order_ports_considering_dependencies
869 message_echo "ERROR: Unsatisfied dependencies are remained:" >&2
870 message_cat "${DBDIR}/unsatisfied.list"
871 message_echo "*** Aborted by ${APPNAME}"
872 message_echo "The ports tree seems broken. You might have caught an incomplete version."
873 message_echo "You are encouraged to update the ports tree by portsnap(8)."
874 message_echo "Then execute"
875 message_echo " ${APPNAME} clean"
876 message_echo "before restart."
877 temp_terminate_process () { :; }
882 program_exec_and_record_completion ORDER_ALL_DEPENDENCIES
885 # ============= Selection of removing leaf ports =============
886 command_do_selection_of_removing_leaf_ports ()
888 local PROGRAM_DEPENDS
889 PROGRAM_DEPENDS='INSPECT_REQUIREMENTS_OF_LEAF_PORTS'
890 _program_exec_and_record_completion__operation ()
892 message_section_title "Selection of removing leaf ports"
893 deinstall_select_leaf_ports_to_delete
896 program_exec_and_record_completion SELECT_LEAF_PORTS
899 # ============= Selection of removing obsolete ports =============
900 command_do_selection_of_removing_obsolete_ports ()
902 local PROGRAM_DEPENDS
903 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES PARSE_CONF'
904 _program_exec_and_record_completion__operation ()
906 message_section_title "Selection of removing obsolete ports"
907 deinstall_select_obsolete_ports_to_delete
910 program_exec_and_record_completion SELECT_OBSOLETE_PORTS
913 # ============= Collection of leaf ports to delete =============
914 command_do_collection_of_leaf_ports_to_delete ()
916 local PROGRAM_DEPENDS
917 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
919 PROGRAM_DEPENDS='SELECT_LEAF_PORTS'
920 _program_exec_and_record_completion__operation ()
922 local src src_unselected reqptn_file src_with_initial_origins
923 message_section_title "Collecting leaf ports to delete"
924 src=${DBDIR}/leaf_ports
925 src_unselected=${DBDIR}/leaf_ports_to_delete.unselected
926 src_with_initial_origins=${DBDIR}/leaf_ports.with_ini
927 reqptn_file=${DBDIR}/leaf_ports.requirements_of_unselected
928 cat "$src_unselected" 2> /dev/null | while read origin
930 cat "${DBDIR}/requires/$origin/requirements.all.full" "${DBDIR}/requires/$origin/ignored_requirements.all" || :
931 done 2> /dev/null | sort -u > $reqptn_file
932 database_query_add_initial_origins < $src > $src_with_initial_origins
935 program_exec_and_record_completion COLLECT_LEAF_PORTS_TO_DELETE
939 # ============= Collection of obsolete ports to delete =============
940 command_do_collection_of_obsolete_ports_to_delete ()
942 local PROGRAM_DEPENDS
943 PROGRAM_DEPENDS='SELECT_OBSOLETE_PORTS'
944 _program_exec_and_record_completion__operation ()
946 local src src_selected src_unselected dst_selected reqptn_file
947 message_section_title "Collecting obsolete ports to delete"
948 src=${DBDIR}/obsolete_ports.can_be_deleted
949 src_selected=${DBDIR}/obsolete_ports_to_delete.selected
950 src_unselected=${DBDIR}/obsolete_ports_to_delete.unselected
951 dst_selected=${DBDIR}/obsolete_ports_to_delete
952 reqptn_file=${DBDIR}/obsolete_ports.requirements_of_unselected
953 cat "$src_unselected" 2> /dev/null | while read origin
955 cat "${DBDIR}/initial/$origin/requirements.run.full" || :
956 cat "${DBDIR}/obsolete/$origin/requirements.run.full" || :
957 done | sort -u > $reqptn_file
958 grep -v -Fx -f "$reqptn_file" "$src_selected" > $dst_selected 2> /dev/null || :
961 program_exec_and_record_completion COLLECT_OBSOLETE_PORTS_TO_DELETE
964 # ============= Set up the list of ports to reinstall =============
965 command_do_set_up_the_list_of_ports_to_reinstall ()
967 local PROGRAM_DEPENDS
968 PROGRAM_DEPENDS='ORDER_ALL_DEPENDENCIES'
969 _program_exec_and_record_completion__operation ()
971 message_section_title "Setting up the list of ports to reinstall"
972 cp -p "${DBDIR}/reinst_order.list" "${DBDIR}/stage.loop_list/reinst_todo"
975 program_exec_and_record_completion SETUP_REINST_TODO
978 # ============= Composition of a list for deinstallation of obsolete and leaf packages =============
979 command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_packages ()
981 local PROGRAM_DEPENDS
982 PROGRAM_DEPENDS='COLLECT_LEAF_PORTS_TO_DELETE COLLECT_OBSOLETE_PORTS_TO_DELETE'
983 _program_exec_and_record_completion__operation ()
985 local reqptn_leaf reqptn_obs leaf_selected leaf_selected_src obs_selected obs_selected_src grepptn preserved
986 message_section_title "Composing a list for deinstallation of obsolete and leaf packages"
987 reqptn_leaf=${DBDIR}/leaf_ports.requirements_of_unselected
988 reqptn_obs=${DBDIR}/obsolete_ports.requirements_of_unselected
989 leaf_selected_src=${DBDIR}/leaf_ports_to_delete.selected
990 leaf_selected=${DBDIR}/leaf_ports_to_delete
991 obs_selected_src=${DBDIR}/obsolete_ports_to_delete.selected
992 obs_selected=${DBDIR}/obsolete_ports_to_delete
993 grepptn=${DBDIR}/ports_to_delete.grep_pattern
994 grepptn_col1=${DBDIR}/ports_to_delete.grep_pattern_col1
995 preserved=${TMPDIR}/LIST_DEINST_PKGS::preserved
996 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ]
998 cat "$reqptn_leaf" "$reqptn_obs" 2> /dev/null | sort -u > $grepptn
999 grep -v -Fx -f "$grepptn" "$leaf_selected_src" 2> /dev/null \
1000 | database_query_add_initial_origins > $leaf_selected || :
1001 cat "$obs_selected" "$leaf_selected" 2> /dev/null || :
1003 rm -f "$leaf_selected"
1004 cat "$obs_selected" 2> /dev/null
1005 fi | sort -u > ${DBDIR}/stage.loop_list/ports_to_delete
1006 str_escape_regexp_filter < ${DBDIR}/stage.loop_list/ports_to_delete \
1007 | sed 's/^/^/;s/$/[[:space:]]/' > $grepptn_col1
1008 cat "${DBDIR}/leaf_ports.with_ini" "${DBDIR}/obsolete_ports" 2> /dev/null \
1009 | grep -Fx -v -f "${DBDIR}/stage.loop_list/ports_to_delete" > ${DBDIR}/stage.loop_list/ports_to_restore 2> /dev/null || :
1010 if [ $opt_batch_mode = no ]
1012 if [ ! -e "${DBDIR}/inspected_ports_only_partially" ] && \
1013 grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$leaf_selected_src" > $preserved 2> /dev/null
1015 message_echo "INFO: Following leaf ports are preserved because required by other preserved leaf/obsolete ports."
1016 message_echo "----------------"
1019 pkgtag=`cat "${DBDIR}/moved_from/$origin/pkgtag" 2> /dev/null` || :
1022 echo "$origin" "($pkgtag)"
1027 message_echo "----------------"
1029 if grep -v -Fx -f "${DBDIR}/stage.loop_list/ports_to_delete" "$obs_selected_src" > $preserved 2> /dev/null
1031 message_echo "INFO: Following obsolete ports are preserved because required by other obsolete ports."
1032 message_echo "----------------"
1035 pkgtag=`cat "${DBDIR}/initial/$origin/installed_version" 2> /dev/null` || :
1038 echo "$origin" "($pkgtag)"
1043 message_echo "----------------"
1048 program_exec_and_record_completion LIST_DEINST_PKGS
1051 # ============= Collect entire distfiles list =============
1052 command_do_collect_entire_distfiles_list ()
1054 local PROGRAM_DEPENDS
1055 if [ $opt_inspect_entire_distinfo = yes ]
1058 _program_exec_and_record_completion__operation ()
1060 message_section_title "Collecting entire distfiles list"
1061 find "${PORTSDIR}" -depth 3 -name distinfo -exec cat {} \; \
1062 | grep '^SHA256 ' | sed -E 's/^SHA256 \(([^)]*)\).*/\1/' \
1063 | sort -u > ${DBDIR}/distfiles.entire.tmp
1064 mv "${DBDIR}/distfiles.entire.tmp" "${DBDIR}/distfiles.entire"
1067 program_exec_and_record_completion COLLECT_ALL_DISTFILES_LIST
1071 # ============= Inspection of all required distfiles =============
1072 command_do_inspection_of_all_required_distfiles ()
1074 local PROGRAM_DEPENDS
1075 PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES COLLECT_ALL_DISTFILES_LIST'
1076 _program_exec_and_record_completion__operation ()
1078 message_section_title "Summarizing distfiles list"
1080 cat "${DBDIR}/distfiles.entire" || :
1081 cat "${DBDIR}/distfiles.inspected" || :
1082 } 2> /dev/null | sort -u | str_escape_regexp_filter \
1083 | sed 's|^|^\\.\\/|; s|$|$|' > ${DBDIR}/distfiles.grep.pattern || :
1086 program_exec_and_record_completion DISTFILES_LIST
1089 # ============= Clean up of reinstallation status for preparation =============
1090 command_do_clean_up_of_reinstallation_status_for_preparation ()
1092 local PROGRAM_DEPENDS
1093 PROGRAM_DEPENDS='REDO_INIT INSPECT_ALL_DEPENDENCIES'
1094 _program_exec_and_record_completion__operation ()
1096 message_section_title "Cleaning up of reinstallation status for preparation"
1097 rm -rf "${DBDIR}/status.ports"
1100 program_exec_and_record_completion CLEANUP_REINST_STATUS
1103 # ============= Completion of building the temporary database =============
1104 command_do_completion_of_building_the_temporary_database ()
1106 local PROGRAM_DEPENDS
1107 PROGRAM_DEPENDS='REDO_INIT SETUP_REINST_TODO CLEANUP_REINST_STATUS PARSE_CONF INSPECT_ALL_DEPENDENCIES RESTORE_ESCAPED_OBSOLETE_PACKAGES_FOR_INSPECTION NECESSARY_UPDATES:direct NECESSARY_UPDATES:full PARSE_TARGET_ATTR_INFO MAKE_DEPENDENTS_LISTS_UNIQUE MAKE_IGNORED_DEPENDENTS_LISTS_UNIQUE COLLECT_LEAF_PORTS_TO_DELETE'
1108 _program_exec_and_record_completion__operation ()
1110 message_section_title "The temporary database is completely built up"
1113 program_exec_and_record_completion PREPARATION
1116 # ============= End of do/redo prepare =============
1117 command_do_end_at_prepare_complete ()
1120 tmp_msg=${TMPDIR}/command_do_end_at_prepare_complete:msg
1121 cat > "$tmp_msg" << eof
1122 Done (skipped reinstallation) at `message_timestamp`
1124 You can restart this process from the aborted/terminated point by executing without options or arguments as:
1127 message_cat "$tmp_msg"
1128 temp_terminate_process () { :; }
1131 # ============= Reinstallation of remained ports =============
1132 command_do_reinstallation_of_remained_ports ()
1134 local PROGRAM_DEPENDS
1135 PROGRAM_DEPENDS='PREPARATION'
1136 _program_exec_restartable_loop_operation__routine ()
1139 temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
1141 _program_exec_and_record_completion__operation ()
1143 local _MSG_CURRENT_STAGE_general
1144 _MSG_CURRENT_STAGE_general="reinstallation"
1145 temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
1146 message_section_title "Reinstallation"
1147 program_exec_restartable_loop_operation reinst_todo
1148 [ "x$PROGRAM_STEP_COUNTER_LAST_SKIPPED" = xyes ] && message_stage_title "$PROGRAM_STEP_COUNTER"
1149 reinstall_restore_conflicts
1150 temp_set_msg_current_stage
1153 program_exec_and_record_completion REINSTALLATION
1156 # ============= Restoration of obsolete and leaf packages which have been deinstalled but unselected from the deletion list again =============
1157 command_do_restore_needed_obsolete_and_leaf_packages ()
1159 local PROGRAM_DEPENDS
1160 PROGRAM_DEPENDS='REDO_INIT LIST_DEINST_PKGS'
1161 _program_exec_restartable_loop_operation__routine ()
1163 deinstall_restore "$@"
1165 _program_exec_and_record_completion__operation ()
1167 local _MSG_CURRENT_STAGE_general
1168 _MSG_CURRENT_STAGE_general="restoration of unselected obsolete/leaf packages"
1169 temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
1170 message_section_title "Restoration of unselected obsolete/leaf packages"
1171 program_exec_restartable_loop_operation ports_to_restore
1172 [ "x$PROGRAM_STEP_COUNTER_LAST_SKIPPED" = xyes ] && message_stage_title "$PROGRAM_STEP_COUNTER"
1173 temp_set_msg_current_stage
1176 program_exec_and_record_completion RESTORE_ONCE_DEINST_PKGS
1179 # ============= Deinstallation of unused obsolete and leaf packages =============
1180 command_do_deinstallation_of_unused_obsolete_and_leaf_packages ()
1182 local PROGRAM_DEPENDS
1183 PROGRAM_DEPENDS='REDO_INIT LIST_DEINST_PKGS'
1184 _program_exec_restartable_loop_operation__routine ()
1188 _program_exec_and_record_completion__operation ()
1190 local _MSG_CURRENT_STAGE_general
1191 _MSG_CURRENT_STAGE_general="deinstallation of obsolete/leaf packages"
1192 temp_set_msg_current_stage "${_MSG_CURRENT_STAGE_general}"
1193 message_section_title "Deinstallation of unused obsolete/leaf packages"
1194 program_exec_restartable_loop_operation ports_to_delete
1195 [ "x$PROGRAM_STEP_COUNTER_LAST_SKIPPED" = xyes ] && message_stage_title "$PROGRAM_STEP_COUNTER"
1196 temp_set_msg_current_stage
1199 program_exec_and_record_completion DEINST_UNUSED_PKGS
1202 # ============= Clean up obsolete or unused distfiles =============
1203 command_do_clean_up_obsolete_or_unused_distfiles ()
1205 local PROGRAM_DEPENDS
1206 if [ $opt_only_target_scope = no -a $opt_keep_distfiles = no ]
1208 PROGRAM_DEPENDS='REINSTALLATION DISTFILES_LIST'
1209 _program_exec_and_record_completion__operation ()
1211 local tmp_distfiles_exists
1212 message_section_title "Cleaning up obsolete or unused distfiles"
1213 tmp_distfiles_exists=${TMPDIR}/CLEANUP_OBSLETE_DISTFILES::distfiles_exists
1214 [ $opt_dry_run = yes ] && message_echo "INFO: The operations are not actually carried out."
1215 ( set -e; cd "${DISTDIR}" && find . -type f ) \
1216 | sed 's|^\./||' | sort -u > $tmp_distfiles_exists
1217 fileedit_manipulate_old_lines "$tmp_distfiles_exists" "${DBDIR}/distfiles.entire" \
1218 | while read distfile
1220 if [ $opt_batch_mode = no ]
1224 [ $opt_dry_run = yes ] && continue
1225 rm -f "${DISTDIR}/$distfile"
1229 program_exec_and_record_completion CLEANUP_OBSLETE_DISTFILES
1233 # ============= Rebuild of package database =============
1234 command_do_rebuild_of_package_database ()
1236 local PROGRAM_DEPENDS
1237 PROGRAM_DEPENDS='REINSTALLATION RESTORE_ONCE_DEINST_PKGS DEINST_UNUSED_PKGS'
1238 _program_exec_and_record_completion__operation ()
1240 which -s pkgdb || return 0
1241 message_section_title "Rebuilding package database for portupgrade"
1242 if grep -q @ "${DBDIR}/stage.loop_list/reinst_todo"
1244 message_echo "INFO: Skipped because of lacking flavor support."
1250 program_exec_and_record_completion REBUILD_PKGDB
1253 # =============Operation of redo command irrespective of option settings =============
1254 command_do_redo__command_all_exec_irrespective_of_saved_options ()
1256 [ $opt_reload_conf = yes ] || return 0
1257 program_deregister_stage_complete SAVE_PREV_CONF
1258 program_deregister_stage_complete ALL_COMPLETE
1259 rm -f "${DBDIR}"/complete
1262 # ============= Preparation of the temporary database =============
1263 command_do_prepare ()
1265 # Meta process for redo
1266 command_do_meta_process_for_redo
1268 # Determine specified targets
1269 command_do_determine_specified_targets
1271 # Show specified targets
1272 command_do_show_specified_targets
1274 # Determine all target ports
1275 command_do_determine_all_target_ports
1277 # Loop considering cases that port options are changed after inspection
1280 # Prepare for inspecting all dependencies
1281 command_do_prepare_for_inspect_all_dependencies
1283 # Inspection of all dependencies
1284 command_do_inspection_of_all_dependencies
1286 # Convert dependency-lists to actual ones
1287 command_do_convert_dependency_lists_to_actual_ones
1289 # Completion of recursive requirement lists
1290 command_do_completion_of_recursive_requirement_lists
1292 # Trim dependency lists by removing uninspected ports
1293 command_do_trim_dependency_lists_by_removing_uninspected_ports
1295 # Inspection of dependents
1296 command_do_inspection_of_dependents
1298 # End the loop when no change is made on port options after the inspection
1299 command_do_reset_changed_portdb && break
1302 # Remove duplicated lines in dependents lists
1303 command_do_remove_duplicated_lines_in_dependents_lists
1305 # Remove duplicated lines in ignored dependents lists
1306 command_do_remove_duplicated_lines_in_ignored_dependents_lists
1308 # Preparation of target attribute information
1309 command_do_preparation_of_target_attribute_information
1311 # Post-process after the preparation of target attribute information
1312 command_do_post_process_after_the_preparation_of_target_attribute_information
1314 # Build of data on complement to new dependents for target attribute information
1315 command_do_build_of_data_on_complement_to_new_dependents_for_target_attribute_information
1317 # Parse target attribute information
1318 command_do_parse_target_attribute_information
1320 # Inspection of necessity
1321 command_do_inspection_of_necessity
1323 # Inspection of necessary upgrades
1324 command_do_inspection_of_necessary_upgrades
1326 # Preparation for inspection of new leaf ports
1327 command_do_preparation_for_inspection_of_new_leaf_ports
1329 # Inspection of new primary leaf ports
1330 command_do_inspection_of_new_primary_leaf_ports
1332 # Inspection of requirements of new leaf ports
1333 command_do_inspection_of_requirements_of_new_leaf_ports
1335 # Order the ports considering dependencies
1336 command_do_order_the_ports_considering_dependencies
1338 # Selection of removing leaf ports
1339 command_do_selection_of_removing_leaf_ports
1341 # Selection of removing obsolete ports
1342 command_do_selection_of_removing_obsolete_ports
1344 # Collection of leaf ports to delete
1345 command_do_collection_of_leaf_ports_to_delete
1347 # Collection of obsolete ports to delete
1348 command_do_collection_of_obsolete_ports_to_delete
1350 # Set up the list of ports to reinstall
1351 command_do_set_up_the_list_of_ports_to_reinstall
1353 # Composition of a list for deinstallation of obsolete and leaf packages
1354 command_do_composition_of_a_list_for_deinstallation_of_obsolete_and_leaf_packages
1356 # Collect entire distfiles list
1357 command_do_collect_entire_distfiles_list
1359 # Inspection of all required distfiles
1360 command_do_inspection_of_all_required_distfiles
1362 # Clean up of reinstallation status for preparation
1363 command_do_clean_up_of_reinstallation_status_for_preparation
1365 # Completion of building the temporary database
1366 command_do_completion_of_building_the_temporary_database
1369 # ============= Reset the progress of reinstallation for retrial =============
1370 command_do_reset_for_reinst_retrial ()
1372 program_deregister_stage_complete REINSTALLATION
1373 program_deregister_stage_complete RESTORE_ONCE_DEINST_PKGS
1374 program_deregister_stage_complete DEINST_UNUSED_PKGS
1375 rm -rf "${DBDIR}/status.ports" "${DBDIR}/new_success_in_current_run"
1378 # ============= Main operation of do/redo =============
1382 # Reset termination messages
1383 temp_reset_termination_messages_common
1388 if [ $ntrial -gt 0 ]
1390 message_echo "########## RETRIAL ($ntrial) OF (RE)INSTALLATION ##########"
1394 if [ $opt_fetch_only = yes ]
1396 # Reinstallation of remained ports
1397 command_do_reinstallation_of_remained_ports
1399 message_echo "Completed the fetch only mode."
1401 elif [ $opt_delete_then_reinstall = no ]
1403 # Reinstallation of remained ports
1404 command_do_reinstallation_of_remained_ports
1406 # Restoration of obsolete and leaf packages which have been deinstalled but unselected from the deletion list again
1407 command_do_restore_needed_obsolete_and_leaf_packages
1409 # Deinstallation of unused obsolete and leaf packages
1410 command_do_deinstallation_of_unused_obsolete_and_leaf_packages
1412 # Deinstallation of unused obsolete and leaf packages
1413 command_do_deinstallation_of_unused_obsolete_and_leaf_packages
1415 # Reinstallation of remained ports
1416 command_do_reinstallation_of_remained_ports
1417 # Restoration of obsolete and leaf packages which have been deinstalled but unselected from the deletion list again
1419 command_do_restore_needed_obsolete_and_leaf_packages
1422 # Clean up obsolete or unused distfiles
1423 command_do_clean_up_obsolete_or_unused_distfiles
1425 # Rebuild of package database
1426 command_do_rebuild_of_package_database
1428 # Retry if incomplete
1429 command_do_is_everything_resolved && break
1430 database_query_is_any_progress || break
1431 command_do_reset_for_reinst_retrial
1432 ntrial=$(($ntrial+1))
1437 # ============= Check whether everything is resolved =============
1438 command_do_is_everything_resolved ()
1441 for subject in failure redo conflict
1443 database_query_show_single_list_exec "$subject" \
1444 `options_get_dependency_type` `options_get_dependency_level` > /dev/null 2> /dev/null && return 1
1449 # ============= Notice of failures =============
1450 command_do_failure_notice ()
1452 local exists_unresolved_ports
1453 exists_unresolved_ports=
1454 message_summary_dependents_of_failed_reinstallation failure || exists_unresolved_ports=y
1455 message_summary_dependents_of_failed_reinstallation redo || exists_unresolved_ports=y
1456 message_summary_dependents_of_failed_reinstallation conflict || exists_unresolved_ports=y
1457 [ "x$exists_unresolved_ports" = xy ] || return 0
1458 message_summary_advice_on_manual_solution
1462 # ============= Ending process =============
1463 command_do_ending_process ()
1465 local PROGRAM_DEPENDS
1466 temp_terminate_process () { :; }
1467 if command_do_failure_notice
1469 if [ $opt_no_opening_message = yes ]
1471 message_echo "Done as ${APPNAME}"
1473 message_section_title "COMPLETELY DONE"
1475 if [ $opt_fetch_only = no -a $opt_dry_run = no ]
1477 PROGRAM_DEPENDS='REBUILD_PKGDB CLEANUP_OBSLETE_DISTFILES '
1478 _program_exec_and_record_completion__operation ()
1481 program_exec_and_record_completion ALL_COMPLETE
1482 [ $opt_no_opening_message = yes ] || message_echo "- E N D -"
1484 message_echo "INFO: Redo for the real (re)installation."
1487 message_warn_no_achieved_progress
1488 message_section_title "Done with some unresolved problems"
1489 message_echo "- To be continued -"