2015-04-09 16:57:41 +00: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 17:30:28 +00:00
|
|
|
shift 4
|
2015-04-09 16:57:41 +00:00
|
|
|
|
|
|
|
if ! command -v proot >/dev/null 2>&1; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-09 17:30:28 +00:00
|
|
|
if [ -z "$MASTERDIR" -o -z "$DISTDIR" ]; then
|
|
|
|
echo "$0 MASTERDIR/DISTDIR not set"
|
2015-04-09 16:57:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-11 09:04:39 +00:00
|
|
|
# proot does not properly return the resultcode. Workaround this
|
2015-04-12 01:13:30 +00:00
|
|
|
RESULT=$(mktemp /tmp/proot_result.XXXXXXXXXX)
|
2015-04-11 09:04:39 +00:00
|
|
|
|
2016-11-17 08:45:21 +00:00
|
|
|
PROOT_NO_SECCOMP=1 proot -r $MASTERDIR -w / -b "$RESULT:/.result" -b $DISTDIR:/void-packages \
|
2015-04-09 16:57:41 +00:00
|
|
|
${HOSTDIR:+-b $HOSTDIR:/host} -b /proc:/proc -b /dev:/dev \
|
2015-04-11 09:04:39 +00:00
|
|
|
-b /sys:/sys $EXTRA_ARGS /bin/sh -c '$@; echo $? > /.result' $0 $@
|
|
|
|
|
|
|
|
rv=$(cat "$RESULT")
|
|
|
|
rm "$RESULT"
|
|
|
|
|
|
|
|
exit $rv
|