OSDN Git Service

Fixed a bug that obsolete or moved ports were not inspected. For this purpose, the...
[portsreinstall/current.git] / lib / chroot / libdatabase_maintain.sh
1 #!/bin/sh -e
2 # ==============================================================================
3 # portsreinstall-chroot library script
4 # Overlay onto lib/libdatabase_maintain.sh for portsreinstall-chroot
5 # - Operations on the temporary database -
6 # Copyright (C) 2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
7 # This software is distributed under the 2-Clause BSD License.
8 # ==============================================================================
9
10 # ============= Destroy the builder chroot environment by preserving the option setting =============
11 database_maintain_destroy ()
12 {
13         message_echo "Starting to clean up the builder chroot environment..."
14         program_deregister_stage_complete CLEANUP_GUEST
15         fs_destroy
16         message_echo "Starting to reset the temporary database by preserving the option setting..."
17         find "${DBDIR}" -depth 1 -maxdepth 1 \
18                 -not \( -name saved_options.sh \
19                         -or -name MYVERSION -or -name .lock \) \
20                 -exec rm -rf {} \; 2> /dev/null || :
21         touch "${DBDIR}/MYVERSION"
22 }
23
24 # ============= Destroy the builder chroot environment and clean up the temporary database =============
25 database_maintain_clean ()
26 {
27         message_echo "Starting to clean up the builder chroot environment..."
28         fs_destroy
29         message_echo "Starting to clean up the temporary database..."
30         command_exec_without_pkgtools__notify_reset_options
31         rm -rf "${DBDIR}"
32 }
33
34 # ============= Forcibly destroy the builder chroot environment and clean up the temporary database =============
35 database_maintain_clean_force ()
36 {
37         [ -e "${DBDIR}/saved_options.sh" ] && . "${DBDIR}/saved_options.sh"
38         database_maintain_clean
39 }