diff options
author | Chandan Singh <csingh43@bloomberg.net> | 2018-04-27 00:00:55 +0100 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2018-05-07 11:21:32 +0000 |
commit | 6ffca067b22c625bb2a25cf0494b7ec022b2fa99 (patch) | |
tree | 04d335525dd0eb4beb8d63e9f583f6be799aec94 /contrib | |
parent | 2e252e9d687a9590fec913efa9b2993980b59339 (diff) | |
download | buildstream-6ffca067b22c625bb2a25cf0494b7ec022b2fa99.tar.gz |
bst-here: Allow users to specify Docker image
Currently, the name of the Docker image is hardcoded in bst-here script.
This makes it harder for users to override it, which may be needed for
various reasons (custom plugins, private Docker registries etc.)
Add `-i` option to allow users to specify the base image. When `-i` is
not provided, default to `BST_HERE_IMAGE` environment variable if it's
set and otherwise to the current image -
`buildstream/buildstream-fedora`.
Also, re-order the command-line options in help text and source code in
alphabetical order to maintain sanity as the number of options is slowly
growing.
Part of #378.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/bst-here | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/contrib/bst-here b/contrib/bst-here index 26ee8170f..c451beeb3 100755 --- a/contrib/bst-here +++ b/contrib/bst-here @@ -25,7 +25,7 @@ usage() { cat <<EOF -USAGE: $(basename "$0") [-t] [-T] [-p] [-h] [COMMAND] [ARG..] +USAGE: $(basename "$0") [-i BST_HERE_IMAGE] [-p] [-t] [-T] [-h] [COMMAND] [ARG..] Run a bst command in a new BuildStream container. @@ -33,16 +33,18 @@ If no command is specified, an interactive shell is launched using "/bin/bash -i". OPTIONS: - -t Force pseudo-terminal allocation. - -T Disable pseudo-terminal allocation. - -p Pull the latest buildstream image before running. - -h Print this help text and exit. + -i IMAGE Specify Docker image to use; can also be specified by setting + BST_HERE_IMAGE environment variable. + -p Pull the latest buildstream image before running. + -t Force pseudo-terminal allocation. + -T Disable pseudo-terminal allocation. + -h Print this help text and exit. EOF exit "$1" } -BST_IMAGE='buildstream/buildstream-fedora:latest' +bst_here_image="${BST_HERE_IMAGE:-buildstream/buildstream-fedora:latest}" is_tty= update=false @@ -52,18 +54,21 @@ then is_tty=y fi -while getopts tTph arg +while getopts i:ptTh arg do case $arg in + i) + bst_here_image="$OPTARG" + ;; + p) + update=true + ;; T) is_tty= ;; t) is_tty=y ;; - p) - update=true - ;; h) usage 0 ;; @@ -97,7 +102,7 @@ fi if "$update" == true then - docker pull "$BST_IMAGE" + docker pull "$bst_here_image" fi # FIXME: We run with --privileged to allow bwrap to mount system @@ -117,5 +122,5 @@ exec docker run --rm -i${is_tty:+ -t} \ --volume buildstream-config:/root/.config \ --volume "$PWD":/src \ --workdir /src \ - "$BST_IMAGE" \ + "$bst_here_image" \ $command |