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
This commit is contained in:
parent
1f63c620f0
commit
38a5aed0dc
|
@ -199,7 +199,7 @@ The following chroot_ prefixed commands are used throughout the various primary
|
|||
.PP
|
||||
Note that the \fBlb chroot_prep\fR(1) command can be used to run these components in bulk.
|
||||
.IP "\fBlb chroot_prep\fR(1)" 4
|
||||
a helper to run the below components in bulk, usable for all those that can be controlled with a single parameter of 'install' or 'remove' (thus excluding \fBlb chroot_archives\fR(1) and also \fBlb chroot_apt\fR(1) when run with 'install-binary'). The first parameter it takes is the execution mode - install or remove - to pass along. The second parameter is the set of helpers to run (they can be space or comma separated; remember to quote if space separated). Any remaining parameters (i.e. options like --force) are passed along. The second can be simply 'all' in which case a default set of all (applicable) components are used. Components can be specified without their filename 'chroot_' prefix for brevity. In remove mode the list of components are run in reverse order, so no need to provide them in reverse order yourself.
|
||||
a helper to run the below components in bulk. The first parameter it takes is the execution mode - install or remove - to pass along. The second parameter is the set of helpers to run (they can be space or comma separated; remember to quote if space separated). Following this one or more of the special parameters 'mode-archives-chroot', 'mode-archives-binary', 'mode-archives-source' and 'mode-apt-install-binary' can optionally be used, to select the 'pass' parameter for \fBlb chroot_archives\fR(1) in the case of the first three (required if 'archives' is one of the helpers to be run), and to run \fBlb chroot_apt\fR(1) in 'install-binary' mode in the last case. Any remaining parameters (i.e. options like --force) are passed along to all scripts run. The second parameter can be simply 'all' in which case a default set of all (applicable) components are used, or 'all-except-archives' which differs in skipping \fBlb chroot_archives\fR(1). Components can be specified without their filename 'chroot_' prefix for brevity. In remove mode the list of components are run in reverse order, so no need to provide them in reverse order yourself.
|
||||
.IP "\fBlb chroot_apt\fR(1)" 4
|
||||
manages apt configuration; in apply mode it applies configuration for use during build process, and in remove mode removes that configuration
|
||||
.IP "\fBlb chroot_archives\fR(1)" 4
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 "${@}"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue