[projects/cleanbuild] Add support to re-use container with --keep-container
glen
glen at pld-linux.org
Sun Aug 29 15:57:50 CEST 2021
commit 98e025574135e6eab94939c11c6842d38984bb3d
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Sun Aug 29 16:08:47 2021 +0300
Add support to re-use container with --keep-container
bin/cleanbuild-docker.sh | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/bin/cleanbuild-docker.sh b/bin/cleanbuild-docker.sh
index 8aa1482..f559e17 100755
--- a/bin/cleanbuild-docker.sh
+++ b/bin/cleanbuild-docker.sh
@@ -53,20 +53,32 @@ tmpfs() {
echo "--tmpfs $home/rpm/BUILD:rw,exec,nosuid,size=$TMPFS"
}
+have_container() {
+ local name="$1" id
+
+ id=$(docker ps -a -f "label=cleanbuild=$name" --format '{{.ID}}')
+
+ test -n "$id"
+}
+
create_container() {
- notice "Clean up old container: $name"
- docker kill $name >/dev/null 2>&1 || :
- docker rm $name >/dev/null 2>&1 || :
+ if ! $KEEP_CONTAINER; then
+ notice "Clean up old container: $name"
+ docker kill $name >/dev/null 2>&1 || :
+ docker rm $name >/dev/null 2>&1 || :
+ fi
install -d $topdir/logs
# start the container
- TMPFS_SIZE=$TMPFS \
- PACKAGE_NAME=$PACKAGE_NAME \
- docker-compose run --rm -d \
- --name=$name \
- --label=cleanbuild=$PACKAGE_NAME \
- cleanbuild
+ if ! have_container "$PACKAGE_NAME"; then
+ TMPFS_SIZE=$TMPFS \
+ PACKAGE_NAME=$PACKAGE_NAME \
+ docker-compose run --rm -d \
+ --name=$name \
+ --label=cleanbuild=$PACKAGE_NAME \
+ cleanbuild
+ fi
notice "Setup the homedir"
docker exec --user=root -w / $name usermod -d $home builder
@@ -89,6 +101,7 @@ package_prepare() {
fi
notice "Fetch package sources"
+ docker exec --user=root -w / $name setfacl -x u:builder /etc/resolv.conf
docker exec $name builder -g $PACKAGE_NAME
if ! $NETWORKING; then
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/cleanbuild.git/commitdiff/eb07c8d6582cadef8a50e97c53963501c981f4e9
More information about the pld-cvs-commit
mailing list