diff options
author | Lyndon Brown <jnqnfe@gmail.com> | 2020-04-05 17:29:31 +0100 |
---|---|---|
committer | Raphaƫl Hertzog <hertzog@debian.org> | 2020-04-23 09:38:02 +0000 |
commit | 38a5aed0dcdf71f43cecfadc6e34c659408b6a00 (patch) | |
tree | 48793210c32b970f78cf4561d3ca23369344fe19 /scripts | |
parent | 1f63c620f0abdf08188975d083d5f11bebfd2433 (diff) | |
download | vyos-live-build-38a5aed0dcdf71f43cecfadc6e34c659408b6a00.tar.gz vyos-live-build-38a5aed0dcdf71f43cecfadc6e34c659408b6a00.zip |
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
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build/binary | 17 | ||||
-rwxr-xr-x | scripts/build/bootstrap | 4 | ||||
-rwxr-xr-x | scripts/build/chroot | 6 | ||||
-rwxr-xr-x | scripts/build/chroot_prep | 72 | ||||
-rwxr-xr-x | scripts/build/installer | 6 | ||||
-rwxr-xr-x | scripts/build/source | 8 |
6 files changed, 76 insertions, 37 deletions
diff --git a/scripts/build/binary b/scripts/build/binary index a641d2be0..a759a7899 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -33,14 +33,14 @@ lb binary_chroot "${@}" # Chroot preparation component lists # We deliberately exclude 'debianchroot' CHROOT_PREP_MOUNTS="devpts proc selinuxfs sysfs" -CHROOT_PREP_OTHER="dpkg tmpfs sysv-rc hosts resolv hostname" +CHROOT_PREP_OTHER="dpkg tmpfs sysv-rc hosts resolv hostname apt" -if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] -then +if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]; then # Configuring chroot + # FIXME: cannot run in 'all' mode while excluding 'debianchroot', do we really need to exclude it? + #lb chroot_prep install all mode-apt-install-binary mode-archives-chroot "${@}" lb chroot_prep install "${CHROOT_PREP_MOUNTS}" "${@}" - lb chroot_prep install "${CHROOT_PREP_OTHER}" "${@}" - lb chroot_apt install-binary "${@}" + lb chroot_prep install "${CHROOT_PREP_OTHER}" mode-apt-install-binary mode-archives-chroot "${@}" lb chroot_archives chroot install "${@}" fi @@ -64,8 +64,7 @@ lb binary_grub-efi "${@}" lb binary_hooks "${@}" lb binary_checksums "${@}" -if [ "${LB_BUILD_WITH_CHROOT}" != "true" ] -then +if [ "${LB_BUILD_WITH_CHROOT}" != "true" ]; then lb chroot_prep install "${CHROOT_PREP_MOUNTS}" "${@}" fi @@ -78,12 +77,10 @@ lb binary_hdd "${@}" lb binary_zsync "${@}" -if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] -then +if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]; then # Deconfiguring chroot Remove_stagefile chroot_archives - lb chroot_apt remove "${@}" lb chroot_prep remove "${CHROOT_PREP_OTHER}" "${@}" fi diff --git a/scripts/build/bootstrap b/scripts/build/bootstrap index 8ec5d237c..08229a393 100755 --- a/scripts/build/bootstrap +++ b/scripts/build/bootstrap @@ -33,11 +33,11 @@ lb bootstrap_debootstrap "${@}" lb bootstrap_cache save "${@}" # Configuring chroot -lb chroot_prep install all "${@}" +lb chroot_prep install all-except-archives "${@}" lb bootstrap_archives binary "${@}" # Deconfiguring chroot -lb chroot_prep remove all "${@}" +lb chroot_prep remove all-except-archives "${@}" Echo_message "Bootstrap stage completed" diff --git a/scripts/build/chroot b/scripts/build/chroot index f6ac8901f..497911800 100755 --- a/scripts/build/chroot +++ b/scripts/build/chroot @@ -31,8 +31,7 @@ Setup_clean_exit lb chroot_cache restore "${@}" # Configuring chroot -lb chroot_prep install all "${@}" -lb chroot_archives chroot install "${@}" +lb chroot_prep install all mode-archives-chroot "${@}" # Customizing chroot lb chroot_linux-image "${@}" @@ -56,8 +55,7 @@ lb chroot_interactive "${@}" Chroot chroot "dpkg-query -W" > chroot.packages.live # Deconfiguring chroot -lb chroot_archives chroot remove "${@}" -lb chroot_prep remove all "${@}" +lb chroot_prep remove all mode-archives-chroot "${@}" # Saving live OS chroot to cache lb chroot_cache save "${@}" 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 diff --git a/scripts/build/installer b/scripts/build/installer index bab2a6d32..30d27990b 100755 --- a/scripts/build/installer +++ b/scripts/build/installer @@ -29,8 +29,7 @@ Setup_clean_exit if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]; then # Configuring chroot - lb chroot_prep install all "${@}" - lb chroot_archives chroot install "${@}" + lb chroot_prep install all mode-archives-chroot "${@}" fi # Building installer @@ -39,8 +38,7 @@ lb installer_preseed "${@}" if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]; then # Deconfiguring chroot - lb chroot_archives chroot remove "${@}" - lb chroot_prep remove all "${@}" + lb chroot_prep remove all mode-archives-chroot "${@}" fi Echo_message "Installer stage completed" diff --git a/scripts/build/source b/scripts/build/source index 9fe0dc8e0..bd113fc07 100755 --- a/scripts/build/source +++ b/scripts/build/source @@ -32,11 +32,10 @@ fi # Setting up cleanup function Setup_clean_exit -CHROOT_PREP="hosts resolv hostname" +CHROOT_PREP="hosts resolv hostname archives" # Configuring chroot (enabling networking) -lb chroot_prep install "${CHROOT_PREP}" "${@}" -lb chroot_archives source install "${@}" +lb chroot_prep install "${CHROOT_PREP}" mode-archives-source "${@}" # Preparing images lb source_live "${@}" @@ -51,7 +50,6 @@ lb source_tar "${@}" lb source_hdd "${@}" # Deconfiguring chroot -lb chroot_archives source remove "${@}" -lb chroot_prep remove "${CHROOT_PREP}" "${@}" +lb chroot_prep remove "${CHROOT_PREP}" mode-archives-source "${@}" Echo_message "Source stage completed" |