summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2018-04-27 00:34:05 +0100
committerChandan Singh <csingh43@bloomberg.net>2018-04-27 12:35:31 +0100
commit25719d55a94f27981ea060c73d7aa8313a54329c (patch)
tree4b95f3f4002594aa776404e7a23e446b4caecc66
parentb5d2086eb05e0605fc6a93b658db5940fe1407aa (diff)
downloadbuildstream-378-make-bst-here-more-flexible.tar.gz
bst-here: Allow users to specify additional volumes to mount378-make-bst-here-more-flexible
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.
-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