aboutsummaryrefslogtreecommitdiff
path: root/cmd/build-env.sh
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2018-10-20 07:47:57 +0200
committerSlack Coder <slackcoder@server.ky>2018-10-20 07:47:57 +0200
commit4aff578ab86483ebf57f19a10b70c4eeb34af88e (patch)
treeeb84d012c2afdec065923fd5fb9d0490fc2e46c4 /cmd/build-env.sh
downloadmuslack64-current-4aff578ab86483ebf57f19a10b70c4eeb34af88e.tar.xz
initial commit
Diffstat (limited to 'cmd/build-env.sh')
-rwxr-xr-xcmd/build-env.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/cmd/build-env.sh b/cmd/build-env.sh
new file mode 100755
index 0000000..fb003e2
--- /dev/null
+++ b/cmd/build-env.sh
@@ -0,0 +1,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
+