diff options
author | Lyndon Brown <jnqnfe@gmail.com> | 2020-03-13 17:11:53 +0000 |
---|---|---|
committer | Lyndon Brown <jnqnfe@gmail.com> | 2020-03-17 18:57:02 +0000 |
commit | fe9195b59c9647598ecea00900edfe2678bddcac (patch) | |
tree | 91e0a0e756cabb781035d58371b5b78590dc1568 /functions | |
parent | 04d9ee0211e7cf2d5f637941ff6579b4f5462da6 (diff) | |
download | vyos-live-build-fe9195b59c9647598ecea00900edfe2678bddcac.tar.gz vyos-live-build-fe9195b59c9647598ecea00900edfe2678bddcac.zip |
stagefiles: further robustify with auto filenames
as suggested by Raphaƫl
rather than have fixed stagefile filename strings at all in the scripts,
use `$(basename $0)` to use the name of the script (which is the same for
almost all cases anyway, and the stage files are supposed to be almost
exclusively unique per-script). we can thus simplify things by determining
the filename for most use cases within the functions themselves.
this does change the file used by a couple of scripts, affecting backwards
compatibility of executing live-build upon an existing partially or fully
completed build:
- binary_grub-pc used "binary_grub"
- chroot_includes used "includes.chroot"
care had to be taken for the following cases:
- there are some cases like bootstrap_cache, source_debian and
bootstrap_debootstrap which are dealing with more than one file, and/or
otherwise a filename that is not specific to the script itself exactly,
or should not be based upon its name.
- some cases like chroot_cache, bootstrap_cache and
chroot_install-packages need to append something to the end of the name
depending upon which pass/action mode the script is being executed with.
- furthermore in the bootstrap_cache case one of the filenames is used
within the bootstrap_debootstrap and thus needs very careful handling
to be certain that a change in filename of bootstrap_cache does not
break bootstrap_debootstrap.
Gbp-Dch: Short
Diffstat (limited to 'functions')
-rwxr-xr-x | functions/stagefile.sh | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/functions/stagefile.sh b/functions/stagefile.sh index f51144bd3..6f9e8cc8b 100755 --- a/functions/stagefile.sh +++ b/functions/stagefile.sh @@ -9,9 +9,21 @@ ## under certain conditions; see COPYING for details. +# 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 () +{ + local SUFFIX="${1}" + local FILENAME + FILENAME="$(basename $0)" + echo ${FILENAME}${SUFFIX:+.$SUFFIX} +} + Check_stagefile () { - FILE=".build/${1}" + local FILE + local NAME + FILE=".build/${1:-$(Stagefile_name)}" NAME="$(basename ${FILE})" # Checking stage file @@ -32,7 +44,9 @@ Check_stagefile () Create_stagefile () { - FILE=".build/${1}" + local FILE + local DIRECTORY + FILE=".build/${1:-$(Stagefile_name)}" DIRECTORY="$(dirname ${FILE})" # Creating stage directory @@ -44,7 +58,9 @@ Create_stagefile () Remove_stagefile () { - rm -f ".build/${1}" + local FILE + FILE=".build/${1:-$(Stagefile_name)}" + rm -f "${FILE}" } Require_stagefile () |