summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-04-02 20:23:57 +0100
committerLyndon Brown <jnqnfe@gmail.com>2020-04-23 18:26:15 +0100
commitd79c96232b40fb082233c97ac8d4f75b821ecefe (patch)
tree0d14ed516433176a321b72cf53fb25981720ac1d /functions
parent500f2050739e8cb902d710d1ae6b3f5de4d00dcd (diff)
downloadvyos-live-build-d79c96232b40fb082233c97ac8d4f75b821ecefe.tar.gz
vyos-live-build-d79c96232b40fb082233c97ac8d4f75b821ecefe.zip
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
Diffstat (limited to 'functions')
-rwxr-xr-xfunctions/stagefile.sh27
1 files changed, 23 insertions, 4 deletions
diff --git a/functions/stagefile.sh b/functions/stagefile.sh
index 3c3468851..3108a7058 100755
--- a/functions/stagefile.sh
+++ b/functions/stagefile.sh
@@ -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