summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2018-05-21 19:59:39 +0000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-05-23 11:11:39 +1000
commite6195a08effd935ff9f05ec20bf82ae153b929d0 (patch)
treedeb3aadc937229c66b4344a4b9ae62f748ef1391
parent1c45cf6e9393e8c27acfa7c86ea305bcc26ff258 (diff)
downloadtalos-petitboot-e6195a08effd935ff9f05ec20bf82ae153b929d0.zip
talos-petitboot-e6195a08effd935ff9f05ec20bf82ae153b929d0.tar.gz
docker/build-pb: Add --interactive flag
Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
-rw-r--r--docker/README.md9
-rwxr-xr-xdocker/build-pb37
2 files changed, 31 insertions, 15 deletions
diff --git a/docker/README.md b/docker/README.md
index 7e3966d..d806ba1 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -20,10 +20,11 @@
### Run an interactive pb-builder container
-As current user:
+As root:
- docker run --rm -it --user $(id -u):$(id -g) -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v $(pwd):/opt/pb -w /opt/pb $(./docker/build-pb -t) bash
+ ./build-pb --interactive
-As root:
- docker run --rm -it -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v $(pwd):/opt/pb -w /opt/pb $(./docker/build-pb -t) bash
+As current user:
+
+ docker run --rm -it --user $(id -u):$(id -g) -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v $(pwd):/opt/pb -w /opt/pb $(./docker/build-pb -t) bash
diff --git a/docker/build-pb b/docker/build-pb
index ce6c41f..ad08ef9 100755
--- a/docker/build-pb
+++ b/docker/build-pb
@@ -12,20 +12,21 @@ usage () {
echo "${name} - Builds the petitboot programs using a pb-builder container." >&2
echo "Usage: ${name} [flags]" >&2
echo "Option flags:" >&2
- echo " -c --check - Run 'make check'." >&2
- echo " -d --dry-run - Do not run docker commands." >&2
- echo " -h --help - Show this help and exit." >&2
- echo " -t --tag - Print Docker tag to stdout and exit." >&2
- echo " -v --verbose - Verbose execution." >&2
+ echo " -c --check - Run 'make check'." >&2
+ echo " -d --dry-run - Do not run docker commands." >&2
+ echo " -h --help - Show this help and exit." >&2
+ echo " -i --interactive - Run an interactive pb-builder container." >&2
+ echo " -t --tag - Print Docker tag to stdout and exit." >&2
+ echo " -v --verbose - Verbose execution." >&2
echo "Environment:" >&2
- echo " DOCKER_TAG - Default: '${DOCKER_TAG}'" >&2
+ echo " DOCKER_TAG - Default: '${DOCKER_TAG}'" >&2
echo "Examples:" >&2
echo " ${name} -vc"
echo " ${name} -v"
}
-short_opts="cdhtv"
-long_opts="check,dry-run,help,tag,verbose"
+short_opts="cdhitv"
+long_opts="check,dry-run,help,interactive,tag,verbose"
opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${name}" -- "$@")
@@ -50,6 +51,10 @@ while true ; do
usage=1
shift
;;
+ -i | --interactive)
+ interactive=1
+ shift
+ ;;
-t | --tag)
tag=1
shift
@@ -80,15 +85,24 @@ if [[ -n "${tag}" ]]; then
exit 0
fi
-docker_args="--rm \
- -u $(id -u):$(id -g) \
+docker_base_args="\
+ --rm \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v ${TOP_DIR}:/opt/pb \
-w /opt/pb \
"
-if [[ -n "$verbose}" ]]; then
+docker_user_args="-u $(id -u):$(id -g)"
+
+if [[ -n "${interactive}" ]]; then
+ cd "${TOP_DIR}"
+ docker_args="${docker_base_args}"
+ run_cmd "docker run -it ${docker_args} ${DOCKER_TAG} /bin/bash"
+ exit
+fi
+
+if [[ -n "${verbose}" ]]; then
bash_debug="-x"
fi
@@ -99,6 +113,7 @@ else
fi
cd "${TOP_DIR}"
+docker_args="${docker_base_args} ${docker_user_args}"
run_cmd "docker run ${docker_args} ${DOCKER_TAG} /bin/bash \
-e ${bash_debug} \
-c './bootstrap && ./configure --with-ncurses && make && ${docker_extra}'"
OpenPOWER on IntegriCloud