Files
scylladb/tools/toolchain/dbuild
Avi Kivity 20b6d00e56 tools: toolchain: support dbuild from subdirectory or parent directory of scylla.git
When building something other than Scylla (like scylla-tools-java or scylla-jmx)
it is convenient to run it from some other directory. To do that, allow running
dbuild from any directory (so we locate tools/toolchain/image relative to the
dbuild script rather than use a fixed path) and mount the current directory
since it's likely the user will want to access files there.
Message-Id: <20190107165824.25164-1-avi@scylladb.com>
2019-01-07 18:35:51 +01:00

39 lines
789 B
Bash
Executable File

#!/bin/bash
here="$(realpath $(dirname "$0"))"
toplevel="$(realpath "$here/../..")"
group_args=()
docker_args=()
for gid in $(id -G); do
group_args+=(--group-add "$gid")
done
if [[ "$1" = -* ]]; then
while [[ "$1" != "--" && $# != 0 ]]; do
docker_args+=("$1")
shift
done
if [[ "$1" != "--" ]]; then
echo "Expected '--' to terminate docker flag list"
exit 1
fi
shift
fi
docker run \
--sig-proxy=true \
--rm \
-u "$(id -u):$(id -g)" \
"${group_args[@]}" \
--cap-add SYS_PTRACE \
-v "$PWD:$PWD" \
-v "$toplevel:$toplevel" \
-v /tmp:/tmp \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-w "$PWD" \
"${docker_args[@]}" \
"$(<"$here/image")" \
"$@"