summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-05-02 14:49:45 +0100
committerLyndon Brown <jnqnfe@gmail.com>2020-05-02 14:49:45 +0100
commit2d7ff4934d721f38ac5274c866e44e20d3bda2e8 (patch)
treeceff49ad2a9dc8496207102412a0195aae867f3b /functions
parentb20979334cc28c345b2b72da30c3591fb5c85882 (diff)
downloadvyos-live-build-2d7ff4934d721f38ac5274c866e44e20d3bda2e8.tar.gz
vyos-live-build-2d7ff4934d721f38ac5274c866e44e20d3bda2e8.zip
improve stagefiles encapsulation
- added and used Stagefiles_dir() - added and used Stagefile_exists() pretty self explanatory. Gbp-Dch: Short
Diffstat (limited to 'functions')
-rwxr-xr-xfunctions/exit.sh14
-rwxr-xr-xfunctions/init.sh2
-rwxr-xr-xfunctions/stagefile.sh13
3 files changed, 22 insertions, 7 deletions
diff --git a/functions/exit.sh b/functions/exit.sh
index 32340a481..675afa2de 100755
--- a/functions/exit.sh
+++ b/functions/exit.sh
@@ -21,7 +21,7 @@ Exit ()
# Skip if we have not yet completed the initial bootstrapping (bootstrap_debootstrap)
# (nothing to be done; avoids unhelpful messages)
- if [ ! -e .build/bootstrap ]; then
+ if ! Stagefile_exists bootstrap; then
return ${VALUE}
fi
@@ -43,10 +43,12 @@ Exit ()
done
fi
- rm -f .build/chroot_devpts
- rm -f .build/chroot_proc
- rm -f .build/chroot_selinuxfs
- rm -f .build/chroot_sysfs
+ STAGEFILES_DIR="$(Stagefiles_dir)"
+
+ rm -f "${STAGEFILES_DIR}"/chroot_devpts
+ rm -f "${STAGEFILES_DIR}"/chroot_proc
+ rm -f "${STAGEFILES_DIR}"/chroot_selinuxfs
+ rm -f "${STAGEFILES_DIR}"/chroot_sysfs
Echo_message "Saving caches..."
@@ -54,7 +56,7 @@ Exit ()
# but let's assume that if there's any binary stage file arround
# we are in binary stage.
- if ls .build/binary* > /dev/null 2>&1
+ if ls "${STAGEFILES_DIR}"/binary* > /dev/null 2>&1
then
Save_package_cache binary
else
diff --git a/functions/init.sh b/functions/init.sh
index d39bf1b5a..708e3d275 100755
--- a/functions/init.sh
+++ b/functions/init.sh
@@ -12,7 +12,7 @@
Auto_build_config ()
{
# Automatically build config
- if [ -x auto/config ] && [ ! -e .build/config ]; then
+ if [ -x auto/config ] && ! Stagefile_exists config; then
Echo_message "Automatically populating config tree."
lb config
fi
diff --git a/functions/stagefile.sh b/functions/stagefile.sh
index 384aaec2d..8d9281415 100755
--- a/functions/stagefile.sh
+++ b/functions/stagefile.sh
@@ -9,6 +9,11 @@
## under certain conditions; see COPYING for details.
+Stagefiles_dir ()
+{
+ echo ".build"
+}
+
# Get the default filename for a script's stagefile (the name of the script
# file itself). A suffix can be appended via providing as a param.
Stagefile_name ()
@@ -19,6 +24,14 @@ Stagefile_name ()
echo ${FILENAME}${SUFFIX:+.$SUFFIX}
}
+Stagefile_exists ()
+{
+ if [ -f ".build/${1:-$(Stagefile_name)}" ]; then
+ return 0
+ fi
+ return 1
+}
+
Check_stagefile ()
{
local FILE