From c1c2040226202ef3a9092005e38ae79dce27a3ee Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Wed, 18 Oct 2017 11:59:39 +0100 Subject: contrib/bst-here: Change how invocation works If run with no arguments, `bst-here` now opens an interactive Bash shell. This has several advantages to running each `bst` command in a new container: * it's faster * bash completions will work * man pages could work (if the user runs `dnf install man`) If run with arguments, those are now assumed to be arguments for `bst` such that instead of running `bst-here bst build foo` you now just run `bst-here build foo`. --- contrib/bst-here | 8 +++++++- doc/source/docker.rst | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/contrib/bst-here b/contrib/bst-here index 595807df4..6b4e6b2f7 100755 --- a/contrib/bst-here +++ b/contrib/bst-here @@ -58,6 +58,12 @@ done BST_HERE_PS1="\[\033[01;34m\]\w\[\033[00m\]> " +if [ "$#" -eq 0 ]; then + command="/bin/bash -i" +else + command="/usr/bin/bst $@" +fi + exec docker run --rm -i${is_tty:+ -t} \ --cap-add SYS_ADMIN \ --env PS1="$BST_HERE_PS1" \ @@ -68,4 +74,4 @@ exec docker run --rm -i${is_tty:+ -t} \ --volume "$PWD":/src \ --workdir /src \ buildstream/buildstream-fedora:latest \ - "$@" + $command diff --git a/doc/source/docker.rst b/doc/source/docker.rst index 55e456d87..20dc6a9c1 100644 --- a/doc/source/docker.rst +++ b/doc/source/docker.rst @@ -21,18 +21,19 @@ Check if ``~/.local/bin`` appears in your PATH environment variable -- if it doesn't, you should `edit your ~/.profile so that it does `_. -Once ``bst-here`` is available in your PATH, you just prefix every BuildStream -command you need to run with ``bst-here`` so that it executes through the -wrapper. The latest version of the buildstream-fedora Docker image is -automatically pulled if needed. The contents of your working directory will be -made available at ``/src`` inside the container. +Once the script is available in your PATH, you can run ``bst-here`` to open a +shell session inside a new container based off the latest version of the +buildstream-fedora Docker image. The current working directory will be mounted +inside the container at ``/src``. -Two other volumes are set up by the ``bst-here`` script: +You can also run individual BuildStream commands as ``bst-here COMMAND``. For +example: ``bst-here show systems/my-system.bst``. Note that BuildStream won't +be able to integrate with Bash tab-completion if you invoke it in this way. + +Two Docker volumes are set up by the ``bst-here`` script: * buildstream-cache -- mounted at ``~/.cache/buildstream`` * buildstream-config -- mounted at ``~/.config/`` These are necessary so that your BuildStream cache and configuration files -persist between invocations of ``bst-here``. You can open a shell inside the -container by running ``bst-here -t /bin/bash``, which is useful if for example -you need to add something custom to ``~/.config/buildstream.conf``. +persist between invocations of ``bst-here``. -- cgit v1.2.1