Merge "Lock around extract-image downloads and extracts"
This commit is contained in:
commit
f4011996ee
1 changed files with 89 additions and 77 deletions
|
@ -14,11 +14,12 @@ CACHED_IMAGE=$4
|
|||
|
||||
CACHED_TAR=$DIB_IMAGE_CACHE/$BASE_IMAGE_TAR
|
||||
DIB_LOCAL_IMAGE=${DIB_LOCAL_IMAGE:-""}
|
||||
TAR_LOCK=$CACHED_TAR.lock
|
||||
|
||||
function extract_image() {
|
||||
if [ -n "$DIB_OFFLINE" -a -f "$CACHED_TAR" ] ; then
|
||||
echo "Not checking freshness of cached $CACHED_TAR."
|
||||
else
|
||||
|
||||
if [ -z "$DIB_LOCAL_IMAGE" ]; then
|
||||
echo "Fetching Base Image"
|
||||
|
||||
|
@ -89,9 +90,20 @@ else
|
|||
else
|
||||
echo "Using cached tar from $CACHED_TAR"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Extract the base image (use --numeric-owner to avoid UID/GID mismatch between
|
||||
# image tarball and host OS e.g. when building Fedora image on an openSUSE host)
|
||||
echo "Extracting base root image from $CACHED_TAR"
|
||||
sudo tar -C $TARGET_ROOT --numeric-owner -xzf $CACHED_TAR
|
||||
}
|
||||
|
||||
(
|
||||
echo "Getting $TAR_LOCK: $(date)"
|
||||
# Wait up to 20 minutes for another process to download
|
||||
if ! flock -w 1200 9 ; then
|
||||
echo "Did not get $TAR_LOCK: $(date)"
|
||||
exit 1
|
||||
fi
|
||||
extract_image
|
||||
) 9> $TAR_LOCK
|
||||
|
|
Loading…
Reference in a new issue