[projects/cleanbuild] Add --exec option to enter container

glen glen at pld-linux.org
Tue Sep 28 17:27:23 CEST 2021


commit 0d37247d5bdf546fa81cebcbdf9dc7479cddd2d1
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Tue Sep 28 18:18:53 2021 +0300

    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
 }
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/cleanbuild.git/commitdiff/0d37247d5bdf546fa81cebcbdf9dc7479cddd2d1



More information about the pld-cvs-commit mailing list