summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-03-12 01:21:39 +0000
committerLyndon Brown <jnqnfe@gmail.com>2020-03-17 18:57:02 +0000
commit04d9ee0211e7cf2d5f637941ff6579b4f5462da6 (patch)
tree17d1ccea5c085c5afd62361d2fe97a14c951cb9b /functions
parentbea349c82237ee165baaf1f7e8043a26e0c14417 (diff)
downloadvyos-live-build-04d9ee0211e7cf2d5f637941ff6579b4f5462da6.tar.gz
vyos-live-build-04d9ee0211e7cf2d5f637941ff6579b4f5462da6.zip
stagefiles: simplify & robustify
- avoid all need to pass ".build/" path in stage file names into the functions - add a helper to remove a stage file (required to complete the above properly) - avoid duplicating filenames within scripts which makes them prone to mistakes (some instances of which I've actually encountered and had to fix) Gbp-Dch: Short
Diffstat (limited to 'functions')
-rwxr-xr-xfunctions/stagefile.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/functions/stagefile.sh b/functions/stagefile.sh
index 9ef4789c9..f51144bd3 100755
--- a/functions/stagefile.sh
+++ b/functions/stagefile.sh
@@ -11,8 +11,8 @@
Check_stagefile ()
{
- FILE="${1}"
- NAME="$(basename ${1})"
+ FILE=".build/${1}"
+ NAME="$(basename ${FILE})"
# Checking stage file
if [ -f "${FILE}" ]
@@ -32,8 +32,8 @@ Check_stagefile ()
Create_stagefile ()
{
- FILE="${1}"
- DIRECTORY="$(dirname ${1})"
+ FILE=".build/${1}"
+ DIRECTORY="$(dirname ${FILE})"
# Creating stage directory
mkdir -p "${DIRECTORY}"
@@ -42,6 +42,11 @@ Create_stagefile ()
touch "${FILE}"
}
+Remove_stagefile ()
+{
+ rm -f ".build/${1}"
+}
+
Require_stagefile ()
{
local NAME
@@ -55,6 +60,7 @@ Require_stagefile ()
local CONTINUE=false
for FILE in ${FILES}
do
+ FILE=".build/${FILE}"
# Find at least one of the required stages
if [ -f ${FILE} ]
then