2 # ==============================================================================
3 # portsreinstall library script
4 # - "forget" 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 forget command =============
12 message_echo "The temporary database is trying to forget about the specified ports as much as possible."
13 message_echo "Concretely, the data on each of the specified ports and their requirements/dependents is removed unless initially installed or required by other preserved ports."
16 # Preparation for inspection of the specified ports
18 _program_exec_and_record_completion__operation ()
20 message_section_title "Preparation for inspection of the specified ports"
21 rm -rf "${DBDIR}/forget"
22 mkdir "${DBDIR}/forget"
23 for list in masters remove_scope
25 rm -f "${DBDIR}/stage.loop_list/forget_$list"*
29 program_exec_and_record_completion FORGET::PREPARATION_INSPECT_MASTER
31 # (Re)initialization of the specified ports to inspect
32 pkgsys_eval_ports_glob "$@" > ${DBDIR}/stage.loop_list/forget_masters
34 # Inspection of the specified ports
35 PROGRAM_DEPENDS='FORGET::PREPARATION_INSPECT_MASTER'
36 _program_exec_restartable_loop_operation__routine ()
38 local origin origins_init
40 origins_init=`database_query_initial_orgins "$origin"`
41 if [ -z "$origins_init" \
42 -a `cat "${DBDIR}/requires/$origin/dependents.all.full" 2> /dev/null | wc -l` -eq 0 ]
44 message_echo "$origin"
45 echo "$origin" >> ${DBDIR}/forget/remove.master
46 cat "${DBDIR}/requires/$origin/requirements.all.full" \
47 2> /dev/null >> ${DBDIR}/forget/remove.scope || :
48 database_build_forget "$origin"
51 _program_exec_and_record_completion__operation ()
53 message_section_title "Inspection of the specified ports"
54 message_echo "----------------"
55 program_exec_restartable_loop_operation forget_masters
56 message_echo "----------------"
57 cat "${DBDIR}/forget/remove.scope" 2> /dev/null \
58 | sort -u > ${DBDIR}/forget/remove.scope.tmp
59 mv "${DBDIR}/forget/remove.scope.tmp" "${DBDIR}/forget/remove.scope"
61 cat "${DBDIR}/forget/remove.master" || :
62 cat "${DBDIR}/forget/remove.scope" || :
63 } 2> /dev/null | sort -u > ${DBDIR}/forget/remove.scope.filter
64 ln -f "${DBDIR}/forget/remove.scope" "${DBDIR}/stage.loop_list/forget_remove_scope"
67 program_exec_and_record_completion FORGET::INSPECT_MASTER
69 # Inspection of the requirements of the specified ports to remove
70 PROGRAM_DEPENDS='FORGET::INSPECT_MASTER'
71 _program_exec_restartable_loop_operation__routine ()
73 local origin origins_init
75 origins_init=`database_query_initial_orgins "$origin"`
76 if [ -z "$origins_init" ] \
77 && ! grep -qv -Fx -f "${DBDIR}/forget/remove.scope.filter" \
78 "${DBDIR}/requires/$origin/dependents.all.full" \
81 message_echo "$origin"
82 database_build_forget "$origin"
83 echo "$origin" >> ${DBDIR}/forget/remove
86 _program_exec_and_record_completion__operation ()
88 message_section_title "Inspection of the requirements of the specified ports to remove"
89 message_echo "----------------"
90 program_exec_restartable_loop_operation forget_remove_scope
91 message_echo "----------------"
93 cat "${DBDIR}/forget/remove.master" || :
94 cat "${DBDIR}/forget/remove" || :
95 } 2> /dev/null | sort -u > ${DBDIR}/forget/remove.filter
96 cat "${DBDIR}/inspected_ports.update" 2> /dev/null | sort -u \
97 | grep -v -Fx -f "${DBDIR}/forget/remove.filter" \
98 > ${DBDIR}/inspected_ports.update.tmp 2> /dev/null || :
99 mv "${DBDIR}/inspected_ports.update.tmp" "${DBDIR}/inspected_ports.update"
102 program_exec_and_record_completion FORGET::INSPECT_REQUIREMENTS_OF_REMOVED_PORTS
104 # Set up so that ports are inspected again in the building process of the temporary database
105 program_deregister_stage_complete PREPARE_FOR_INSPECT_ALL_DEPENDENCIES
107 # Clean up the database for this command because it is no more effective
108 program_deregister_stage_complete FORGET::PREPARATION_INSPECT_MASTER
110 # Invalidate the completion
111 program_deregister_stage_complete ALL_COMPLETE