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
|
2015-04-12 03:13:30 +02:00
|
|
|
RESULT=$(mktemp /tmp/proot_result.XXXXXXXXXX)
|
2015-04-11 11:04:39 +02:00
|
|
|
|
|
|
|
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
|