summaryrefslogtreecommitdiff
path: root/docker-run.sh
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2019-03-22 10:13:14 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2019-03-22 20:55:01 +0000
commit2179403ebfa2990eeae4d1b15b3f6d542d3b5346 (patch)
tree9a491cf324eaf591172d2fd5b7823fbf8006171a /docker-run.sh
parentc98ba8dcfcce77d78cd68dedfa8c2bfd17ff01fc (diff)
docker-run.sh, tcwg-cleanup-stale-workspaces.sh: Use flock
In order to be able to remove old workspaces, this patch uses flock to make sure the renaming for $dir to $dir.bak does not happen while a build is in progress. To achieve that, both the renaming and the command executed by docker-run.sh use this exclusive lock. Unfortunately, this does not prevent race conditions with builds not relying on docker-run.sh, so such builds should either use flock or switch to using docker-run.sh. Change-Id: Ib8a7cbf33819d81f858c25f62a091b0b94c48d21
Diffstat (limited to 'docker-run.sh')
-rwxr-xr-xdocker-run.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/docker-run.sh b/docker-run.sh
index de7f340a..72cadaee 100755
--- a/docker-run.sh
+++ b/docker-run.sh
@@ -7,6 +7,7 @@ convert_args_to_variables "$@"
shift "$SHIFT_CONVERTED_ARGS"
qemu="${qemu-}"
+WORKSPACE="${WORKSPACE-}"
trap "container_cleanup" EXIT
@@ -16,4 +17,15 @@ case "$qemu" in
esac
. ./container.sh
-container_exec "$@"
+# We want to use flock only when WORKSPACE exists
+if [ "x$WORKSPACE" != "x" ]; then
+ if [ ! -d "$WORKSPACE" ]; then
+ echo "ERROR: WORKSPACE $WORKSPACE does not exist"
+ exit 1
+ fi
+ FLOCK="flock $WORKSPACE"
+else
+ FLOCK=""
+fi
+
+$FLOCK container_exec "$@"