diff --git a/scripts/build/chroot_hooks b/scripts/build/chroot_hooks index fbe3a9ca1..f5a2e4443 100755 --- a/scripts/build/chroot_hooks +++ b/scripts/build/chroot_hooks @@ -32,14 +32,9 @@ Check_stagefile # Acquire lock file Acquire_lockfile -# 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 +# Make build config available to chroot hooks. +mkdir -p chroot/live-build +cp --recursive --preserve=mode,timestamps --dereference config chroot/live-build/config ## Processing hooks if ls config/hooks/normal/*.chroot > /dev/null 2>&1 && ( @@ -92,10 +87,8 @@ then Save_package_cache chroot fi -# Remove bind mount of build config inside chroot. -umount chroot/live-build/config -rmdir chroot/live-build/config -rmdir chroot/live-build +# Remove build config inside chroot. +rm -rf chroot/live-build # Creating stage file Create_stagefile diff --git a/scripts/build/chroot_proc b/scripts/build/chroot_proc index fcc866932..d651dacf6 100755 --- a/scripts/build/chroot_proc +++ b/scripts/build/chroot_proc @@ -41,7 +41,10 @@ case "${_ACTION}" in mkdir -p chroot/proc # Mounting /proc - mount -t proc -o x-gvfs-hide proc-live chroot/proc + if ! mount -t proc -o x-gvfs-hide proc-live chroot/proc + then + Echo_warning "Cannot mount /proc (running in container?)" + fi # Creating stage file Create_stagefile diff --git a/scripts/build/chroot_sysfs b/scripts/build/chroot_sysfs index e4601abe1..d64003659 100755 --- a/scripts/build/chroot_sysfs +++ b/scripts/build/chroot_sysfs @@ -41,7 +41,10 @@ case "${_ACTION}" in mkdir -p chroot/sys # Mounting /sys - mount -t sysfs -o x-gvfs-hide sysfs-live chroot/sys + if ! mount -t sysfs -o x-gvfs-hide sysfs-live chroot/sys + then + Echo_warning "Cannot mount /sys (running in container?)" + fi # Creating stage file Create_stagefile