github-cli: update to 2.62.0
[void-pkg.git] / common / chroot-style / uchroot.sh
blobe24ceac308be034f55a60ecb7a6b20bc35e1e2f8
1 #!/bin/sh
3 # This chroot script uses xbps-uchroot(1).
5 readonly MASTERDIR="$1"
6 readonly DISTDIR="$2"
7 readonly HOSTDIR="$3"
8 readonly EXTRA_ARGS="$4"
9 readonly CMD="$5"
10 shift 5
12 msg_red() {
13 # error messages in bold/red
14 [ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
15 printf "=> ERROR: %s\\n" "$@" >&2
16 [ -n "$NOCOLORS" ] || printf >&2 "\033[m"
19 readonly XBPS_UCHROOT_CMD="$(command -v xbps-uchroot 2>/dev/null)"
21 if [ -z "$XBPS_UCHROOT_CMD" ]; then
22 msg_red "could not find xbps-uchroot"
23 exit 1
26 if ! [ -x "$XBPS_UCHROOT_CMD" ]; then
27 msg_red "xbps-uchroot is not executable. Are you in the $(stat -c %G "$XBPS_UCHROOT_CMD") group?"
28 exit 1
31 if [ -z "$MASTERDIR" ] || [ -z "$DISTDIR" ]; then
32 msg_red "$0: MASTERDIR/DISTDIR not set"
33 exit 1
36 exec xbps-uchroot $EXTRA_ARGS -b $DISTDIR:/void-packages ${HOSTDIR:+-b $HOSTDIR:/host} -- $MASTERDIR $CMD $@