From fe9195b59c9647598ecea00900edfe2678bddcac Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Fri, 13 Mar 2020 17:11:53 +0000 Subject: stagefiles: further robustify with auto filenames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/build/bootstrap_cache | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scripts/build/bootstrap_cache') diff --git a/scripts/build/bootstrap_cache b/scripts/build/bootstrap_cache index b80e6661a..8cbf30536 100755 --- a/scripts/build/bootstrap_cache +++ b/scripts/build/bootstrap_cache @@ -29,13 +29,16 @@ then exit 0 fi +_ACTION="${1}" +shift + +# Set non-default stage file name (auto picked up by the functions) # Note, this (plus the applicable extension added below) must match that used in `bootstrap_debootstrap` -STAGE_FILE="bootstrap_cache" +STAGE_FILE="bootstrap_cache.${_ACTION}" -case "${1}" in +case "${_ACTION}" in restore) # Checking stage file - STAGE_FILE="${STAGE_FILE}.restore" Check_stagefile "${STAGE_FILE}" if [ -d cache/bootstrap ] @@ -53,7 +56,7 @@ case "${1}" in # Creating stage file Create_stagefile "${STAGE_FILE}" - Create_stagefile bootstrap + Create_stagefile "bootstrap" exit 0 fi @@ -63,7 +66,6 @@ case "${1}" in Echo_message "Saving bootstrap stage to cache..." # Checking stage file - STAGE_FILE="${STAGE_FILE}.save" Check_stagefile "${STAGE_FILE}" # Acquire lock file -- cgit v1.2.3