Call shell by absolute path in chroot

When using the --script-chroot option, chroot is called with just sh
(relative path), relying on the host environment's $PATH to find the
executable. At least on Arch Linux, this does not work, as Arch Linux
by default does not have /bin in the PATH (/bin is just a symlink to
/usr/bin).

Since the chroot system was just built and it is know to contain
/bin/sh, I think it makes sense to just call it explicitly here.

Related to https://github.com/alpinelinux/alpine-make-rootfs/issues/10

Co-Authored-By: Conrad Hoffmann <ch@bitfehler.net>
This commit is contained in:
Jakub Jirutka 2020-01-28 16:53:04 +01:00
parent 4f8d71c4f4
commit d5b96dcaab

View file

@ -498,7 +498,7 @@ if [ "$SCRIPT" ]; then
else else
einfo "Executing script in chroot: $script_name $*" einfo "Executing script in chroot: $script_name $*"
mount_bind "${SCRIPT%/*}" mnt/ mount_bind "${SCRIPT%/*}" mnt/
chroot . sh -c "cd /mnt && ./$script_name \"\$@\"" -- "$@" \ chroot . /bin/sh -c "cd /mnt && ./$script_name \"\$@\"" -- "$@" \
|| die 'Script failed' || die 'Script failed'
fi fi
fi fi