| #!/bin/bash | |
| # | |
| # Copyright 2017 Bloomberg Finance LP | |
| # | |
| # This program is free software; you can redistribute it and/or | |
| # modify it under the terms of the GNU Lesser General Public | |
| # License as published by the Free Software Foundation; either | |
| # version 2 of the License, or (at your option) any later version. | |
| # | |
| # This library is distributed in the hope that it will be useful, | |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| # Lesser General Public License for more details. | |
| # | |
| # You should have received a copy of the GNU Lesser General Public | |
| # License along with this library. If not, see <http://www.gnu.org/licenses/>. | |
| # | |
| # Authors: | |
| # Charles Bailey <cbailey32@bloomberg.net> | |
| # Sam Thursfield <sam.thursfield@codethink.co.uk> | |
| # This is a helper script for using BuildStream via Docker. See | |
| # docs/source/install.rst for documentation. | |
| is_tty= | |
| if test -t 0 | |
| then | |
| is_tty=y | |
| fi | |
| while getopts tT arg | |
| do | |
| case $arg in | |
| T) | |
| is_tty= | |
| ;; | |
| t) | |
| is_tty=y | |
| ;; | |
| esac | |
| done | |
| test "$OPTIND" -gt 1 && | |
| shift $(( OPTIND - 1 )) | |
| create_volume_if_not_exists () { | |
| if ! docker volume inspect "$1" >/dev/null 2>&1 | |
| then | |
| docker volume create --name "$1" | |
| fi | |
| } | |
| for vol in buildstream-cache buildstream-config | |
| do | |
| create_volume_if_not_exists "$vol" | |
| 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 \ | |
| --cap-add SYS_CHROOT \ | |
| --cap-add NET_ADMIN \ | |
| --cap-add SETUID \ | |
| --cap-add SETGID \ | |
| --env PS1="$BST_HERE_PS1" \ | |
| --device /dev/fuse \ | |
| --security-opt seccomp=unconfined \ | |
| --volume buildstream-cache:/root/.cache/buildstream \ | |
| --volume buildstream-config:/root/.config \ | |
| --volume "$PWD":/src:Z \ | |
| --workdir /src \ | |
| buildstream/buildstream-fedora:latest \ | |
| $command |