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 diff --git a/scripts/build/chroot_prep b/scripts/build/chroot_prep index f9ebdea5f..b62bbb0fa 100755 --- a/scripts/build/chroot_prep +++ b/scripts/build/chroot_prep @@ -94,7 +94,7 @@ if In_list "archives" ${HELPERS} && [ -z "${ARCHIVES_PASS}" ]; then exit 1 fi -if In_list "archives" ${HELPERS} && [ ! -e .build/bootstrap ]; then +if In_list "archives" ${HELPERS} && ! Stagefile_exists bootstrap; then Echo_warning "The 'archives' helper is selected, but the bootstrap stage has not completed." fi diff --git a/scripts/build/clean b/scripts/build/clean index b8e613f7f..32a198399 100755 --- a/scripts/build/clean +++ b/scripts/build/clean @@ -46,6 +46,8 @@ else ARGUMENTS="${@}" fi +STAGEFILES_DIR="$(Stagefiles_dir)" + for ARGUMENT in ${ARGUMENTS} do case "${ARGUMENT}" in @@ -85,7 +87,7 @@ do rm -f chroot.packages.live chroot.packages.install rm -f chroot.files - rm -f .build/chroot* + rm -f "${STAGEFILES_DIR}"/chroot* ;; --binary) @@ -104,7 +106,7 @@ do rm -rf binary rm -rf tftpboot - rm -f .build/binary* + rm -f "${STAGEFILES_DIR}"/binary* ;; --remove) @@ -118,12 +120,12 @@ do if [ -e auto/config ] then - rm -f .build/config + Remove_stagefile config fi ;; --stage) - rm -rf .build/* + rm -rf "${STAGEFILES_DIR}"/* ;; --source) @@ -136,7 +138,7 @@ do rm -rf source - rm -f .build/source* + rm -f "${STAGEFILES_DIR}"/source* ;; -h|--help) diff --git a/scripts/build/config b/scripts/build/config index dc79d08f9..3a79c9f88 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -871,7 +871,7 @@ fi # Ignoring --config if CWD already has a config # Only print warning from direct execution, not when run from auto script redirection, to avoid repetition -if [ -e .build/config ] && [ -n "${_CONFIG}" ] +if Stagefile_exists && [ -n "${_CONFIG}" ] then if [ "${1}" != "noauto" ] then