diff options
Diffstat (limited to 'scripts/build')
-rwxr-xr-x | scripts/build/binary | 4 | ||||
-rwxr-xr-x | scripts/build/binary_hooks | 78 | ||||
-rwxr-xr-x | scripts/build/binary_includes | 57 | ||||
-rwxr-xr-x | scripts/build/bootstrap | 8 | ||||
-rwxr-xr-x | scripts/build/bootstrap_archive-keys | 77 | ||||
-rwxr-xr-x | scripts/build/bootstrap_cache | 86 | ||||
-rwxr-xr-x | scripts/build/bootstrap_cdebootstrap | 143 | ||||
-rwxr-xr-x | scripts/build/bootstrap_debootstrap | 139 | ||||
-rwxr-xr-x | scripts/build/build | 1 | ||||
-rwxr-xr-x | scripts/build/chroot | 4 | ||||
-rwxr-xr-x | scripts/build/chroot_hooks | 115 | ||||
-rwxr-xr-x | scripts/build/chroot_includes | 50 | ||||
-rwxr-xr-x | scripts/build/chroot_live-packages | 87 | ||||
-rwxr-xr-x | scripts/build/config | 17 | ||||
-rwxr-xr-x | scripts/build/source | 4 | ||||
-rwxr-xr-x | scripts/build/source_debian-live | 62 | ||||
-rwxr-xr-x | scripts/build/source_hooks | 78 |
17 files changed, 998 insertions, 12 deletions
diff --git a/scripts/build/binary b/scripts/build/binary index 60e053203..c1f9ec662 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -67,8 +67,8 @@ lb binary_syslinux ${@} lb binary_disk ${@} lb binary_loadlin ${@} lb binary_win32-loader ${@} -lb binary-includes ${@} -lb binary-hooks ${@} +lb binary_includes ${@} +lb binary_hooks ${@} lb binary_checksums ${@} if [ "${LB_BUILD_WITH_CHROOT}" != "true" ] diff --git a/scripts/build/binary_hooks b/scripts/build/binary_hooks new file mode 100755 index 000000000..91340adcc --- /dev/null +++ b/scripts/build/binary_hooks @@ -0,0 +1,78 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot 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/binary_hooks + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +## Processing distribution hooks + +# Running hooks +for _HOOK in ${LB_BINARY_HOOKS} +do + for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks + do + for FILE in "${LOCATION}"/????-"${_HOOK}".binary + do + if [ -e "${FILE}" ] + then + cd binary + "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + cd "${OLDPWD}" + fi + done + done +done + +## Processing local hooks + +if Find_files config/hooks/*.binary +then + for HOOK in config/hooks/*.binary + do + # Making hook executable + if [ ! -x "${HOOK}" ] + then + chmod +x "${HOOK}" + fi + + # Executing hook + ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + done + + # Creating stage file + Create_stagefile .build/binary_hooks +fi diff --git a/scripts/build/binary_includes b/scripts/build/binary_includes new file mode 100755 index 000000000..68edfd6fa --- /dev/null +++ b/scripts/build/binary_includes @@ -0,0 +1,57 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 binary')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +Echo_message "Begin copying binary includes..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/includes.binary + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +if Find_files config/includes.binary/ +then + # Copying includes + cd config/includes.binary + find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/binary + cd "${OLDPWD}" + + # Removing symlinks + case "${LIVE_IMAGE_TYPE}" in + hdd*) + find binary -type l | xargs rm -f + ;; + esac + + # Creating stage file + Create_stagefile .build/binary_includes +fi diff --git a/scripts/build/bootstrap b/scripts/build/bootstrap index dcee793c2..8a8293a5c 100755 --- a/scripts/build/bootstrap +++ b/scripts/build/bootstrap @@ -35,7 +35,11 @@ Set_defaults Setup_cleanup # Bootstrapping system -lb bootstrap-${LB_BOOTSTRAP} +lb bootstrap_cache restore ${@} +lb bootstrap_cdebootstrap ${@} +lb bootstrap_debootstrap ${@} +lb bootstrap_archive-keys ${@} +lb bootstrap_cache save ${@} # Configuring chroot lb chroot_devpts install ${@} @@ -53,8 +57,6 @@ lb chroot_hostname install ${@} lb chroot_apt install ${@} lb bootstrap_archives binary ${@} -lb bootstrap-includes ${@} -lb bootstrap-hooks ${@} # Deconfiguring chroot lb chroot_apt remove ${@} diff --git a/scripts/build/bootstrap_archive-keys b/scripts/build/bootstrap_archive-keys new file mode 100755 index 000000000..4b9324f51 --- /dev/null +++ b/scripts/build/bootstrap_archive-keys @@ -0,0 +1,77 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 'bootstrap non-Debian archive-signing-keys')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +# TODO: allow verification against user-specified keyring +# For now, we'll only validate against debian-keyring + +# TODO2: use chrooted validation rather than host system based one + +case "${LB_MODE}" in + progress-linux) + case "${LB_DISTRIBUTION}" in + artax*) + _KEYS="1.0-artax 1.0-artax-packages" + ;; + + baureo*) + _KEYS="2.0-baureo 2.0-baureo-packages" + ;; + + chairon*) + _KEYS="3.0-chairon 3.0-chairon-packages" + ;; + esac + + _URL="${LB_MIRROR_CHROOT}/project/keys" + ;; +esac + +for _KEY in ${_KEYS} +do + Echo_message "Fetching archive-key ${_KEY}..." + + wget -q "${_URL}/archive-key-${_KEY}.asc" -O chroot/key.asc + wget -q "${_URL}/archive-key-${_KEY}.asc.sig" -O chroot/key.asc.sig + + if [ -e /usr/bin/gpgv ] && [ -e /usr/share/keyrings/debian-keyring.gpg ] + then + Echo_message "Verifying archive-key ${_KEY} against debian-keyring..." + + /usr/bin/gpgv --quiet --keyring /usr/share/keyrings/debian-keyring.gpg chroot/key.asc.sig chroot/key.asc > /dev/null 2>&1 || { Echo_error "archive-key ${_KEY} has invalid signature."; return 1;} + else + Echo_warning "Skipping archive-key ${_KEY} verification, either gpgv or debian-keyring not available on host system..." + fi + + Echo_message "Importing archive-key ${_KEY}..." + + Chroot chroot "apt-key add key.asc" + rm -f chroot/key.asc chroot/key.asc.sig +done + +Chroot chroot "apt-get update" + +# Creating stage file +Create_stagefile .build/bootstrap_archive-keys diff --git a/scripts/build/bootstrap_cache b/scripts/build/bootstrap_cache new file mode 100755 index 000000000..c9b28d78d --- /dev/null +++ b/scripts/build/bootstrap_cache @@ -0,0 +1,86 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 bootstrap stage')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +# Check architecture +Check_crossarchitectures + +for STAGE in ${LB_CACHE_STAGES} +do + if [ "${STAGE}" = "bootstrap" ] + then + case "${1}" in + restore) + Echo_message "Restoring bootstrap stage from cache..." + + # Checking stage file + Check_stagefile .build/bootstrap_cache.restore + + if [ -d cache/bootstrap ] + 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/bootstrap chroot + + # Creating stage file + Create_stagefile .build/bootstrap_cache.restore + Create_stagefile .build/bootstrap + + exit 0 + fi + ;; + + save) + Echo_message "Saving bootstrap stage to cache..." + + # Checking stage file + Check_stagefile .build/bootstrap_cache.save + + # Checking lock file + Check_lockfile .lock + + # Creating lock file + Create_lockfile .lock + + rm -rf cache/bootstrap + + mkdir -p cache + + cp -a chroot cache/bootstrap + + # Creating stage file + Create_stagefile .build/bootstrap_cache.save + ;; + esac + fi +done diff --git a/scripts/build/bootstrap_cdebootstrap b/scripts/build/bootstrap_cdebootstrap new file mode 100755 index 000000000..5704ee538 --- /dev/null +++ b/scripts/build/bootstrap_cdebootstrap @@ -0,0 +1,143 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 'bootstrap a Debian system with cdebootstrap(1)')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +if [ "${LB_BOOTSTRAP}" != "cdebootstrap" ] && [ "${LB_BOOTSTRAP}" != "cdebootstrap-static" ] +then + exit 0 +fi + +if [ ! -x "$(which cdebootstrap 2>/dev/null)" ] +then + echo "E: cdebootstrap - command not found" + echo "I: cdebootstrap can be obtained from http://ftp.debian.org/debian/pool/main/d/cdebootstrap/" + echo "I: On Debian based systems, cdebootstrap can be installed with 'apt-get install cdebootstrap'." + exit 1 +fi + +# Check architecture +Check_crossarchitectures + +Echo_message "Begin bootstrapping system..." + +Check_package /usr/bin/${LB_BOOTSTRAP} cdebootstrap + +# Ensure that a system is built as root +lb testroot + +# Checking stage file +Check_stagefile .build/bootstrap +Check_stagefile .build/bootstrap_cache.restore + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Creating chroot directory +mkdir -p chroot + +# Setting cdebootstrap options +if [ -n "${LIVE_IMAGE_ARCHITECTURE}" ] +then + CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --arch=${LIVE_IMAGE_ARCHITECTURE}" +fi + +if [ "${_DEBUG}" = "true" ] +then + CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --debug" +fi + +if [ "${_QUIET}" = "true" ] +then + CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --quiet" +fi + +if [ "${_VERBOSE}" = "true" ] +then + CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --verbose" +fi + +if [ "${LB_APT_SECURE}" = "false" ] +then + CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --allow-unauthenticated" +fi + +if [ -x "/usr/bin/cdebootstrap" ] || [ -x "/usr/bin/cdebootstrap-static" ] +then + if [ "${LB_CACHE_PACKAGES}" = "true" ] + then + if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1 + then + mkdir -p chroot/var/cache/bootstrap + cp cache/packages.bootstrap/*.deb chroot/var/cache/bootstrap + fi + + Echo_breakage "Running ${LB_BOOTSTRAP} (download-only)... " + ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" + + # Removing old cache + rm -f cache/packages.bootstrap/*.deb + + # Saving new cache + mkdir -p cache/packages.bootstrap + cp chroot/var/cache/bootstrap/*.deb cache/packages.bootstrap + fi + + Echo_breakage "Running ${LB_BOOTSTRAP}... " + + # Run appropriate bootstrap, i.e. foreign or regular bootstrap + if [ "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" = "${LIVE_IMAGE_ARCHITECTURE}" ]; then + + if [ -n "${LB_BOOTSTRAP_QEMU_EXCLUDE}" ] + then + CDEBOOTSTRAP_OPTIONS="${CDEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_QEMU_EXCLUDE} | sed 's| *|,|g')" + fi + + Echo_message "Bootstrap will be foreign" + ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" + + Echo_message "Running debootstrap second stage under QEMU" + cp ${LB_BOOTSTRAP_QEMU_STATIC} chroot/usr/bin + Chroot chroot /bin/sh /sbin/cdebootstrap-foreign + else + ${LB_BOOTSTRAP} ${CDEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" + fi + + # Deconfiguring cdebootstrap configurations + rm -f chroot/etc/apt/sources.list + rm -f chroot/etc/hosts + rm -f chroot/etc/resolv.conf + + # Removing bootstrap cache + rm -rf chroot/var/cache/bootstrap + + # Creating stage file + Create_stagefile .build/bootstrap +else + Echo_error "Can't process file /usr/bin/${LB_BOOTSTRAP} (FIXME)" + exit 1 +fi diff --git a/scripts/build/bootstrap_debootstrap b/scripts/build/bootstrap_debootstrap new file mode 100755 index 000000000..9ecceb80f --- /dev/null +++ b/scripts/build/bootstrap_debootstrap @@ -0,0 +1,139 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 'bootstrap a Debian system with debootstrap(8)')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +if [ "${LB_BOOTSTRAP}" != "debootstrap" ] +then + exit 0 +fi + +if [ ! -x "$(which debootstrap 2>/dev/null)" ] +then + echo "E: debootstrap - command not found" + echo "I: debootstrap can be obtained from http://ftp.debian.org/debian/pool/main/d/debootstrap/" + echo "I: On Debian based systems, debootstrap can be installed with 'apt-get install debootstrap'." + exit 1 +fi + +# Check architecture +Check_crossarchitectures + +Echo_message "Begin bootstrapping system..." + +Check_package /usr/sbin/debootstrap debootstrap + +# Ensure that a system is built as root +lb testroot + +# Checking stage file +Check_stagefile .build/bootstrap +Check_stagefile .build/bootstrap_cache.restore + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Creating chroot directory +mkdir -p chroot + +# Setting debootstrap options +if [ -n "${LIVE_IMAGE_ARCHITECTURE}" ] +then + DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --arch=${LIVE_IMAGE_ARCHITECTURE}" +fi + +if [ "${LIVE_IMAGE_ARCHIVE_AREAS}" != "main" ] +then + # Modify archive areas to remove leading/trailing whitespaces and replace other whitepspace with commas + DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --components=$(echo ${LIVE_IMAGE_ARCHIVE_AREAS} | sed -e 's| |,|g')" +fi + +if [ "${_VERBOSE}" = "true" ] +then + DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --verbose" +fi + +# If LB_APT_SECURE is false, do not check signatures of the Release file +# (requires debootstrap >= 1.0.30) +if [ "${LB_APT_SECURE}" = "false" ] && /usr/sbin/debootstrap --help | grep -qs '\-\-no-check-gpg' +then + DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --no-check-gpg" +fi + +if [ -x "/usr/sbin/debootstrap" ] +then + if [ "${LB_CACHE_PACKAGES}" = "true" ] + then + if ls cache/packages.bootstrap/*.deb > /dev/null 2>&1 + then + mkdir -p chroot/var/cache/apt/archives + cp cache/packages.bootstrap/*.deb chroot/var/cache/apt/archives + fi + + Echo_breakage "Running debootstrap (download-only)... " + debootstrap ${DEBOOTSTRAP_OPTIONS} --download-only "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" + + # Removing old cache + rm -f cache/packages.bootstrap/*.deb + + # Saving new cache + mkdir -p cache/packages.bootstrap + cp chroot/var/cache/apt/archives/*.deb cache/packages.bootstrap + fi + + Echo_breakage "Running debootstrap... " + + # Run appropriate bootstrap, i.e. foreign or regular bootstrap + if [ "${LB_BOOTSTRAP_QEMU_ARCHITECTURES}" = "${LIVE_IMAGE_ARCHITECTURE}" ]; then + + if [ -n "${LB_BOOTSTRAP_QEMU_EXCLUDE}" ] + then + DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --exclude=$(echo ${LB_BOOTSTRAP_QEMU_EXCLUDE} | sed 's| *|,|g')" + fi + + Echo_message "Bootstrap will be foreign" + debootstrap ${DEBOOTSTRAP_OPTIONS} --foreign "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" + + Echo_message "Running debootstrap second stage under QEMU" + cp ${LB_BOOTSTRAP_QEMU_STATIC} chroot/usr/bin + Chroot chroot /bin/sh /debootstrap/debootstrap --second-stage + else + debootstrap ${DEBOOTSTRAP_OPTIONS} "${LB_PARENT_DISTRIBUTION}" chroot "${LB_PARENT_MIRROR_BOOTSTRAP}" + fi + + # Deconfiguring debootstrap configurations + rm -f chroot/etc/hosts + + # Removing bootstrap cache + rm -f chroot/var/cache/apt/archives/*.deb + + # Creating stage file + Create_stagefile .build/bootstrap +else + Echo_error "Can't process file /usr/bin/debootstrap (FIXME)" + exit 1 +fi diff --git a/scripts/build/build b/scripts/build/build index 1e73ce564..9c3cf4f9c 100755 --- a/scripts/build/build +++ b/scripts/build/build @@ -17,7 +17,6 @@ set -e if [ -x auto/config ] && [ ! -e .build/config ] then Echo_message "Automatically populating config tree." - lb init lb config fi diff --git a/scripts/build/chroot b/scripts/build/chroot index d1be31c5d..beeca1158 100755 --- a/scripts/build/chroot +++ b/scripts/build/chroot @@ -67,8 +67,8 @@ do fi done -lb chroot-includes ${@} -lb chroot-hooks ${@} +lb chroot_includes ${@} +lb chroot_hooks ${@} lb chroot_hacks ${@} lb chroot_interactive ${@} diff --git a/scripts/build/chroot_hooks b/scripts/build/chroot_hooks new file mode 100755 index 000000000..59cf286bf --- /dev/null +++ b/scripts/build/chroot_hooks @@ -0,0 +1,115 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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/chroot 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 Find_files config/hooks/*.chroot +then + # Restoring cache + Restore_cache cache/packages.chroot + + for _HOOK in config/hooks/*.chroot + do + # 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 + diff --git a/scripts/build/chroot_includes b/scripts/build/chroot_includes new file mode 100755 index 000000000..78a416620 --- /dev/null +++ b/scripts/build/chroot_includes @@ -0,0 +1,50 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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/chroot 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/chroot_includes +fi diff --git a/scripts/build/chroot_live-packages b/scripts/build/chroot_live-packages new file mode 100755 index 000000000..603dc0ef0 --- /dev/null +++ b/scripts/build/chroot_live-packages @@ -0,0 +1,87 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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/chroot 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 live-boot +if [ -n "${LB_INITRAMFS}" ] && [ "${LB_INITRAMFS}" != "none" ] +then + _PACKAGES="${LB_INITRAMFS}" +fi + +# Queue installation of live-config +if [ -n "${LB_INITSYSTEM}" ] && [ "${LB_INITSYSTEM}" != "none" ] +then + _PACKAGES="${_PACKAGES} live-config live-config-${LB_INITSYSTEM}" +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 + case "${LB_APT}" in + apt|apt-get) + Chroot chroot "apt-get ${APT_OPTIONS} install ${_PACKAGES}" + ;; + + aptitude) + Chroot chroot "aptitude ${APTITUDE_OPTIONS} install ${_PACKAGES}" + ;; + esac + + # Creating stage file + Create_stagefile .build/chroot_live-packages +fi diff --git a/scripts/build/config b/scripts/build/config index e3ae1410d..6e390e74d 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -883,8 +883,8 @@ Check_defaults if [ ! -e config ] then - Echo_error "fatal: Not a live-build directory: use 'lb init' to initialize it" - exit 1 + Echo_message "Creating config tree for a ${LB_MODE}/${LB_DISTRIBUTION}/${LIVE_IMAGE_ARCHITECTURE} system" + mkdir config else Echo_message "Updating config tree for a ${LB_MODE}/${LB_DISTRIBUTION}/${LIVE_IMAGE_ARCHITECTURE} system" fi @@ -1338,6 +1338,19 @@ then rmdir --ignore-fail-on-non-empty local > /dev/null 2>&1 || true fi +mkdir -p config/hooks +mkdir -p config/includes config/includes.bootstrap config/includes.chroot config/includes.binary config/includes.source + +Echo_message "Symlinking hooks..." + +for _HOOK in "${LIVE_BUILD}"/share/hooks/*.hook* /usr/share/live/build/hooks/*.hook* +do + if [ -e "${_HOOK}" ] && [ ! -e "config/hooks/$(basename ${_HOOK})" ] + then + ln -s "${_HOOK}" "config/hooks/$(basename ${_HOOK})" + fi +done + cat > config/build << EOF [Image] Architecture: ${LIVE_IMAGE_ARCHITECTURE} diff --git a/scripts/build/source b/scripts/build/source index 3f68aae86..a4fd58a17 100755 --- a/scripts/build/source +++ b/scripts/build/source @@ -51,8 +51,8 @@ lb chroot_archives source install ${@} lb source_live ${@} lb source_debian ${@} lb source_disk ${@} -lb source-includes ${@} -lb source-hooks ${@} +lb source_includes ${@} +lb source_hooks ${@} lb source_checksums ${@} # Building images diff --git a/scripts/build/source_debian-live b/scripts/build/source_debian-live new file mode 100755 index 000000000..6c825e72b --- /dev/null +++ b/scripts/build/source_debian-live @@ -0,0 +1,62 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 debian-live config into source')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +if [ "${LB_SOURCE}" != "true" ] +then + exit 0 +fi + +Echo_message "Begin copying live-build configuration..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/source_debian-live + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +# Remove old sources +if [ -d source/debian-live ] +then + rm -rf source/debian-live +fi + +# Copy system configuration +mkdir -p source/debian-live +cp -a config source/debian-live + +if Find_files auto/* +then + cp -a auto source/debian-live +fi + +# Creating stage file +Create_stagefile .build/source_debian-live diff --git a/scripts/build/source_hooks b/scripts/build/source_hooks new file mode 100755 index 000000000..3c22edfd1 --- /dev/null +++ b/scripts/build/source_hooks @@ -0,0 +1,78 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 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 source')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/source config/source +Set_defaults + +Echo_message "Begin executing hooks..." + +# Requiring stage file +Require_stagefile .build/config .build/bootstrap + +# Checking stage file +Check_stagefile .build/source_hooks + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +## Processing distribution hooks + +# Running hooks +for _HOOK in ${LB_BINARY_HOOKS} +do + for LOCATION in "${LIVE_BUILD}/hooks" /usr/share/live/build/hooks + do + for FILE in "${LOCATION}"/????-"${_HOOK}".source + do + if [ -e "${FILE}" ] + then + cd source + "${FILE}" || { Echo_error "${_HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + cd "${OLDPWD}" + fi + done + done +done + +## Processing local hooks + +if Find_files config/hooks/*.source +then + for HOOK in config/hooks/*.source + do + # Making hook executable + if [ ! -x "${HOOK}" ] + then + chmod +x "${HOOK}" + fi + + # Executing hook + ./"${HOOK}" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;} + done + + # Creating stage file + Create_stagefile .build/source_hooks +fi |