2015-04-09 18:57:41 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This chroot script uses proot (see http://proot.me)
|
|
|
|
#
|
|
|
|
readonly MASTERDIR="$1"
|
|
|
|
readonly DISTDIR="$2"
|
|
|
|
readonly HOSTDIR="$3"
|
|
|
|
readonly EXTRA_ARGS="$4"
|
2015-04-09 19:30:28 +02:00
|
|
|
shift 4
|
2015-04-09 18:57:41 +02:00
|
|
|
|
|
|
|
if ! command -v proot >/dev/null 2>&1; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-09 19:30:28 +02:00
|
|
|
if [ -z "$MASTERDIR" -o -z "$DISTDIR" ]; then
|
|
|
|
echo "$0 MASTERDIR/DISTDIR not set"
|
2015-04-09 18:57:41 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-11 11:04:39 +02:00
|
|
|
# proot does not properly return the resultcode. Workaround this
|
2019-06-17 17:38:07 +02:00
|
|
|
RESULT=$(mktemp) || exit 1
|
2015-04-11 11:04:39 +02:00
|
|
|
|
2016-11-17 09:45:21 +01:00
|
|
|
PROOT_NO_SECCOMP=1 proot -r $MASTERDIR -w / -b "$RESULT:/.result" -b $DISTDIR:/void-packages \
|
2015-04-09 18:57:41 +02:00
|
|
|
${HOSTDIR:+-b $HOSTDIR:/host} -b /proc:/proc -b /dev:/dev \
|
2015-04-11 11:04:39 +02:00
|
|
|
-b /sys:/sys $EXTRA_ARGS /bin/sh -c '$@; echo $? > /.result' $0 $@
|
|
|
|
|
|
|
|
rv=$(cat "$RESULT")
|
|
|
|
rm "$RESULT"
|
|
|
|
|
|
|
|
exit $rv
|