stagefiles: guard unnecessary chroot removal

just as most scripts are skipped if their stagefile exists (indicating
that they have already been run to completion), including chroot
preparation scripts in install mode, this implements the same guard for
chroot prep remove mode, such that they exit early if their stagefile
does not exist, indicating that the modification has already been removed.
(also override-able by --force in the same way).

this basically just uses a tweaked copy of Check_stagefile().

Gbp-Dch: Short
This commit is contained in:
Lyndon Brown 2020-04-02 20:23:57 +01:00
parent 500f205073
commit d79c96232b
13 changed files with 59 additions and 4 deletions

View File

@ -27,10 +27,8 @@ Check_stagefile ()
NAME="$(basename ${FILE})"
# Checking stage file
if [ -f "${FILE}" ]
then
if [ "${_FORCE}" != "true" ]
then
if [ -f "${FILE}" ]; then
if [ "${_FORCE}" != "true" ]; then
# Skip execution
Echo_warning "Skipping %s, already done" "${NAME}"
exit 0
@ -42,6 +40,27 @@ Check_stagefile ()
fi
}
# Used by chroot preperation scripts in removal mode
Ensure_stagefile_exists ()
{
local FILE
local NAME
FILE=".build/${1:-$(Stagefile_name)}"
NAME="$(basename ${FILE})"
# Checking stage file
if [ ! -f "${FILE}" ]; then
if [ "${_FORCE}" != "true" ]; then
# Skip execution
Echo_warning "Skipping removal of %s, it is not applied" "${NAME}"
exit 0
else
# Force execution
Echo_message "Forcing %s" "${NAME}"
fi
fi
}
Create_stagefile ()
{
local FILE

View File

@ -147,6 +147,9 @@ case "${1}" in
remove)
Echo_message "Deconfiguring file /etc/apt/apt.conf"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -50,6 +50,9 @@ case "${1}" in
remove)
Echo_message "Deconfiguring file /etc/debian_chroot"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -47,6 +47,9 @@ case "${1}" in
remove)
Echo_message "Begin unmounting /dev/pts..."
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -60,6 +60,9 @@ EOF
remove)
Echo_message "Deconfiguring file /sbin/start-stop-daemon"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -57,6 +57,9 @@ EOF
remove)
Echo_message "Deconfiguring file /etc/hostname"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -61,6 +61,9 @@ EOF
remove)
Echo_message "Deconfiguring file /etc/hosts"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -47,6 +47,9 @@ case "${1}" in
remove)
Echo_message "Begin unmounting /proc..."
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -64,6 +64,9 @@ case "${1}" in
remove)
Echo_message "Deconfiguring file /etc/resolv.conf"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -50,6 +50,9 @@ case "${1}" in
remove)
Echo_message "Begin unmounting /sys/fs/selinux..."
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -47,6 +47,9 @@ case "${1}" in
remove)
Echo_message "Begin unmounting /sys..."
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -56,6 +56,9 @@ EOF
remove)
Echo_message "Deconfiguring file /usr/sbin/policy-rc.d"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile

View File

@ -52,6 +52,9 @@ case "${1}" in
remove)
Echo_message "Deconfiguring tmpfs for /var/lib/dpkg"
# Checking stage file
Ensure_stagefile_exists
# Acquire lock file
Acquire_lockfile