summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build/binary32
-rwxr-xr-xscripts/build/bootstrap26
-rwxr-xr-xscripts/build/chroot26
-rwxr-xr-xscripts/build/chroot_prep69
-rwxr-xr-xscripts/build/installer32
-rwxr-xr-xscripts/build/source10
6 files changed, 91 insertions, 104 deletions
diff --git a/scripts/build/binary b/scripts/build/binary
index ac24a4f4a..49e0e994b 100755
--- a/scripts/build/binary
+++ b/scripts/build/binary
@@ -30,18 +30,16 @@ Setup_clean_exit
# Preparing root filesystem
lb binary_chroot "${@}"
+# Chroot preparation component lists
+# We deliberately exclude 'debianchroot' and 'tmpfs'
+CHROOT_PREP_MOUNTS="devpts proc selinuxfs sysfs"
+CHROOT_PREP_OTHER="dpkg sysv-rc hosts resolv hostname"
+
if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
then
# Configuring chroot
- lb chroot_devpts install "${@}"
- lb chroot_proc install "${@}"
- lb chroot_selinuxfs install "${@}"
- lb chroot_sysfs install "${@}"
- lb chroot_hosts install "${@}"
- lb chroot_resolv install "${@}"
- lb chroot_hostname install "${@}"
- lb chroot_dpkg install "${@}"
- lb chroot_sysv-rc install "${@}"
+ lb chroot_prep install "${CHROOT_PREP_MOUNTS}" "${@}"
+ lb chroot_prep install "${CHROOT_PREP_OTHER}" "${@}"
lb chroot_apt install-binary "${@}"
lb chroot_archives chroot install "${@}"
fi
@@ -68,10 +66,7 @@ lb binary_checksums "${@}"
if [ "${LB_BUILD_WITH_CHROOT}" != "true" ]
then
- lb chroot_devpts install "${@}"
- lb chroot_proc install "${@}"
- lb chroot_selinuxfs install "${@}"
- lb chroot_sysfs install "${@}"
+ lb chroot_prep install "${CHROOT_PREP_MOUNTS}" "${@}"
fi
# Building images
@@ -89,16 +84,9 @@ then
Remove_stagefile chroot_archives
lb chroot_apt remove "${@}"
- lb chroot_hostname remove "${@}"
- lb chroot_resolv remove "${@}"
- lb chroot_hosts remove "${@}"
- lb chroot_sysv-rc remove "${@}"
- lb chroot_dpkg remove "${@}"
+ lb chroot_prep remove "${CHROOT_PREP_OTHER}" "${@}"
fi
-lb chroot_sysfs remove "${@}"
-lb chroot_selinuxfs remove "${@}"
-lb chroot_proc remove "${@}"
-lb chroot_devpts remove "${@}"
+lb chroot_prep remove "${CHROOT_PREP_MOUNTS}" "${@}"
Echo_message "Binary stage completed"
diff --git a/scripts/build/bootstrap b/scripts/build/bootstrap
index dcb4f710b..8ec5d237c 100755
--- a/scripts/build/bootstrap
+++ b/scripts/build/bootstrap
@@ -33,33 +33,11 @@ lb bootstrap_debootstrap "${@}"
lb bootstrap_cache save "${@}"
# Configuring chroot
-lb chroot_devpts install "${@}"
-lb chroot_proc install "${@}"
-lb chroot_selinuxfs install "${@}"
-lb chroot_sysfs install "${@}"
-lb chroot_debianchroot install "${@}"
-lb chroot_dpkg install "${@}"
-lb chroot_tmpfs install "${@}"
-lb chroot_sysv-rc install "${@}"
-lb chroot_hosts install "${@}"
-lb chroot_resolv install "${@}"
-lb chroot_hostname install "${@}"
-lb chroot_apt install "${@}"
+lb chroot_prep install all "${@}"
lb bootstrap_archives binary "${@}"
# Deconfiguring chroot
-lb chroot_apt remove "${@}"
-lb chroot_hostname remove "${@}"
-lb chroot_resolv remove "${@}"
-lb chroot_hosts remove "${@}"
-lb chroot_sysv-rc remove "${@}"
-lb chroot_tmpfs remove "${@}"
-lb chroot_dpkg remove "${@}"
-lb chroot_debianchroot remove "${@}"
-lb chroot_sysfs remove "${@}"
-lb chroot_selinuxfs remove "${@}"
-lb chroot_proc remove "${@}"
-lb chroot_devpts remove "${@}"
+lb chroot_prep remove all "${@}"
Echo_message "Bootstrap stage completed"
diff --git a/scripts/build/chroot b/scripts/build/chroot
index ad15ff0a2..f6ac8901f 100755
--- a/scripts/build/chroot
+++ b/scripts/build/chroot
@@ -31,18 +31,7 @@ Setup_clean_exit
lb chroot_cache restore "${@}"
# Configuring chroot
-lb chroot_devpts install "${@}"
-lb chroot_proc install "${@}"
-lb chroot_selinuxfs install "${@}"
-lb chroot_sysfs install "${@}"
-lb chroot_debianchroot install "${@}"
-lb chroot_dpkg install "${@}"
-lb chroot_tmpfs install "${@}"
-lb chroot_sysv-rc install "${@}"
-lb chroot_hosts install "${@}"
-lb chroot_resolv install "${@}"
-lb chroot_hostname install "${@}"
-lb chroot_apt install "${@}"
+lb chroot_prep install all "${@}"
lb chroot_archives chroot install "${@}"
# Customizing chroot
@@ -68,18 +57,7 @@ Chroot chroot "dpkg-query -W" > chroot.packages.live
# Deconfiguring chroot
lb chroot_archives chroot remove "${@}"
-lb chroot_apt remove "${@}"
-lb chroot_hostname remove "${@}"
-lb chroot_resolv remove "${@}"
-lb chroot_hosts remove "${@}"
-lb chroot_sysv-rc remove "${@}"
-lb chroot_tmpfs remove "${@}"
-lb chroot_dpkg remove "${@}"
-lb chroot_debianchroot remove "${@}"
-lb chroot_sysfs remove "${@}"
-lb chroot_selinuxfs remove "${@}"
-lb chroot_proc remove "${@}"
-lb chroot_devpts remove "${@}"
+lb chroot_prep remove all "${@}"
# Saving live OS chroot to cache
lb chroot_cache save "${@}"
diff --git a/scripts/build/chroot_prep b/scripts/build/chroot_prep
new file mode 100755
index 000000000..8bb456b8b
--- /dev/null
+++ b/scripts/build/chroot_prep
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2020 The Debian Live team
+##
+## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="Prep chroot"
+USAGE="${PROGRAM} {install|remove} {all|\"HELPERS\"} [--force]"
+
+# Processing arguments and configuration files
+Init_config_data "${@}"
+
+# Requiring stage file
+Require_stagefiles config bootstrap
+
+ACTION="${1}"
+HELPERS="${2}"
+shift 2
+
+if ! In_list "${ACTION}" install remove; then
+ Echo_error "Invalid action parameter"
+ exit 1
+fi
+
+if [ -z "${HELPERS}" ]; then
+ Echo_error "You must specify which helpers to run"
+ 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
+
+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!"
+ exit 1
+fi
+
+if [ "${_ACTION}" = "remove" ]; then
+ HELPERS_REVERSED=""
+ for HELPER in $HELPERS; do
+ HELPERS_REVERSED="${HELPER}${HELPERS_REVERSED:+ $HELPERS_REVERSED}"
+ done
+ HELPERS="${HELPERS_REVERSED}"
+fi
+
+for HELPER in $HELPERS; do
+ lb "chroot_${HELPER}" "${ACTION}" "${@}"
+done
diff --git a/scripts/build/installer b/scripts/build/installer
index 3054861dc..bab2a6d32 100755
--- a/scripts/build/installer
+++ b/scripts/build/installer
@@ -27,21 +27,9 @@ Init_config_data "${@}"
# Setting up cleanup function
Setup_clean_exit
-if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
-then
+if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]; then
# Configuring chroot
- lb chroot_devpts install "${@}"
- lb chroot_proc install "${@}"
- lb chroot_selinuxfs install "${@}"
- lb chroot_sysfs install "${@}"
- lb chroot_debianchroot install "${@}"
- lb chroot_dpkg install "${@}"
- lb chroot_tmpfs install "${@}"
- lb chroot_sysv-rc install "${@}"
- lb chroot_hosts install "${@}"
- lb chroot_resolv install "${@}"
- lb chroot_hostname install "${@}"
- lb chroot_apt install "${@}"
+ lb chroot_prep install all "${@}"
lb chroot_archives chroot install "${@}"
fi
@@ -49,22 +37,10 @@ fi
lb installer_debian-installer "${@}"
lb installer_preseed "${@}"
-if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]
-then
+if [ "${LB_BUILD_WITH_CHROOT}" = "true" ]; then
# Deconfiguring chroot
lb chroot_archives chroot remove "${@}"
- lb chroot_apt remove "${@}"
- lb chroot_hostname remove "${@}"
- lb chroot_resolv remove "${@}"
- lb chroot_hosts remove "${@}"
- lb chroot_sysv-rc remove "${@}"
- lb chroot_tmpfs remove "${@}"
- lb chroot_dpkg remove "${@}"
- lb chroot_debianchroot remove "${@}"
- lb chroot_sysfs remove "${@}"
- lb chroot_selinuxfs remove "${@}"
- lb chroot_proc remove "${@}"
- lb chroot_devpts remove "${@}"
+ lb chroot_prep remove all "${@}"
fi
Echo_message "Installer stage completed"
diff --git a/scripts/build/source b/scripts/build/source
index 7e03c337c..9fe0dc8e0 100755
--- a/scripts/build/source
+++ b/scripts/build/source
@@ -32,10 +32,10 @@ fi
# Setting up cleanup function
Setup_clean_exit
+CHROOT_PREP="hosts resolv hostname"
+
# Configuring chroot (enabling networking)
-lb chroot_hosts install "${@}"
-lb chroot_resolv install "${@}"
-lb chroot_hostname install "${@}"
+lb chroot_prep install "${CHROOT_PREP}" "${@}"
lb chroot_archives source install "${@}"
# Preparing images
@@ -52,8 +52,6 @@ lb source_hdd "${@}"
# Deconfiguring chroot
lb chroot_archives source remove "${@}"
-lb chroot_hostname remove "${@}"
-lb chroot_resolv remove "${@}"
-lb chroot_hosts remove "${@}"
+lb chroot_prep remove "${CHROOT_PREP}" "${@}"
Echo_message "Source stage completed"