summaryrefslogtreecommitdiffstats
path: root/system-build/scripts/build/chroot
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xsystem-build/scripts/build/chroot92
-rwxr-xr-xsystem-build/scripts/build/chroot_apt315
-rwxr-xr-xsystem-build/scripts/build/chroot_archives675
-rwxr-xr-xsystem-build/scripts/build/chroot_cache82
-rwxr-xr-xsystem-build/scripts/build/chroot_debianchroot81
-rwxr-xr-xsystem-build/scripts/build/chroot_devpts77
-rwxr-xr-xsystem-build/scripts/build/chroot_dpkg105
-rwxr-xr-xsystem-build/scripts/build/chroot_firmware124
-rwxr-xr-xsystem-build/scripts/build/chroot_hacks128
-rwxr-xr-xsystem-build/scripts/build/chroot_hooks119
-rwxr-xr-xsystem-build/scripts/build/chroot_hostname91
-rwxr-xr-xsystem-build/scripts/build/chroot_hosts97
-rwxr-xr-xsystem-build/scripts/build/chroot_includes50
-rwxr-xr-xsystem-build/scripts/build/chroot_install-packages94
-rwxr-xr-xsystem-build/scripts/build/chroot_interactive62
-rwxr-xr-xsystem-build/scripts/build/chroot_linux-image60
-rwxr-xr-xsystem-build/scripts/build/chroot_live-packages79
-rwxr-xr-xsystem-build/scripts/build/chroot_package-lists120
-rwxr-xr-xsystem-build/scripts/build/chroot_preseed72
-rwxr-xr-xsystem-build/scripts/build/chroot_proc81
-rwxr-xr-xsystem-build/scripts/build/chroot_resolv107
-rwxr-xr-xsystem-build/scripts/build/chroot_selinuxfs78
-rwxr-xr-xsystem-build/scripts/build/chroot_sysfs75
-rwxr-xr-xsystem-build/scripts/build/chroot_sysv-rc87
-rwxr-xr-xsystem-build/scripts/build/chroot_tmpfs80
25 files changed, 3031 insertions, 0 deletions
diff --git a/system-build/scripts/build/chroot b/system-build/scripts/build/chroot
new file mode 100755
index 0000000..d6277e6
--- /dev/null
+++ b/system-build/scripts/build/chroot
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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
+
+# Automatically populating config tree
+if [ -x auto/config ] && [ ! -e .build/config ]
+then
+ Echo_message "Automatically populating config tree."
+ lb config
+fi
+
+# Setting static variables
+DESCRIPTION="$(Echo 'customize the Debian system')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Setup cleanup function
+Setup_cleanup
+
+# Configuring chroot
+lb chroot_cache restore ${@}
+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_archives chroot install ${@}
+
+# Customizing chroot
+lb chroot_linux-image ${@}
+lb chroot_firmware ${@}
+lb chroot_preseed ${@}
+
+for _PASS in install live
+do
+ lb chroot_package-lists ${_PASS} ${@}
+ lb chroot_install-packages ${_PASS} ${@}
+
+ if [ "${_PASS}" = install ]
+ then
+ Chroot chroot "dpkg-query -W" > chroot.packages.install
+ fi
+done
+
+lb chroot_includes ${@}
+lb chroot_hooks ${@}
+lb chroot_hacks ${@}
+lb chroot_interactive ${@}
+
+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_cache save ${@}
+
+Chroot chroot "ls -lR" > chroot.files
diff --git a/system-build/scripts/build/chroot_apt b/system-build/scripts/build/chroot_apt
new file mode 100755
index 0000000..5f7c2cc
--- /dev/null
+++ b/system-build/scripts/build/chroot_apt
@@ -0,0 +1,315 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /etc/apt/apt.conf')"
+HELP=""
+USAGE="${PROGRAM} {install|install-binary|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install|install-binary)
+ Echo_message "Configuring file /etc/apt/apt.conf"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_apt
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ mkdir -p chroot/etc/apt/apt.conf.d
+
+ # Configuring apt ftp proxy
+ if [ -n "${LB_APT_FTP_PROXY}" ]
+ then
+ echo "Acquire::ftp::Proxy \"${LB_APT_FTP_PROXY}\";" > chroot/etc/apt/apt.conf.d/00ftp-proxy
+ fi
+
+ # Configuring apt http proxy
+ if [ -n "${LB_APT_HTTP_PROXY}" ]
+ then
+ echo "Acquire::http::Proxy \"${LB_APT_HTTP_PROXY}\";" > chroot/etc/apt/apt.conf.d/00http-proxy
+ fi
+
+ # Configuring apt pipeline
+ if [ -n "${LB_APT_PIPELINE}" ]
+ then
+ echo "Acquire::http::Pipeline-Depth \"${LB_APT_PIPELINE}\";" > chroot/etc/apt/apt.conf.d/00pipeline
+ fi
+
+ # Configuring apt recommends
+ case "${LB_APT_RECOMMENDS}" in
+ true)
+ echo "APT::Install-Recommends \"true\";" > chroot/etc/apt/apt.conf.d/00recommends
+ ;;
+
+ false)
+ echo "APT::Install-Recommends \"false\";" > chroot/etc/apt/apt.conf.d/00recommends
+ ;;
+ esac
+
+ # Configuring apt secure
+ case "${LB_APT_SECURE}" in
+ true)
+ echo "APT::Get::AllowUnauthenticated \"false\";" > chroot/etc/apt/apt.conf.d/00secure
+ ;;
+
+ false)
+ echo "APT::Get::AllowUnauthenticated \"true\";" > chroot/etc/apt/apt.conf.d/00secure
+ ;;
+ esac
+
+ # Configuring apt config
+ if [ -f config/apt/apt.conf ]
+ then
+ if [ -f chroot/etc/apt/apt.conf ]
+ then
+ mv chroot/etc/apt/apt.conf chroot/etc/apt/apt.conf.orig
+ fi
+
+ cp config/apt/apt.conf chroot/etc/apt/apt.conf
+ fi
+
+ # Configuring apt preferences
+ if [ -f config/apt/preferences ]
+ then
+ if [ -f chroot/etc/apt/preferences ]
+ then
+ mv chroot/etc/apt/preferences chroot/etc/apt/preferences.orig
+ fi
+
+ cp config/apt/preferences chroot/etc/apt/preferences
+ fi
+
+ if Find_files config/apt/*.pref
+ then
+ for _FILE in config/apt/*.pref
+ do
+ if [ -f chroot/etc/apt/preferences.d/$(basename ${_FILE}) ]
+ then
+ mv chroot/etc/apt/preferences.d/$(basename ${_FILE}) chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig
+ fi
+
+ cp -aL ${_FILE} chroot/etc/apt/preferences.d
+ done
+ fi
+
+ if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
+ then
+ echo >> chroot/etc/apt/preferences
+ echo "# Added by lb_chroot_apt ${@}" >> chroot/etc/apt/preferences
+ echo "Package: *" >> chroot/etc/apt/preferences
+ echo "Pin: release o=config/packages.chroot" >> chroot/etc/apt/preferences
+
+ case "${1}" in
+ install)
+ # Ensure local packages have priority
+ echo "Pin-Priority: 1001" >> chroot/etc/apt/preferences
+ ;;
+
+ install-binary)
+ # Ensure local packages are not re-installed during lb_binary
+ echo "Pin-Priority: 99" >> chroot/etc/apt/preferences
+
+ echo >> chroot/etc/apt/preferences
+ echo "Package: *" >> chroot/etc/apt/preferences
+ echo "Pin: release o=debian" >> chroot/etc/apt/preferences
+ echo "Pin-Priority: 99" >> chroot/etc/apt/preferences
+ ;;
+ esac
+ fi
+
+ case "${LB_MODE}" in
+ progress-linux)
+ if [ ! -e chroot/etc/apt/preferences.d/progress-linux.pref ]
+ then
+ _DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||')"
+
+ _ENABLE_DISTRIBUTIONS="${_DISTRIBUTION}"
+ _DISABLE_DISTRIBUTIONS=""
+
+ if [ "${LB_SECURITY}" = "true" ]
+ then
+ _ENABLE_DISTRIBUTIONS="${_ENABLE_DISTRIBUTIONS} ${_DISTRIBUTION}-security"
+ fi
+
+ if [ "${LB_UPDATES}" = "true" ]
+ then
+ _ENABLE_DISTRIBUTIONS="${_ENABLE_DISTRIBUTIONS} ${_DISTRIBUTION}-updates"
+ fi
+
+ case "${LB_DISTRIBUTION}" in
+ *-backports)
+ if [ "${LB_BACKPORTS}" = "true" ]
+ then
+ _ENABLE_DISTRIBUTIONS="${_ENABLE_DISTRIBUTIONS} ${_DISTRIBUTION}-backports"
+ fi
+ ;;
+
+ *)
+ if [ "${LB_BACKPORTS}" = "true" ]
+ then
+ _DISABLE_DISTRIBUTIONS="${_DISABLE_DISTRIBUTIONS} ${_DISTRIBUTION}-backports"
+ fi
+ ;;
+ esac
+
+ for _DISTRIBUTION in ${_ENABLE_DISTRIBUTIONS}
+ do
+
+cat >> chroot/etc/apt/preferences.d/progress-linux.pref << EOF
+
+Package: *
+Pin: release n=${_DISTRIBUTION}
+Pin-Priority: 999
+EOF
+
+ done
+
+ for _DISTRIBUTION in ${_DISABLE_DISTRIBUTIONS}
+ do
+
+cat >> chroot/etc/apt/preferences.d/progress-linux.pref << EOF
+
+#Package: *
+#Pin: release n=${_DISTRIBUTION}
+#Pin-Priority: 999
+EOF
+
+ done
+ fi
+ ;;
+ esac
+
+ # Creating stage file
+ Create_stagefile .build/chroot_apt
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /etc/apt/apt.conf"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Deconfiguring apt ftp proxy
+ rm -f chroot/etc/apt/apt.conf.d/00ftp-proxy
+
+ # Deconfiguring apt http proxy
+ rm -f chroot/etc/apt/apt.conf.d/00http-proxy
+
+ # Deconfiguring apt pipeline
+ rm -f chroot/etc/apt/apt.conf.d/00pipeline
+
+ # Deconfiguring apt recommends
+ if [ "${LB_APT_RECOMMENDS}" = "true" ]
+ then
+ rm -f chroot/etc/apt/apt.conf.d/00recommends
+ fi
+
+ # Deconfiguring apt secure
+ if [ "${LB_APT_SECURE}" = "true" ]
+ then
+ rm -f chroot/etc/apt/apt.conf.d/00secure
+ fi
+
+ # Configuring apt config
+ if [ -f config/apt/apt.conf ]
+ then
+ if [ -f chroot/etc/apt/apt.conf ]
+ then
+ mv chroot/etc/apt/apt.conf chroot/etc/apt/apt.conf.orig
+ fi
+
+ cp config/apt/apt.conf chroot/etc/apt/apt.conf
+
+ if [ -f chroot/etc/apt/apt.conf.orig ]
+ then
+ mv chroot/etc/apt/apt.conf.orig chroot/etc/apt/apt.conf
+ fi
+ fi
+
+ # Deconfiguring apt preferences
+ if [ -f config/apt/preferences ]
+ then
+ if [ -f chroot/etc/apt/preferences ]
+ then
+ mv chroot/etc/apt/preferences chroot/etc/apt/preferences.orig
+ fi
+
+ cp config/apt/preferences chroot/etc/apt/preferences
+
+ if [ -f chroot/etc/apt/preferences.orig ]
+ then
+ mv chroot/etc/apt/preferences.orig chroot/etc/apt/preferences
+ fi
+ fi
+
+ if Find_files config/apt/*.pref
+ then
+ for _FILE in config/apt/*.pref
+ do
+ if [ -f chroot/etc/apt/preferences.d/$(basename ${_FILE}) ]
+ then
+ mv chroot/etc/apt/preferences.d/$(basename ${_FILE}) chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig
+ fi
+
+ cp -aL ${_FILE} chroot/etc/apt/preferences.d
+
+ if [ -f chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig ]
+ then
+ mv chroot/etc/apt/preferences.d/$(basename ${_FILE}).orig chroot/etc/apt/preferences.d/$(basename ${_FILE})
+ fi
+ done
+ fi
+
+ if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
+ then
+ if [ -f chroot/etc/apt/preferences ]
+ then
+ # delete additions from lb_chroot_apt install|install-binary to preferences
+ sed -i '/# Added by lb_chroot_apt/,$d' chroot/etc/apt/preferences
+ # delete the last empty line
+ sed -i '${/^[[:blank:]]*$/d;}' chroot/etc/apt/preferences
+ # if the resulting preferences file is empty there was no user additions, remove it
+ if [ ! -s chroot/etc/apt/preferences ]
+ then
+ rm -rf chroot/etc/apt/preferences
+ fi
+ fi
+
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_apt
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_archives b/system-build/scripts/build/chroot_archives
new file mode 100755
index 0000000..063f3b6
--- /dev/null
+++ b/system-build/scripts/build/chroot_archives
@@ -0,0 +1,675 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /etc/apt/sources.list')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+_PASS="${1}"
+shift
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${LB_DERIVATIVE}" in
+ true)
+ _PARENT_FILE="sources.list.d/debian.list"
+ ;;
+
+ false)
+ _PARENT_FILE="sources.list"
+ ;;
+esac
+
+case "${1}" in
+ install)
+ Echo_message "Configuring file /etc/apt/sources.list"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_archives
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Restoring cache
+ Restore_cache cache/packages.chroot
+
+ # Configure custom sources.list
+
+if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
+then
+ Chroot_bind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
+fi
+
+cat > chroot/etc/apt/${_PARENT_FILE} << EOF
+deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}
+EOF
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ rm -f chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ _DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||')"
+
+ echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+
+ if [ "${LB_SECURITY}" = "true" ]
+ then
+ case "${LB_MODE}" in
+ debian|progress-linux)
+ case "${LB_PARENT_DISTRIBUTION}" in
+ sid)
+
+ ;;
+
+ *)
+ echo "deb ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_CHROOT_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+ ;;
+ esac
+
+ if [ "${LB_MODE}" = progress-linux ]
+ then
+ echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ else
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ echo "deb ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_CHROOT_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+ fi
+ ;;
+ esac
+ fi
+
+ if [ "${LB_UPDATES}" = "true" ]
+ then
+ echo "deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+ fi
+
+ if [ "${LB_BACKPORTS}" = "true" ]
+ then
+ case "${LB_MODE}" in
+ debian)
+ if [ "${LB_PARENT_DISTRIBUTION}" != "sid" ]
+ then
+ echo "deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+ fi
+ ;;
+ esac
+
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ echo "deb ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_CHROOT} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+ fi
+
+ # Adding local apt sources (chroot)
+ for FILE in config/archives/*.list config/archives/*.list.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION}|g" \
+ -e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
+ -e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
+ -e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
+ "${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
+
+ if [ "${_PASS}" != "source" ] && [ "${LB_APT_SOURCE_ARCHIVES}" = "false" ]
+ then
+ # Strip out source archives
+ sed "/^deb-src /d" "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
+ fi
+ fi
+ done
+
+ # Adding local apt configuration (chroot)
+ for FILE in config/archives/*.conf config/archives/*.conf.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot)
+ fi
+ done
+
+ # Adding local apt preferences (chroot)
+ for FILE in config/archives/*.pref config/archives/*.pref.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot)
+ fi
+ done
+
+ # Configure local package repository
+ if Find_files config/packages.chroot/*.deb || Find_files config/packages/*.deb
+ then
+ rm -rf chroot/root/packages
+ mkdir -p chroot/root/packages
+
+ if [ "$(stat --printf %d config/packages.chroot/)" = "$(stat --printf %d chroot/root/packages/)" ] ||
+ [ "$(stat --printf %d config/packages/)" = "$(stat --printf %d chroot/root/packages/)" ]
+ then
+ CP_OPTIONS="-l"
+ fi
+
+ # Copy packages
+ if Find_files config/packages.chroot/*_"${LB_ARCHITECTURES}".deb || Find_files config/packages/*_"${LB_ARCHITECTURES}".deb
+ then
+ for FILE in config/packages.chroot/*_"${LB_ARCHITECTURES}".deb config/packages/*_"${LB_ARCHITECTURES}".deb
+ do
+ if [ -L "${FILE}" ]
+ then
+ cp -L "${FILE}" chroot/root/packages
+ elif [ -e "${FILE}" ]
+ then
+ cp ${CP_OPTIONS} "${FILE}" chroot/root/packages
+ fi
+ done
+ fi
+
+ if Find_files config/packages.chroot/*_all.deb || Find_files config/packages/*_all.deb
+ then
+ for FILE in config/packages.chroot/*_all.deb config/packages/*_all.deb
+ do
+ if [ -L "${FILE}" ]
+ then
+ cp -L "${FILE}" chroot/root/packages
+ elif [ -e "${FILE}" ]
+ then
+ cp ${CP_OPTIONS} "${FILE}" chroot/root/packages
+ fi
+ done
+ fi
+
+ if Find_files chroot/root/packages/*.deb
+ then
+ # If we bootstrapped a minimal chroot, we need
+ # to install apt-utils before we have
+ # completed all the indices.
+ if [ ! -e chroot/usr/bin/apt-ftparchive ]
+ then
+ Apt chroot update
+ fi
+
+ # Check depends
+ Check_package chroot /usr/bin/apt-ftparchive apt-utils
+
+ # Installing depends
+ Install_package
+
+ # Generate Packages and Packages.gz
+ echo "cd /root/packages && apt-ftparchive packages . > Packages" | Chroot chroot sh
+ gzip -9 -c chroot/root/packages/Packages > chroot/root/packages/Packages.gz
+
+ # Generate Release
+ echo "cd /root/packages && apt-ftparchive \
+ -o APT::FTPArchive::Release::Origin=config/packages.chroot \
+ release . > Release" | Chroot chroot sh
+
+ # Add to sources.list.d
+ echo "deb [ trusted=yes ] file:/root/packages ./" > chroot/etc/apt/sources.list.d/packages.list
+
+ # Move top-level sources away, otherwise apt always preferes it (#644148)
+ if [ -e chroot/etc/apt/sources.list ]
+ then
+ mv chroot/etc/apt/sources.list chroot/etc/apt/sources.list.d/zz-sources.list
+ fi
+
+ # Removing depends
+ Remove_package
+ else
+ Echo_warning "Local packages must be named with suffix '_all.deb' or '_\$architecture.deb'."
+ fi
+ fi
+
+ if Find_files chroot/root/packages/*.deb
+ then
+ gunzip < chroot/root/packages/Packages.gz | awk '/^Package: / { print $2 }' \
+ >> chroot/root/packages.chroot
+ fi
+
+ # Update indices from cache
+ if [ "${LB_CACHE_INDICES}" = "true" ] && [ -d cache/indices.bootstrap ]
+ then
+ if Find_files cache/indices.bootstrap/secring.gpg*
+ then
+ cp -f cache/indices.bootstrap/secring.gpg* chroot/etc/apt
+ fi
+
+ if Find_files cache/indices.bootstrap/trusted.gpg*
+ then
+ cp -rf cache/indices.bootstrap/trusted.gpg* chroot/etc/apt
+ fi
+
+ if [ -f cache/indices.bootstrap/pkgcache.bin ]
+ then
+ cp -f cache/indices.bootstrap/pkgcache.bin chroot/var/cache/apt
+ fi
+
+ if [ -f cache/indices.bootstrap/srcpkgcache.bin ]
+ then
+ cp -f cache/indices.bootstrap/srcpkgcache.bin chroot/var/cache/apt
+ fi
+
+ if Find_files cache/indices.bootstrap/*_Packages
+ then
+ cp -f cache/indices.bootstrap/*_Packages chroot/var/lib/apt/lists
+ fi
+
+ if Find_files cache/indices.bootstrap/*_Sources
+ then
+ cp -f cache/indices.bootstrap/*_Sources chroot/var/lib/apt/lists
+ fi
+
+ if Find_files cache/indices.bootstrap/*Release*
+ then
+ cp -f cache/indices.bootstrap/*Release* chroot/var/lib/apt/lists
+ fi
+ else # Get fresh indices
+ # Check local archive keys
+ if Find_files config/archives/*.key || \
+ Find_files config/archives/*.key.chroot
+ then
+ for FILE in config/archives/*.key \
+ config/archives/*.key.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ cp ${FILE} chroot/root
+ Chroot chroot "apt-key add /root/$(basename ${FILE})"
+ rm -f chroot/root/$(basename ${FILE})
+ fi
+ done
+ fi
+
+ # Check local keyring packages
+ if Find_files config/archives/*.deb
+ then
+ for PACKAGE in config/archives/*.deb
+ do
+ cp ${PACKAGE} chroot/root
+ Chroot chroot "dpkg -i /root/$(basename ${PACKAGE})"
+ rm -f chroot/root/$(basename ${PACKAGE})
+ done
+ fi
+
+ # Rebuild apt indices from scratch.
+ # Due to the fact that apt doesn't understand
+ # pinning on the fly, we need to manually remove
+ # the cached indices and rebuild them again.
+ rm -rf chroot/var/cache/apt/*.bin
+
+ Apt chroot update
+
+ # Installing keyring packages
+ if [ -n "${LB_KEYRING_PACKAGES}" ]
+ then
+ Apt chroot "install ${LB_KEYRING_PACKAGES}"
+ fi
+
+ rm -rf chroot/var/cache/apt/*.bin
+
+ Apt chroot update
+ Apt chroot "upgrade"
+ Apt chroot "dist-upgrade"
+
+ if [ "${LB_CACHE_INDICES}" = "true" ]
+ then
+ mkdir -p cache/indices.bootstrap
+
+ if Find_files chroot/etc/apt/secring.gpg*
+ then
+ cp -f chroot/etc/apt/secring.gpg* cache/indices.bootstrap
+ fi
+
+ cp -rf chroot/etc/apt/trusted.gpg* cache/indices.bootstrap
+
+ cp -f chroot/var/cache/apt/pkgcache.bin cache/indices.bootstrap
+
+ if Find_files chroot/var/cache/apt/srcpkgcache.bin
+ then
+ cp -f chroot/var/cache/apt/srcpkgcache.bin cache/indices.bootstrap
+ fi
+
+ cp -f chroot/var/lib/apt/lists/*_Packages cache/indices.bootstrap
+
+ if Find_files chroot/var/lib/apt/lists/*_Sources
+ then
+ cp -f chroot/var/lib/apt/lists/*_Sources cache/indices.bootstrap
+ fi
+
+ cp -f chroot/var/lib/apt/lists/*Release* cache/indices.bootstrap
+ fi
+ fi
+
+ # Saving cache
+ Save_cache cache/packages.chroot
+
+ # Creating stage file
+ Create_stagefile .build/chroot_archives
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /etc/apt/sources.list"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Restore top-level sources
+ if [ -e chroot/etc/apt/sources.list.d/zz-sources.list ]
+ then
+ mv chroot/etc/apt/sources.list.d/zz-sources.list chroot/etc/apt/sources.list
+ fi
+
+ # Unmount local repository
+if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
+then
+ Chroot_unbind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
+fi
+
+ # Configure generic indices
+ # Don't do anything if it's not required
+ if [ "${LB_PARENT_MIRROR_CHROOT}" = "${LB_PARENT_MIRROR_BINARY}" ] && \
+ [ "${LB_PARENT_MIRROR_CHROOT_SECURITY}" = "${LB_PARENT_MIRROR_BINARY_SECURITY}" ] && \
+ [ ! -d chroot/root/packages ]
+ then
+ # Removing stage file
+ rm -f .build/chroot_archives
+
+ exit 0
+ fi
+
+ # Cleaning apt list cache
+ rm -rf chroot/var/lib/apt/lists
+ mkdir -p chroot/var/lib/apt/lists/partial
+
+ # Configure custom sources.list
+
+cat > chroot/etc/apt/${_PARENT_FILE} << EOF
+deb ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}
+EOF
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION} ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ rm -f chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ _DISTRIBUTION="$(echo ${LB_DISTRIBUTION} | sed -e 's|-backports||')"
+
+ echo "deb ${LB_MIRROR_BINARY} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_BINARY} ${_DISTRIBUTION} ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+
+ if [ "${LB_SECURITY}" = "true" ]
+ then
+ case "${LB_MODE}" in
+ debian|progress-linux)
+ case "${LB_PARENT_DISTRIBUTION}" in
+ sid)
+
+ ;;
+
+ *)
+ echo "deb ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_BINARY_SECURITY} ${LB_PARENT_DISTRIBUTION}/updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+ ;;
+ esac
+
+ if [ "${LB_MODE}" = progress-linux ]
+ then
+ echo "deb ${LB_MIRROR_BINARY_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_BINARY_SECURITY} ${_DISTRIBUTION}-security ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ else
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ echo "deb ${LB_MIRROR_BINARY_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_BINARY_SECURITY} ${_DISTRIBUTION}/updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+ fi
+ ;;
+ esac
+ fi
+
+ if [ "${LB_UPDATES}" = "true" ]
+ then
+ echo "deb ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION}-updates ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ echo "deb ${LB_MIRROR_BINARY} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_BINARY} ${_DISTRIBUTION}-updates ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+ fi
+
+ if [ "${LB_BACKPORTS}" = "true" ]
+ then
+ case "${LB_MODE}" in
+ debian)
+ if [ "${LB_PARENT_DISTRIBUTION}" != "sid" ]
+ then
+ echo "deb ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_PARENT_MIRROR_BINARY} ${LB_PARENT_DISTRIBUTION}-backports ${LB_PARENT_ARCHIVE_AREAS}" >> chroot/etc/apt/${_PARENT_FILE}
+ fi
+ fi
+ ;;
+ esac
+
+ if [ "${LB_DERIVATIVE}" = "true" ]
+ then
+ echo "deb ${LB_MIRROR_BINARY} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+
+ if [ "${_PASS}" = "source" ] || [ "${LB_APT_SOURCE_ARCHIVES}" = "true" ]
+ then
+ echo "deb-src ${LB_MIRROR_BINARY} ${_DISTRIBUTION}-backports ${LB_ARCHIVE_AREAS}" >> chroot/etc/apt/sources.list.d/${LB_MODE}.list
+ fi
+ fi
+ fi
+
+ # Removing chroot-only apt sources
+ for FILE in config/archives/*.list.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ rm -f "chroot/etc/apt/sources.list.d/$(basename ${FILE} .chroot)"
+ fi
+ done
+
+ # Removing chroot-only apt configuration
+ for FILE in config/archives/*.conf.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ rm -f "chroot/etc/apt/apt.conf.d/$(basename ${FILE} .chroot)"
+ fi
+ done
+
+ # Removing chroot-only apt preferences
+ for FILE in config/archives/*.pref.chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ rm -f "chroot/etc/apt/preferences.d/$(basename ${FILE} .chroot)"
+ fi
+ done
+
+ # Adding local apt sources (binary)
+ for FILE in config/archives/*.list config/archives/*.list.binary
+ do
+ if [ -e "${FILE}" ]
+ then
+ sed -e "s|@DISTRIBUTION@|${LB_DISTRIBUTION}|g" \
+ -e "s|@PARENT_DISTRIBUTION@|${LB_PARENT_DISTRIBUTION}|g" \
+ -e "s|@ARCHIVE_AREAS@|${LB_ARCHIVE_AREAS}|g" \
+ -e "s|@PARENT_ARCHIVE_AREAS@|${LB_PARENT_ARCHIVE_AREAS}|g" \
+ "${FILE}" > "chroot/etc/apt/sources.list.d/$(basename ${FILE} .binary)"
+
+ if [ "${_PASS}" != "source" ] && [ "${LB_APT_SOURCE_ARCHIVES}" = "false" ]
+ then
+ # Strip out source archives
+ sed "/^deb-src /d" "chroot/etc/apt/sources.list.d/$(basename ${FILE} .binary)"
+ fi
+ fi
+ done
+
+ # Adding local apt configuration (binary)
+ for FILE in config/archives/*.conf config/archives/*.conf.binary
+ do
+ if [ -e "${FILE}" ]
+ then
+ cp ${FILE} chroot/etc/apt/apt.conf.d/$(basename ${FILE} .binary)
+ fi
+ done
+
+ # Adding local apt preferences (binary)
+ for FILE in config/archives/*.pref config/archives/*.pref.binary
+ do
+ if [ -e "${FILE}" ]
+ then
+ cp ${FILE} chroot/etc/apt/preferences.d/$(basename ${FILE} .binary)
+ fi
+ done
+
+ # Adding local apt keys (binary)
+ for FILE in config/archives/*.key config/archives/*.key.binary
+ do
+ if [ -e "${FILE}" ]
+ then
+ cp ${FILE} chroot/root
+ Chroot chroot "apt-key add /root/$(basename ${FILE})"
+ rm -f chroot/root/$(basename ${FILE})
+ fi
+ done
+
+ # Updating indices
+ Apt chroot update
+
+ # Cleaning apt package cache
+ rm -rf chroot/var/cache/apt
+ mkdir -p chroot/var/cache/apt/archives/partial
+
+ # Cleaning apt package lists
+ if [ "${LB_APT_INDICES}" = "false" ]
+ then
+ rm -rf chroot/var/lib/apt/lists
+ mkdir -p chroot/var/lib/apt/lists/partial
+ fi
+
+ # Remove local package repository
+ rm -f chroot/etc/apt/sources.list.d/packages.list
+ rm -rf chroot/root/packages
+
+ # Removing stage file
+ rm -f .build/chroot_archives
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_cache b/system-build/scripts/build/chroot_cache
new file mode 100755
index 0000000..96f7af2
--- /dev/null
+++ b/system-build/scripts/build/chroot_cache
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'cache chroot stage')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+for STAGE in ${LB_CACHE_STAGES}
+do
+ if [ "${STAGE}" = "chroot" ]
+ then
+ case "${1}" in
+ restore)
+ Echo_message "Restoring chroot stage from cache..."
+
+ # Checking stage file
+ Check_stagefile .build/chroot_cache.restore
+
+ if [ -d cache/chroot ]
+ then
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Removing old chroot
+ rm -rf chroot
+
+ # Restoring old cache
+ cp -a cache/chroot chroot
+
+ # Creating stage file
+ Create_stagefile .build/chroot_cache.restore
+
+ exit 0
+ fi
+ ;;
+
+ save)
+ Echo_message "Saving chroot stage to cache..."
+
+ # Checking stage file
+ Check_stagefile .build/chroot_cache.save
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ rm -rf cache/chroot
+
+ mkdir -p cache
+
+ cp -a chroot cache/chroot
+
+ # Creating stage file
+ Create_stagefile .build/chroot_cache.save
+ ;;
+ esac
+ fi
+done
diff --git a/system-build/scripts/build/chroot_debianchroot b/system-build/scripts/build/chroot_debianchroot
new file mode 100755
index 0000000..77680f0
--- /dev/null
+++ b/system-build/scripts/build/chroot_debianchroot
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /etc/debian_chroot')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Configuring file /etc/debian_chroot"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_debianchroot
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -f chroot/etc/debian_chroot ]
+ then
+ # Save chroot file
+ mv chroot/etc/debian_chroot chroot/etc/debian_chroot.orig
+ fi
+
+ # Create chroot file
+ echo "live" > chroot/etc/debian_chroot
+
+ # Creating stage file
+ Create_stagefile .build/chroot_debianchroot
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /etc/debian_chroot"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -f chroot/etc/debian_chroot.orig ]
+ then
+ # Restore chroot file
+ mv chroot/etc/debian_chroot.orig chroot/etc/debian_chroot
+ else
+ # Remove chroot file
+ rm -f chroot/etc/debian_chroot
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_debianchroot
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_devpts b/system-build/scripts/build/chroot_devpts
new file mode 100755
index 0000000..8fb76a7
--- /dev/null
+++ b/system-build/scripts/build/chroot_devpts
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'mount /dev/pts')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Begin mounting /dev/pts..."
+
+ # Checking stage file
+ Check_stagefile .build/chroot_devpts
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Creating mountpoint
+ mkdir -p chroot/dev/pts
+
+ # Mounting /dev/pts
+ mount devpts-live -t devpts -o gid=5,mode=620 chroot/dev/pts || true
+
+ # Creating stage file
+ Create_stagefile .build/chroot_devpts
+ ;;
+
+ remove)
+ Echo_message "Begin unmounting /dev/pts..."
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Unmounting /dev/pts
+ if grep -qs "$(pwd)/chroot/dev/pts" /proc/mounts || Find_files chroot/dev/pts/*
+ then
+ umount chroot/dev/pts
+ else
+ umount -f chroot/dev/pts > /dev/null 2>&1 || true
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_devpts
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_dpkg b/system-build/scripts/build/chroot_dpkg
new file mode 100755
index 0000000..c6f1574
--- /dev/null
+++ b/system-build/scripts/build/chroot_dpkg
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /sbin/dpkg')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Configuring file /sbin/start-stop-daemon"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_dpkg
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Create custom start-stop-daemon program
+ Chroot chroot dpkg-divert --rename --quiet --add /sbin/start-stop-daemon
+
+cat > chroot/sbin/start-stop-daemon << EOF
+#!/bin/sh
+
+exit 0
+EOF
+
+ chmod 755 chroot/sbin/start-stop-daemon
+
+ # Disable dpkg syncing
+
+cat > chroot/etc/dpkg/dpkg.cfg.d/live-build << EOF
+force-unsafe-io
+EOF
+
+ # Manual hacks for special packages
+
+ # Generic live-build handle for other live packages to act upon
+ touch chroot/.live-build
+
+ # flash-kernel
+ Chroot chroot dpkg-divert --rename --quiet --add /usr/sbin/flash-kernel
+ ln -fs /bin/true chroot/usr/sbin/flash-kernel
+
+ # Creating stage file
+ Create_stagefile .build/chroot_dpkg
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /sbin/start-stop-daemon"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Manual hacks for special packages
+
+ # Generic live-build handle
+ rm -f chroot/.live-build
+
+ # flash-kernel
+ rm -f chroot/usr/sbin/flash-kernel
+ Chroot chroot dpkg-divert --rename --quiet --remove /usr/sbin/flash-kernel
+
+ # Remove custom start-stop-daemon program
+ rm -f chroot/sbin/start-stop-daemon
+ Chroot chroot dpkg-divert --rename --quiet --remove /sbin/start-stop-daemon
+
+ # Remove dpkg sync configuration
+ rm -f chroot/etc/dpkg/dpkg.cfg.d/live-build
+
+ # Removing stage file
+ rm -f .build/chroot_dpkg
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_firmware b/system-build/scripts/build/chroot_firmware
new file mode 100755
index 0000000..d91f570
--- /dev/null
+++ b/system-build/scripts/build/chroot_firmware
@@ -0,0 +1,124 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'schedule kernel packages for installation')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+if [ "${LB_FIRMWARE_CHROOT}" != "true" ]
+then
+ exit 0
+fi
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_firmware
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Checking depends
+Check_package host /usr/bin/wget wget
+
+# Diverting update-initramfs
+#case "${LB_INITRAMFS}" in
+# system-boot)
+# mv chroot/usr/sbin/update-initramfs chroot/usr/sbin/update-initramfs.live-build
+# ;;
+#esac
+
+# Include firmware packages
+# Assumption: firmware packages install files into /lib/firmware
+
+# Get all firmware packages names
+mkdir -p cache/contents.chroot
+
+FIRMWARE_PACKAGES=""
+
+_CONTENTS="$(for _PARENT_ARCHIVE_AREA in ${LB_PARENT_ARCHIVE_AREAS}; do echo ${LB_PARENT_MIRROR_CHROOT}/dists/${LB_PARENT_DISTRIBUTION}/${_PARENT_ARCHIVE_AREA}/Contents-${LB_ARCHITECTURES}.gz; done)"
+
+rm -f cache/contents.chroot/contents.${LB_PARENT_DISTRIBUTION}.${LB_ARCHITECTURES}
+
+for _CONTENT in ${_CONTENTS}
+do
+ wget ${WGET_OPTIONS} ${_CONTENT} -O - | gunzip -c >> cache/contents.chroot/contents.${LB_PARENT_DISTRIBUTION}.${LB_ARCHITECTURES}
+
+ FIRMWARE_PACKAGES="${FIRMWARE_PACKAGES} $(awk '/^lib\/firmware/ { print $2 }' cache/contents.chroot/contents.${LB_PARENT_DISTRIBUTION}.${LB_ARCHITECTURES} | sort -u)"
+done
+
+if echo ${LB_PARENT_ARCHIVE_AREAS} | grep -qs "non-free"
+then
+ # Manually add firmware-linux/non-free meta package
+ if [ "${LB_DERIVATIVE}" != "true" ]
+ then
+ FIRMWARE_PACKAGES="${FIRMWARE_PACKAGES} firmware-linux"
+ else
+ case "${LB_DERIVATIVE_IS_BASED_ON}" in
+ debian)
+ FIRMWARE_PACKAGES="${FIRMWARE_PACKAGES} firmware-linux"
+ ;;
+ *)
+ ;;
+ esac
+ fi
+fi
+
+if [ "${LB_DERIVATIVE}" = "true" ]
+then
+ # FIXME: account for the fact that PARENT_DISTRIBUTION and DISTRIBUTION might be the same (to not have overlapping cache files for contents).
+
+ _CONTENTS="$(for _ARCHIVE_AREA in ${LB_ARCHIVE_AREAS}; do echo ${LB_MIRROR_CHROOT}/dists/${LB_DISTRIBUTION}/${_ARCHIVE_AREA}/Contents-${LB_ARCHITECTURES}.gz; done)"
+
+ rm -f cache/contents.chroot/contents.${LB_DISTRIBUTION}.${LB_ARCHITECTURES}
+
+ for _CONTENT in ${_CONTENTS}
+ do
+ wget ${WGET_OPTIONS} ${_CONTENT} -O - | gunzip -c >> cache/contents.chroot/contents.${LB_DISTRIBUTION}.${LB_ARCHITECTURES}
+
+ FIRMWARE_PACKAGES="${FIRMWARE_PACKAGES} $(awk '/^lib\/firmware/ { print $2 }' cache/contents.chroot/contents.${LB_DISTRIBUTION}.${LB_ARCHITECTURES} | sort -u)"
+ done
+fi
+
+# Drop section and keep package names only
+for _PACKAGE in ${FIRMWARE_PACKAGES}
+do
+ echo $(echo ${_PACKAGE} | awk -F/ '{ print $NF }') >> chroot/root/packages.chroot
+done
+
+# Some known licenses required to be accepted
+if echo ${LB_PARENT_ARCHIVE_AREAS} | grep -qs "non-free"
+then
+
+cat >> chroot/root/packages.chroot.cfg << EOF
+firmware-ivtv firmware-ivtv/license/accepted boolean true
+firmware-ipw2x00 firmware-ipw2x00/license/accepted boolean true
+EOF
+
+fi
+
+# Creating stage file
+Create_stagefile .build/chroot_firmware
diff --git a/system-build/scripts/build/chroot_hacks b/system-build/scripts/build/chroot_hacks
new file mode 100755
index 0000000..f439ca1
--- /dev/null
+++ b/system-build/scripts/build/chroot_hacks
@@ -0,0 +1,128 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'execute hacks in chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+Echo_message "Begin executing hacks..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_hacks
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+case "${LIVE_IMAGE_TYPE}" in
+ netboot)
+ if [ ! -f chroot/sbin/mount.cifs ]
+ then
+ Apt chroot install cifs-utils
+ fi
+
+ if [ ! -d chroot/etc/initramfs-tools ]
+ then
+ mkdir chroot/etc/initramfs-tools
+ fi
+
+ # Configuring initramfs for NFS
+ if ! grep -qs "BOOT=nfs" chroot/etc/initramfs-tools/initramfs.conf
+ then
+ echo "BOOT=nfs" >> chroot/etc/initramfs-tools/initramfs.conf
+ fi
+
+ if ! grep -qs "NFSROOT=auto" chroot/etc/initramfs-tools/initramfs.conf
+ then
+ echo "NFSROOT=auto" >> chroot/etc/initramfs-tools/initramfs.conf
+ fi
+ ;;
+esac
+
+# Update initramfs (always, because of udev rules in initrd)
+case "${LB_INITRAMFS}" in
+ system-boot)
+ #UPDATE_INITRAMFS_OPTIONS="LIVE_GENERATE_UUID=1"
+ ;;
+esac
+
+if [ "${LB_INITRAMFS}" != "none" ]
+then
+ Chroot chroot "${UPDATE_INITRAMFS_OPTIONS} update-initramfs -k all -t -u"
+fi
+
+# We probably ought to use COMPRESS= in a temporary file in
+# /etc/initramfs-tools/conf.d/ instead, but it's hard to pass options that
+# way.
+case "${LB_INITRAMFS_COMPRESSION}" in
+ gzip)
+ ;;
+
+ bzip2)
+ for INITRAMFS in $(find chroot/boot -name 'initrd*'); do
+ zcat "${INITRAMFS}" | bzip2 -c ${BZIP2_OPTIONS} > "${INITRAMFS}.new"
+ mv "${INITRAMFS}.new" "${INITRAMFS}"
+ echo "$(sha1sum ${INITRAMFS} | awk '{ print $1 }') /boot/$(basename ${INITRAMFS})" > chroot/var/lib/initramfs-tools/$(basename ${INITRAMFS} | sed -e 's|initrd.img-||')
+ done
+ ;;
+
+ lzma)
+ for INITRAMFS in $(find chroot/boot -name 'initrd*'); do
+ zcat "${INITRAMFS}" | lzma -c ${LZMA_OPTIONS} > "${INITRAMFS}.new"
+ mv "${INITRAMFS}.new" "${INITRAMFS}"
+ echo "$(sha1sum ${INITRAMFS} | awk '{ print $1 }') /boot/$(basename ${INITRAMFS})" > chroot/var/lib/initramfs-tools/$(basename ${INITRAMFS} | sed -e 's|initrd.img-||')
+ done
+ ;;
+esac
+
+case "${LB_INITRAMFS}" in
+ system-boot)
+ ID="1000"
+ ;;
+
+ *)
+ ID=""
+ ;;
+esac
+
+rm -f chroot/etc/hosts
+
+if [ "${LB_DEBIAN_INSTALLER}" = "live" ]
+then
+ # This is a temporary hack to get rid of fstab;
+ # needs cleanup in system-boot first to proper fix.
+ rm -f chroot/etc/fstab
+ touch chroot/etc/fstab
+fi
+
+if [ "${LB_SWAP_FILE_PATH}" ]; then
+ dd if=/dev/zero of="chroot/${LB_SWAP_FILE_PATH}" bs=1024k count="${LB_SWAP_FILE_SIZE}"
+ mkswap "chroot/${LB_SWAP_FILE_PATH}"
+fi
+
+# Creating stage file
+Create_stagefile .build/chroot_hacks
diff --git a/system-build/scripts/build/chroot_hooks b/system-build/scripts/build/chroot_hooks
new file mode 100755
index 0000000..af20b0d
--- /dev/null
+++ b/system-build/scripts/build/chroot_hooks
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'execute hooks in chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+Echo_message "Begin executing hooks..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_hooks
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+## Processing distribution hooks
+
+# Make build config available to chroot hooks. First, make the bind
+# mount and then make it read-only. This can't happen in one mount
+# command, then the resulting mount will be rw (see mount(8)). Making it
+# ro prevents modifications and prevents accidentally removing the
+# contents of the config directory when removing the chroot.
+mkdir -p chroot/live-build/config
+mount -o bind config chroot/live-build/config
+mount -o remount,ro,bind config chroot/live-build/config
+
+# Copying hooks
+for _HOOK in ${LB_CHROOT_HOOKS}
+do
+ for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks
+ do
+ for FILE in "${LOCATION}"/????-"${_HOOK}".chroot
+ do
+ if [ -e "${FILE}" ]
+ then
+ mkdir -p chroot/root/lb_chroot_hooks
+ cp "${FILE}" chroot/root/lb_chroot_hooks
+ fi
+ done
+ done
+done
+
+# Running hooks
+if ls chroot/root/lb_chroot_hooks/* > /dev/null 2>&1
+then
+ for _HOOK in chroot/root/lb_chroot_hooks/*
+ do
+ Chroot chroot "/root/lb_chroot_hooks/$(basename ${_HOOK})" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ rm -f chroot/root/lb_chroot_hooks/"$(basename ${_HOOK})"
+ done
+
+ rmdir chroot/root/lb_chroot_hooks
+fi
+
+## Processing local hooks
+if ls config/hooks/normal/*.chroot config/hooks/live/*.chroot > /dev/null 2>&1
+then
+ # Restoring cache
+ Restore_cache cache/packages.chroot
+
+ for HOOK in config/hooks/normal/*.chroot config/hooks/live/*.chroot
+ do
+ if [ ! -e "${HOOK}" ]
+ then
+ continue
+ fi
+
+ # Copying hook
+ cp "${HOOK}" chroot/root
+
+ # Making hook executable
+ if [ ! -x chroot/root/"$(basename ${HOOK})" ]
+ then
+ chmod +x chroot/root/"$(basename ${HOOK})"
+ fi
+
+ # Executing hook
+ Chroot chroot "/root/$(basename ${HOOK})" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+
+ # Removing hook
+ rm -f chroot/root/"$(basename ${HOOK})"
+ done
+
+ # Saving cache
+ Save_cache cache/packages.chroot
+
+ # Creating stage file
+ Create_stagefile .build/chroot_hooks
+fi
+
+# Remove bind mount of build config inside chroot.
+umount chroot/live-build/config
+rmdir chroot/live-build/config
+rmdir chroot/live-build
diff --git a/system-build/scripts/build/chroot_hostname b/system-build/scripts/build/chroot_hostname
new file mode 100755
index 0000000..ae191a7
--- /dev/null
+++ b/system-build/scripts/build/chroot_hostname
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /bin/hostname')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ # Checking stage file
+ Check_stagefile .build/chroot_hostname
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Create hostname file
+ Echo_message "Configuring file /etc/hostname"
+
+ echo "localhost.localdomain" > chroot/etc/hostname
+
+ # Create custom hostname
+ Echo_message "Configuring file /bin/hostname"
+
+ Chroot chroot dpkg-divert --rename --quiet --add /bin/hostname
+
+cat > chroot/bin/hostname << EOF
+#!/bin/sh
+
+echo "localhost.localdomain"
+EOF
+
+ chmod 755 chroot/bin/hostname
+
+ # Creating stage file
+ Create_stagefile .build/chroot_hostname
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /etc/hostname"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Copying hostname from includes, if existing
+ if [ -e config/includes.chroot/etc/hostname ]
+ then
+ cp -a config/includes.chroot/etc/hostname chroot/etc/hostname
+ fi
+
+ Echo_message "Deconfiguring file /bin/hostname"
+
+ # Remove custom hostname
+ rm -f chroot/bin/hostname
+ Chroot chroot dpkg-divert --rename --quiet --remove /bin/hostname
+
+ # Removing stage file
+ rm -f .build/chroot_hostname
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_hosts b/system-build/scripts/build/chroot_hosts
new file mode 100755
index 0000000..9f0da29
--- /dev/null
+++ b/system-build/scripts/build/chroot_hosts
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /etc/hosts')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Configuring file /etc/hosts"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_hosts
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -f chroot/etc/hosts ]
+ then
+ # Save hosts file
+ mv chroot/etc/hosts chroot/etc/hosts.orig
+ fi
+
+ # Creating hosts file
+
+cat > chroot/etc/hosts << EOF
+127.0.0.1 localhost localhost.localdomain
+127.0.1.1 debian
+EOF
+
+ if [ -f /etc/hosts ]
+ then
+ # Append hosts file
+ #grep -e "127.0.0.1" -e "127.0.1.1" /etc/hosts >> chroot/etc/hosts
+ cat /etc/hosts >> chroot/etc/hosts
+ fi
+
+ # Creating stage file
+ Create_stagefile .build/chroot_hosts
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /etc/hosts"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -e config/includes.chroot/etc/hosts ]
+ then
+ # Copying local hosts
+ cp -a config/includes.chroot/etc/hosts chroot/etc/hosts
+ rm -f chroot/etc/hosts.orig
+ elif [ -f chroot/etc/hosts.orig ]
+ then
+ # Restore hosts file
+ mv chroot/etc/hosts.orig chroot/etc/hosts
+ else
+ # Blank out hosts file, don't remove in case its a symlink
+ Truncate chroot/etc/hosts
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_hosts
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_includes b/system-build/scripts/build/chroot_includes
new file mode 100755
index 0000000..6498aa3
--- /dev/null
+++ b/system-build/scripts/build/chroot_includes
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'copy files into chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+Echo_message "Begin copying chroot includes..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/includes.chroot
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+if Find_files config/includes.chroot/
+then
+ # Copying includes
+ cd config/includes.chroot
+ find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/chroot
+ cd "${OLDPWD}"
+
+ # Creating stage file
+ Create_stagefile .build/includes.chroot
+fi
diff --git a/system-build/scripts/build/chroot_install-packages b/system-build/scripts/build/chroot_install-packages
new file mode 100755
index 0000000..36c0f93
--- /dev/null
+++ b/system-build/scripts/build/chroot_install-packages
@@ -0,0 +1,94 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'install queued packages into chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+USAGE="${PROGRAM} {install|live} [--force]"
+
+_PASS="${1}"
+shift
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+Echo_message "Begin installing packages (${_PASS} pass)..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_install-packages.${PASS}
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Check for packages specified with foreign architecture
+_FOREIGN_ARCHITECTURES_FILE="chroot/root/packages.foreign-architectures"
+if [ -e "${_FOREIGN_ARCHITECTURES_FILE}" ] && [ -s "${_FOREIGN_ARCHITECTURES_FILE}" ]
+then
+ _APT_ARCHITECTURES_ADDED="0"
+
+ # Check if version of dpkg in chroot supports multiarch
+ if Chroot chroot dpkg --print-foreign-architectures > /dev/null 2>&1
+ then
+ # Add foregin architectures
+ while read _ARCHITECTURES_LINE
+ do
+ Echo_message "Adding foreign architecture ${_ARCHITECTURES_LINE} to dpkg"
+ Chroot chroot dpkg --add-architecture ${_ARCHITECTURES_LINE}
+
+ _APT_ARCHITECTURES_ADDED="1"
+ done < "${_FOREIGN_ARCHITECTURES_FILE}"
+
+ # Tidy up
+ rm -f "${_FOREIGN_ARCHITECTURES_FILE}"
+ else
+ Echo_error "Version of dpkg in chroot does not support foreign architectures."
+ fi
+
+ # Update apt if foreign architectures were added
+ if [ "${_APT_ARCHITECTURES_ADDED}" -ne "0" ]
+ then
+ Echo_message "Added foreign architectures, updating apt..."
+ Apt chroot update
+ fi
+fi
+
+if [ -e chroot/root/packages.chroot ] && [ -s chroot/root/packages.chroot ]
+then
+ # Restoring cache
+ Restore_cache cache/packages.chroot
+
+ # Installing packages
+ Chroot chroot "xargs --arg-file=/root/packages.chroot apt-get ${APT_OPTIONS} install"
+
+ # Tidying up
+ rm -f chroot/root/packages.chroot
+
+ # Saving cache
+ Save_cache cache/packages.chroot
+
+fi
+
+# Creating stage file
+Create_stagefile .build/chroot_install-packages.${_PASS}
diff --git a/system-build/scripts/build/chroot_interactive b/system-build/scripts/build/chroot_interactive
new file mode 100755
index 0000000..f21b6dd
--- /dev/null
+++ b/system-build/scripts/build/chroot_interactive
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'make build interactive')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+if [ "${LB_INTERACTIVE}" = "false" ]
+then
+ exit 0
+fi
+
+Echo_message "Begin interactive build..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_interactive
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+case "${LB_INTERACTIVE}" in
+ true|shell)
+ Echo_message "Pausing build: starting interactive shell..."
+ Chroot chroot "/bin/bash --login"
+ ;;
+ x11)
+ Echo_message "Pausing build: starting interactive X11..."
+ Chroot chroot "startx"
+ ;;
+ xnest)
+ Echo_message "Pausing build: starting interactive Xnest..."
+ #Chroot chroot "" # FIXME
+ ;;
+esac
+
+# Creating stage file
+Create_stagefile .build/chroot_interactive
diff --git a/system-build/scripts/build/chroot_linux-image b/system-build/scripts/build/chroot_linux-image
new file mode 100755
index 0000000..c28cb54
--- /dev/null
+++ b/system-build/scripts/build/chroot_linux-image
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'schedule kernel packages for installation')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+if [ "${LB_LINUX_PACKAGES}" = "none" ]
+then
+ exit 0
+fi
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_linux-image
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Diverting update-initramfs
+#case "${LB_INITRAMFS}" in
+# system-boot)
+# mv chroot/usr/sbin/update-initramfs chroot/usr/sbin/update-initramfs.live-build
+# ;;
+#esac
+
+for FLAVOUR in ${LB_LINUX_FLAVOURS}
+do
+ for PACKAGE in ${LB_LINUX_PACKAGES}
+ do
+ echo ${PACKAGE}-${FLAVOUR} >> chroot/root/packages.chroot
+ done
+done
+
+# Creating stage file
+Create_stagefile .build/chroot_linux-image
diff --git a/system-build/scripts/build/chroot_live-packages b/system-build/scripts/build/chroot_live-packages
new file mode 100755
index 0000000..0e4f2bf
--- /dev/null
+++ b/system-build/scripts/build/chroot_live-packages
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'schedule live packages for installation')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_live-packages
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Queue installation of system-boot
+if [ -n "${LB_INITRAMFS}" ] && [ "${LB_INITRAMFS}" != "none" ]
+then
+ _PACKAGES="${LB_INITRAMFS}"
+fi
+
+# Queue installation of system-config
+if [ -n "${LB_INITSYSTEM}" ] && [ "${LB_INITSYSTEM}" != "none" ]
+then
+ _PACKAGES="${_PACKAGES} system-config"
+fi
+
+# Do initsystem specific hacks
+case "${LB_INITSYSTEM}" in
+ systemd)
+ _PACKAGES="${_PACKAGES} systemd-sysv"
+
+ if [ -e chroot/var/lib/dpkg/info/sysvinit.list ]
+ then
+ Chroot chroot "dpkg --force-remove-essential --purge sysvinit"
+ fi
+ ;;
+
+ sysvinit)
+ _PACKAGES="${_PACKAGES} sysvinit"
+
+ if [ -e chroot/var/lib/dpkg/info/systemd-sysv.list ]
+ then
+ Chroot chroot "dpkg --force-remove-essential --purge systemd systemd-sysv"
+ fi
+ ;;
+esac
+
+# Install live packages
+if [ -n "${_PACKAGES}" ]
+then
+ Chroot chroot "apt-get ${APT_OPTIONS} install ${_PACKAGES}"
+
+ # Creating stage file
+ Create_stagefile .build/chroot_live-packages
+fi
diff --git a/system-build/scripts/build/chroot_package-lists b/system-build/scripts/build/chroot_package-lists
new file mode 100755
index 0000000..7e93e61
--- /dev/null
+++ b/system-build/scripts/build/chroot_package-lists
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'queue install of package lists into chroot')"
+HELP=""
+USAGE="${PROGRAM} {install|live} [--force]"
+
+_PASS="${1}"
+shift
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+Echo_message "Begin queueing installation of package lists (${_PASS} pass)..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_package-lists.${_PASS}
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Handling local package lists
+if ! ( ls config/package-lists/*.list > /dev/null 2>&1 || \
+ ls config/package-lists/*.list.chroot > /dev/null 2>&1 || \
+ ls config/package-lists/*.list.chroot_${_PASS} > /dev/null 2>&1 )
+then
+ exit 0
+fi
+
+case "${LB_BUILD_WITH_CHROOT}" in
+ true)
+ # Checking depends
+ Check_package chroot /usr/bin/grep-aptavail dctrl-tools
+
+ # Restoring cache
+ Restore_cache cache/packages.chroot
+
+ # Installing depends
+ Install_package
+ ;;
+
+ false)
+ if [ ! -e /usr/bin/grep-aptavail ]; then
+ # dctrl-tools
+ Echo_error "/usr/bin/grep-aptavail - no such file."
+ exit 1
+ fi
+ ;;
+esac
+
+if [ -e "${LIVE_BUILD}/share/bin/Packages" ]
+then
+ cp "${LIVE_BUILD}/share/bin/Packages" chroot/bin
+else
+ cp /usr/share/live/build/bin/Packages chroot/bin
+fi
+
+for LIST in config/package-lists/*.list \
+ config/package-lists/*.list.chroot \
+ config/package-lists/*.list.chroot_${_PASS}
+do
+ if [ -e "${LIST}" ]
+ then
+ # Generating package list
+ Expand_packagelist "$(basename ${LIST})" "config/package-lists" \
+ | grep -v '^#' >> chroot/root/packages.chroot
+ fi
+done
+
+# Discover unique package architectures in fully-expanded package list
+for _PACKAGE_ARCHITECTURE in $(Discover_package_architectures "chroot/root/packages.chroot")
+do
+ # If this is a foreign architecture, append to packages.foreign-architectures
+ if [ "${_PACKAGE_ARCHITECTURE}" != "${LB_ARCHITECTURES}" ]
+ then
+ Echo_message "Accepting foreign architecture: ${_PACKAGE_ARCHITECTURE}, live image architecture is: ${LB_ARCHITECTURES}"
+ echo "${_PACKAGE_ARCHITECTURE}" >> chroot/root/packages.foreign-architectures
+ fi
+done
+
+rm -f chroot/bin/Packages
+
+case "${LB_BUILD_WITH_CHROOT}" in
+ true)
+ # Removing dctrl-tools again if the user has not installed it
+ if ! grep -qs dctrl-tools chroot/root/packages.chroot
+ then
+ # Removing depends
+ Remove_package
+ fi
+
+ # Saving cache
+ Save_cache cache/packages.chroot
+ ;;
+esac
+
+# Creating stage file
+Create_stagefile .build/chroot_package-lists.${_PASS}
diff --git a/system-build/scripts/build/chroot_preseed b/system-build/scripts/build/chroot_preseed
new file mode 100755
index 0000000..53bd8df
--- /dev/null
+++ b/system-build/scripts/build/chroot_preseed
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'execute local preseed in chroot')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+Echo_message "Begin executing local preseeds..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/chroot_preseed
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+if ls config/preseed/*.cfg > /dev/null 2>&1 || \
+ ls config/preseed/*.cfg.chroot > /dev/null 2>&1 || \
+ ls chroot/root/packages.chroot.cfg > /dev/null 2>&1
+then
+ # Check dependency
+ Check_package chroot /usr/bin/debconf-set-selections debconf
+
+ # Install dependency
+ Install_package
+
+ for PRESEED in config/preseed/*.cfg config/preseed/*.cfg.chroot chroot/root/packages.chroot.cfg
+ do
+ if [ -e "${PRESEED}" ]
+ then
+ # Copying local preseed
+ cp "${PRESEED}" chroot/root/preseed
+
+ Chroot chroot "debconf-set-selections /root/preseed"
+
+ # Removing local preseed file
+ rm -f chroot/root/preseed
+ fi
+ done
+
+ rm -f chroot/root/packages.chroot.cfg
+
+ # Remove dependency
+ Remove_package
+
+ # Creating stage file
+ Create_stagefile .build/chroot_preseed
+fi
diff --git a/system-build/scripts/build/chroot_proc b/system-build/scripts/build/chroot_proc
new file mode 100755
index 0000000..f84c0d4
--- /dev/null
+++ b/system-build/scripts/build/chroot_proc
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'mount /proc')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Begin mounting /proc..."
+
+ # Checking stage file
+ Check_stagefile .build/chroot_proc
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Creating mountpoint
+ mkdir -p chroot/proc
+
+ # Mounting /proc
+ mount proc-live -t proc chroot/proc
+
+ # Creating stage file
+ Create_stagefile .build/chroot_proc
+ ;;
+
+ remove)
+ Echo_message "Begin unmounting /proc..."
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Workaround binfmt-support /proc locking
+ if [ -e chroot/proc/sys/fs/binfmt_misc/status ]
+ then
+ umount chroot/proc/sys/fs/binfmt_misc
+ fi
+
+ # Unmounting /proc
+ if [ -e chroot/proc/version ]
+ then
+ umount chroot/proc
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_proc
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_resolv b/system-build/scripts/build/chroot_resolv
new file mode 100755
index 0000000..7cf55fc
--- /dev/null
+++ b/system-build/scripts/build/chroot_resolv
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /etc/resolv.conf')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Configuring file /etc/resolv.conf"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_resolv
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -e chroot/etc/resolv.conf ]
+ then
+ # Save resolv file or symlink
+ mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig
+
+ # Also truncate it, otherwise we'll end up with the one
+ # created by debootstrap in the final image.
+ #
+ # If you want to have a custom resolv.conf, please
+ # overwrite it with normal local_includes mechanism.
+ Truncate chroot/etc/resolv.conf.orig
+ elif [ -L chroot/etc/resolv.conf ]
+ then
+ # Move resolv.conf aside if it's a symlink (likely resolvconf)
+ mv chroot/etc/resolv.conf chroot/etc/resolv.conf.orig
+ fi
+
+ if [ -f /etc/resolv.conf ]
+ then
+ # Copy resolv file
+ cp /etc/resolv.conf chroot/etc/resolv.conf
+ fi
+
+ # Creating stage file
+ Create_stagefile .build/chroot_resolv
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /etc/resolv.conf"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -e config/includes.chroot/etc/resolv.conf ]
+ then
+ # Copying local resolv.conf
+ cp -a config/includes.chroot/etc/resolv.conf chroot/etc/resolv.conf
+ rm -f chroot/etc/resolv.conf.orig
+ elif [ -e chroot/etc/resolv.conf.orig ] || [ -L chroot/etc/resolv.conf.orig ]
+ then
+ # Restoring resolv file or symlink
+ mv chroot/etc/resolv.conf.orig chroot/etc/resolv.conf
+ else
+ # Truncating resolv file
+ Truncate chroot/etc/resolv.conf
+ fi
+
+ # Clean up resolvconf's pollution
+ if [ -e chroot/etc/resolvconf/resolv.conf.d ]
+ then
+ rm -f chroot/etc/resolvconf/resolv.conf.d/original
+ rm -f chroot/etc/resolvconf/resolv.conf.d/tail
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_resolv
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_selinuxfs b/system-build/scripts/build/chroot_selinuxfs
new file mode 100755
index 0000000..66d4639
--- /dev/null
+++ b/system-build/scripts/build/chroot_selinuxfs
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'mount /sys/fs/selinux')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ if [ -e /sys/fs/selinux/enforce ] && [ "$(cat /sys/fs/selinux/enforce)" = "1" ]
+ then
+ Echo_message "Begin mounting /sys/fs/selinux..."
+
+ # Checking stage file
+ Check_stagefile .build/chroot_selinuxfs
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Create mountpoint
+ mkdir -p chroot/sys/fs/selinux
+
+ # Mounting /sys/fs/selinux
+ mount selinuxfs-live -t selinuxfs chroot/sys/fs/selinux
+
+ # Creating stage file
+ Create_stagefile .build/chroot_selinuxfs
+ fi
+ ;;
+
+ remove)
+ Echo_message "Begin unmounting /sys/fs/selinux..."
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Unmounting /sys/fs/selinux
+ if [ -e chroot/sys/fs/selinux/enforce ]
+ then
+ umount chroot/sys/fs/selinux
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_selinux
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_sysfs b/system-build/scripts/build/chroot_sysfs
new file mode 100755
index 0000000..a0637f1
--- /dev/null
+++ b/system-build/scripts/build/chroot_sysfs
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'mount /sys')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Begin mounting /sys..."
+
+ # Checking stage file
+ Check_stagefile .build/chroot_sysfs
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Create mountpoint
+ mkdir -p chroot/sys
+
+ # Mounting /sys
+ mount sysfs-live -t sysfs chroot/sys
+
+ # Creating stage file
+ Create_stagefile .build/chroot_sysfs
+ ;;
+
+ remove)
+ Echo_message "Begin unmounting /sys..."
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Unmounting /sys
+ if [ -e chroot/sys/class ]
+ then
+ umount chroot/sys
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_sysfs
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_sysv-rc b/system-build/scripts/build/chroot_sysv-rc
new file mode 100755
index 0000000..a613fd4
--- /dev/null
+++ b/system-build/scripts/build/chroot_sysv-rc
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'manage /usr/sbin/policy-rc.d')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Configuring file /usr/sbin/policy-rc.d"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_sysv-rc
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ if [ -e chroot/usr/sbin/policy-rc.d ]
+ then
+ # Save policy-rc.d file
+ Chroot chroot dpkg-divert --rename --quiet --add /usr/sbin/policy-rc.d
+ fi
+
+ # Create policy-rc.d file
+cat > chroot/usr/sbin/policy-rc.d << EOF
+#!/bin/sh
+echo "All runlevel operations denied by policy" >&2
+exit 101
+EOF
+
+ chmod 0755 chroot/usr/sbin/policy-rc.d
+
+ # Creating stage file
+ Create_stagefile .build/chroot_sysv-rc
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring file /usr/sbin/policy-rc.d"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ # Remove custom policy-rc.d file
+ rm -f chroot/usr/sbin/policy-rc.d
+
+ if [ -e chroot/usr/sbin/policy-rc.d.distrib ]
+ then
+ # Restore policy-rc.d file
+ Chroot chroot dpkg-divert --rename --quiet --remove /usr/sbin/policy-rc.d
+ fi
+
+ # Removing stage file
+ rm -f .build/chroot_sysv-rc
+ ;;
+
+ *)
+ Usage
+ ;;
+esac
diff --git a/system-build/scripts/build/chroot_tmpfs b/system-build/scripts/build/chroot_tmpfs
new file mode 100755
index 0000000..a7a1d72
--- /dev/null
+++ b/system-build/scripts/build/chroot_tmpfs
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## 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="$(Echo 'use tmpfs to speedup the build')"
+HELP=""
+USAGE="${PROGRAM} {install|remove} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/system config/binary config/source
+Set_defaults
+
+if [ "${LB_BUILD_WITH_TMPFS}" != "true" ]
+then
+ exit 0
+fi
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+case "${1}" in
+ install)
+ Echo_message "Configuring tmpfs for /var/lib/dpkg"
+
+ # Checking stage file
+ Check_stagefile .build/chroot_tmpfs
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ mv chroot/var/lib/dpkg chroot/var/lib/dpkg.tmp
+ mkdir chroot/var/lib/dpkg
+ mount -t tmpfs tmpfs chroot/var/lib/dpkg
+ mv chroot/var/lib/dpkg.tmp/* chroot/var/lib/dpkg
+ rm -rf chroot/var/lib/dpkg.tmp
+
+ # Creating stage file
+ Create_stagefile .build/chroot_tmpfs
+ ;;
+
+ remove)
+ Echo_message "Deconfiguring tmpfs for /var/lib/dpkg"
+
+ # Checking lock file
+ Check_lockfile .lock
+
+ # Creating lock file
+ Create_lockfile .lock
+
+ mkdir -p chroot/var/lib/dpkg.tmp
+ mv chroot/var/lib/dpkg/* chroot/var/lib/dpkg.tmp
+ umount chroot/var/lib/dpkg
+ rm -rf chroot/var/lib/dpkg
+ mv chroot/var/lib/dpkg.tmp chroot/var/lib/dpkg
+
+ # Removing stage file
+ rm -f .build/chroot_tmpfs
+ ;;
+
+ *)
+ Usage
+ ;;
+esac