aboutsummaryrefslogtreecommitdiff
path: root/cmd/build-env.sh
blob: fb003e2e6c2ecfdbfa6b5ea029cc720ff898f8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

CMD_DIR="$(realpath $(dirname $0))"
PROJ_DIR="$(realpath $CMD_DIR/..)"

export CC="${CC:=musl-gcc --static}"
export ROOT="${ROOT:=/opt/muslack64-14.2}"
export TMP="${TMP:=/tmp/muslack}"
export USE_STATIC="${USE_STATIC:=true}"
export PKGTYPE="txz"

export PS1="[muslack-dev] $PS1"

TARGET="bash"
if [ $# -gt 0 ]; then
  TARGET=$@
fi

if [ ! -d "$ROOT" ]; then
  >&2 echo "This script expects $ROOT to exist.  Maybe you should create it?"
  exit 1
fi

bwrap \
  --unshare-all \
  --uid 0 \
  --gid 0 \
  --ro-bind / / \
  --bind /tmp /tmp \
  --bind "$PROJ_DIR" "$PROJ_DIR" \
  --ro-bind "$ROOT/usr/include" /usr/include/musl \
  --ro-bind "$ROOT/usr/lib64" /usr/lib64/musl \
  --bind "$ROOT" "$ROOT" \
  --dev-bind /dev /dev \
  $TARGET