From 0d37247d5bdf546fa81cebcbdf9dc7479cddd2d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Tue, 28 Sep 2021 18:18:53 +0300 Subject: [PATCH] Add --exec option to enter container --- bin/cleanbuild-docker.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/cleanbuild-docker.sh b/bin/cleanbuild-docker.sh index 30bba1e..5288f30 100755 --- a/bin/cleanbuild-docker.sh +++ b/bin/cleanbuild-docker.sh @@ -11,6 +11,7 @@ PROGRAM=${0##*/} : ${WITHOUT=} : ${KEEP_CONTAINER=true} : ${TMPFS="4G"} +: ${EXEC=false} dir=$(pwd) image=registry.gitlab.com/pld-linux/cleanbuild @@ -93,6 +94,11 @@ create_container() { fi } +enter_container() { + notice "Entering container for $PACKAGE_NAME" + docker exec --user=root -it $name bash +} + package_prepare() { notice "Fetch sources and install dependencies" if [ -d $topdir/packages/$PACKAGE_NAME ]; then @@ -169,7 +175,7 @@ package_build() { parse_options() { local t - t=$(getopt -o 'x' --long 'network,no-tmpfs,notmpfs,tmpfs:,keep-container:,with:,without:' -n "$PROGRAM" -- "$@") + t=$(getopt -o 'x' --long 'network,exec,no-tmpfs,notmpfs,tmpfs:,keep-container:,with:,without:' -n "$PROGRAM" -- "$@") [ $? != 0 ] && exit $? eval set -- "$t" @@ -181,6 +187,9 @@ parse_options() { --network) NETWORKING=true ;; + --exec) + EXEC=true + ;; --no-tmpfs|--notmpfs) TMPFS=false ;; @@ -222,6 +231,10 @@ main() { $TRACING && set -x local name="cleanbuild-$PACKAGE_NAME" create_container + if $EXEC; then + enter_container + return + fi package_prepare package_build } -- 2.44.0