From 38a5aed0dcdf71f43cecfadc6e34c659408b6a00 Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Sun, 5 Apr 2020 17:29:31 +0100 Subject: chroot_prep: expand coverage it now covers: - `lb chroot_apt install-binary` - `lb chroot_archives {chroot|binary|source} {install|remove}` by expanding usage from: `lb chroot_prep {install|remove} HELPERS [ARGS]` to: `lb chroot_prep {install|remove} HELPERS [MODE[ MODE..]] [ARGS]` where `[MODE[ MODE..]]` is an optional set of one or more of: - archives-chroot, which specifies to use 'chroot' as the first param to the chroot_archives script - archives-binary, which specifies to use 'binary' - archives-source, which specifies to use 'source' - apt-install-binary, which specified to pass 'install-binary' instead of 'install' to chroot_apt thus _all_ chroot prep scripts can be run through this helper now! note, in the case of the binary stage, 'archives' is deliberately not added to CHROOT_PREP_OTHER, this is not a mistake! Gbp-Dch: Short --- scripts/build/chroot_prep | 72 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 12 deletions(-) (limited to 'scripts/build/chroot_prep') diff --git a/scripts/build/chroot_prep b/scripts/build/chroot_prep index 8bb456b8b..3fac53852 100755 --- a/scripts/build/chroot_prep +++ b/scripts/build/chroot_prep @@ -15,7 +15,7 @@ set -e # Setting static variables DESCRIPTION="Prep chroot" -USAGE="${PROGRAM} {install|remove} {all|\"HELPERS\"} [--force]" +USAGE="${PROGRAM} {install|remove} {all|all-except-archives|\"HELPERS\"} [MODE[ MODE..]] [--force]" # Processing arguments and configuration files Init_config_data "${@}" @@ -37,22 +37,60 @@ if [ -z "${HELPERS}" ]; then exit 1 fi -if [ "${HELPERS}" = "all" ]; then - # Use default set of all helpers (except chroot_archives which cannot be supported due to different parameter needs) - HELPERS="devpts proc selinuxfs sysfs debianchroot dpkg tmpfs sysv-rc hosts resolv hostname apt" -else - # Support both comma and space separation - # Support with and without 'chroot_' script filename prefix - HELPERS="$(echo "${HELPERS}" | sed -e 's|,| |g' -e 's|^chroot_||g')" -fi +ARCHIVES_PASS="" +APT_ACTION="${ACTION}" + +MODES="mode-archives-chroot \ + mode-archives-binary \ + mode-archives-source \ + mode-apt-install-binary" + +while In_list "${1}" $MODES; do + case "${1}" in + mode-archives-chroot) + ARCHIVES_PASS="chroot" + ;; + mode-archives-binary) + ARCHIVES_PASS="binary" + ;; + mode-archives-source) + ARCHIVES_PASS="source" + ;; + mode-apt-install-binary) + APT_ACTION="install-binary" + ;; + *) + Echo_error "Internal failure, case not covered" + exit 1 + ;; + esac + shift +done + +# Default set, EXCLUDING 'archives' +DEFAULT_HELPERS="devpts proc selinuxfs sysfs debianchroot dpkg tmpfs sysv-rc hosts resolv hostname apt" + +case "${HELPERS}" in + all) + HELPERS="${DEFAULT_HELPERS} archives" + ;; + all-except-archives) + HELPERS="${DEFAULT_HELPERS}" + ;; + *) + # Support both comma and space separation + # Support with and without 'chroot_' script filename prefix + HELPERS="$(echo "${HELPERS}" | sed -e 's|,| |g' -e 's|^chroot_||g')" + ;; +esac if In_list "prep" ${HELPERS}; then Echo_error "Recursive!" exit 1 fi -if In_list "archives" ${HELPERS}; then - Echo_error "The chroot_archives helper cannot be used through chroot_prep!" +if In_list "archives" ${HELPERS} && [ -z "${ARCHIVES_PASS}" ]; then + Echo_error "Use of the archives component through chroot_prep requires specifying a mode-archives-* mode" exit 1 fi @@ -65,5 +103,15 @@ if [ "${_ACTION}" = "remove" ]; then fi for HELPER in $HELPERS; do - lb "chroot_${HELPER}" "${ACTION}" "${@}" + case "${HELPER}" in + archives) + lb "chroot_${HELPER}" "${ARCHIVES_PASS}" "${ACTION}" "${@}" + ;; + apt) + lb "chroot_${HELPER}" "${APT_ACTION}" "${@}" + ;; + *) + lb "chroot_${HELPER}" "${ACTION}" "${@}" + ;; + esac done -- cgit v1.2.3