diff options
author | Thore Sommer <debian@thson.de> | 2020-10-27 15:07:11 +0000 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2020-10-27 15:07:11 +0000 |
commit | 7360d50fa6b7ef4809d28cf873ab7d29dc2a6f97 (patch) | |
tree | 609b88fd0c2840a14688a6bd18b185fd686a7781 /functions | |
parent | 7b19209aaeb14719d8029fa321aa39aef08b6e94 (diff) | |
download | vyos-live-build-7360d50fa6b7ef4809d28cf873ab7d29dc2a6f97.tar.gz vyos-live-build-7360d50fa6b7ef4809d28cf873ab7d29dc2a6f97.zip |
Added the option to include files before and after package installation
Moved includes.chroot to includes.chroot_after_packages and added
includes.chroot_before_packages. includes.chroot does still work as before.
We also now use rsync for copying files if it is installed.
This improves runtime and space consumption for large includes.
Gbp-Dch: Short
Closes: #927128
Diffstat (limited to 'functions')
-rwxr-xr-x | functions/chroot.sh | 20 | ||||
-rwxr-xr-x | functions/compatibility.sh | 30 |
2 files changed, 50 insertions, 0 deletions
diff --git a/functions/chroot.sh b/functions/chroot.sh index 76733e50e..d62a4fad0 100755 --- a/functions/chroot.sh +++ b/functions/chroot.sh @@ -56,3 +56,23 @@ Chroot_package_list() { dpkg-query --admindir=${CHROOT}/var/lib/dpkg -W -f'${Package}\n' } + +Chroot_copy_dir() { + local DIR="${1}" + local NAME="${2:-$(basename ${DIR})}" + + Check_installed host /usr/bin/rsync rsync + if [ "${INSTALL_STATUS}" -eq "0" ] + then + Echo_message "Copying ${NAME} into chroot using rsync..." + rsync -Klrv --chown=0:0 "${DIR}" chroot/ + else + cd "${DIR}" + Echo_message "Creating a tarball with files from ${NAME}..." + tar cf "${OLDPWD}"/chroot/"${NAME}".tar . + cd "${OLDPWD}" + Echo_message "Extracting the tarball in the chroot..." + Chroot chroot "tar -xvf ${NAME}.tar --no-same-owner --keep-directory-symlink --overwrite" + rm chroot/"${NAME}".tar + fi +} diff --git a/functions/compatibility.sh b/functions/compatibility.sh new file mode 100755 index 000000000..f0ae08346 --- /dev/null +++ b/functions/compatibility.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2016-2020 The Debian Live team +## 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. + +# We've added the option to also include files before packages renamed the old directory. +# This function auto detects which version should be used. +select_includes_chroot(){ + local OLD_DIR="includes.chroot" + local NEW_DIR="includes.chroot_after_packages" + + if Find_files "config/${NEW_DIR}/" && Find_files "config/${OLD_DIR}/" + then + Echo_error "You have files in ${OLD_DIR} and ${NEW_DIR}. Only one directory is allowed." + exit 1 + fi + + if Find_files "config/${NEW_DIR}/" + then + echo -n "${NEW_DIR}" + elif Find_files "config/${OLD_DIR}/" + then + echo -n "${OLD_DIR}" + fi +} |