summaryrefslogtreecommitdiff
path: root/contrib/bst-here
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2018-04-27 00:34:05 +0100
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-05-07 11:21:32 +0000
commit491760395eb9cb1e27fbe62ec49d98af7cca0d61 (patch)
treeef83a1202a1dc75b17333da244dd4ff131ba1d8b /contrib/bst-here
parent6ffca067b22c625bb2a25cf0494b7ec022b2fa99 (diff)
downloadbuildstream-491760395eb9cb1e27fbe62ec49d98af7cca0d61.tar.gz
bst-here: Allow users to specify additional volumes to mount
One may want to mount additional volumes to preserve certain directories or to share some data between the host and the container. Allow users to do so by providing a `-v` option that passes its arguments to corresponding `-v`/`--volume` option for `docker run` command. Part of #378.
Diffstat (limited to 'contrib/bst-here')
-rwxr-xr-xcontrib/bst-here11
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/bst-here b/contrib/bst-here
index c451beeb3..8816147bd 100755
--- a/contrib/bst-here
+++ b/contrib/bst-here
@@ -25,7 +25,7 @@
usage() {
cat <<EOF
-USAGE: $(basename "$0") [-i BST_HERE_IMAGE] [-p] [-t] [-T] [-h] [COMMAND] [ARG..]
+USAGE: $(basename "$0") [-i BST_HERE_IMAGE] [-p] [-t] [-T] [-v VOLUME ...] [-h] [COMMAND] [ARG..]
Run a bst command in a new BuildStream container.
@@ -38,6 +38,8 @@ OPTIONS:
-p Pull the latest buildstream image before running.
-t Force pseudo-terminal allocation.
-T Disable pseudo-terminal allocation.
+ -v VOLUME Specify additional volumes to mount; should be in format
+ 'host-src:container-dest' same as 'docker run -v'.
-h Print this help text and exit.
EOF
@@ -48,13 +50,14 @@ bst_here_image="${BST_HERE_IMAGE:-buildstream/buildstream-fedora:latest}"
is_tty=
update=false
+extra_volumes_opt=
if test -t 0
then
is_tty=y
fi
-while getopts i:ptTh arg
+while getopts i:ptTv:h arg
do
case $arg in
i)
@@ -69,6 +72,9 @@ do
t)
is_tty=y
;;
+ v)
+ extra_volumes_opt="$extra_volumes_opt --volume $OPTARG"
+ ;;
h)
usage 0
;;
@@ -121,6 +127,7 @@ exec docker run --rm -i${is_tty:+ -t} \
--volume buildstream-cache:/root/.cache/buildstream \
--volume buildstream-config:/root/.config \
--volume "$PWD":/src \
+ $extra_volumes_opt \
--workdir /src \
"$bst_here_image" \
$command