summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThore Sommer <debian@thson.de>2020-10-12 18:26:16 +0000
committerLuca Boccassi <bluca@debian.org>2020-10-12 18:26:16 +0000
commit7b19209aaeb14719d8029fa321aa39aef08b6e94 (patch)
treeedd0de665156e7c2eb7d234ee1433e6c0e84212c /scripts
parent59380dddf0e0468b51f3587fcbafe8cdb72bd0c7 (diff)
downloadvyos-live-build-7b19209aaeb14719d8029fa321aa39aef08b6e94.tar.gz
vyos-live-build-7b19209aaeb14719d8029fa321aa39aef08b6e94.zip
Option for using systemd-nspawn instead of chroot for hooks.
Installation of flatpaks doesn't work with normal chroots. This patch enables support for using systemd-nspawn in hooks. Gbp-Dch: Short Closes: #965953
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build/chroot_hooks24
1 files changed, 21 insertions, 3 deletions
diff --git a/scripts/build/chroot_hooks b/scripts/build/chroot_hooks
index ff06eac3e..4e3702b14 100755
--- a/scripts/build/chroot_hooks
+++ b/scripts/build/chroot_hooks
@@ -72,12 +72,20 @@ rmdir chroot/root/lb_chroot_hooks
rmdir --ignore-fail-on-non-empty chroot/root
## Processing local hooks
-if ls config/hooks/normal/*.chroot config/hooks/live/*.chroot > /dev/null 2>&1
+if ls config/hooks/normal/*.chroot > /dev/null 2>&1 && (
+ ls config/hooks/live/*.chroot > /dev/null 2>&1 ||
+ ls config/hooks/live/*.container > /dev/null 2>&1 )
then
+ # If a systemd-nspawn hook exists check if package is installed
+ if ls config/hooks/live/*.container > /dev/null 2>&1
+ then
+ Check_package host /usr/bin/systemd-nspawn systemd-container
+ fi
+
# Restoring cache
Restore_package_cache chroot
- for HOOK in config/hooks/normal/*.chroot config/hooks/live/*.chroot
+ for HOOK in config/hooks/normal/*.chroot config/hooks/live/*.chroot config/hooks/live/*.container
do
if [ ! -e "${HOOK}" ]
then
@@ -94,7 +102,17 @@ then
fi
# Executing hook
- Chroot chroot "/root/$(basename ${HOOK})" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ Echo_message "Executing hook ${HOOK}..."
+ case "${HOOK}" in
+ *.container)
+ umount chroot/proc
+ systemd-nspawn --capability=all -D chroot "/root/$(basename ${HOOK})" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ mount proc-live -t proc chroot/proc
+ ;;
+ *)
+ Chroot chroot "/root/$(basename ${HOOK})" || { Echo_error "${HOOK} failed (exit non-zero). You should check for errors."; exit 1 ;}
+ ;;
+ esac
# Removing hook
rm -f chroot/root/"$(basename ${HOOK})"