From fbb797ea42cc10a647d0861b4d9fb439d8f0e482 Mon Sep 17 00:00:00 2001 From: Jon-Paul Sullivan Date: Mon, 30 Jun 2014 18:34:41 +0100 Subject: [PATCH] Lock around source repositories setup Problems were seen when building images in parallel with git clones and fetches interfering with each other. Stop it. Co-Authored-By: Michael Kerrin Change-Id: Iaa48f259755d8b22327459a5c6d224a342909aee --- .../extra-data.d/98-source-repositories | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index ab5684d91..4f84d2b58 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -188,7 +188,15 @@ rm -f $GIT_MANIFEST # Get source repositories for the target for _SOURCEREPO in $(find $TMP_HOOKS_PATH -maxdepth 1 -name "source-repository-*" -not -name '*~'); do - get_repos_for_element $_SOURCEREPO + repo_flock=$CACHE_BASE/repositories_flock + ( + echo "Getting $repo_flock: $(date)" + if ! flock -w 600 9 ; then + echo "Did not get $repo_flock: $(date)" + exit 1 + fi + get_repos_for_element $_SOURCEREPO + ) 9> $repo_flock done # Copy the manifest into the image if it exists (there may be no git repositories used)