Really handle Ubuntu mirror cache skew,

The last patch to do this only handled the case of SHA256SUM being
stale, but the image is more likely to be stale in the default
configuration as the hash file is downloaded over HTTPS.

Change-Id: I6531fa684e560cad48c3696394d48a600680c875
Closes-Bug: #1336067
This commit is contained in:
Robert Collins 2014-07-09 08:07:58 +12:00
parent 3cdfd9565e
commit eca284cab7

View File

@ -24,11 +24,18 @@ else
$TMP_HOOKS_PATH/bin/cache-url $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $CACHED_FILE
pushd $DIB_IMAGE_CACHE
if ! grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check - ; then
# It is likely that an upstream http(s) proxy has given us a new image, but stale sha256sums
# Try again. Harder.
# It is likely that an upstream http(s) proxy has given us a skewed
# result - either a cached SHA file or a cached image. Use cache-busting
# to get (as long as caches are compliant...) fresh files.
# Try the sha256sum first, just in case that is the stale one (avoiding
# downloading the larger image), and then if the sums still fail retry
# the image.
$TMP_HOOKS_PATH/bin/cache-url -f $SHA256SUMS $CACHED_SUMS
if ! grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check - ; then
$TMP_HOOKS_PATH/bin/cache-url -f $DIB_CLOUD_IMAGES/$DIB_RELEASE/current/$BASE_IMAGE_FILE $CACHED_FILE
grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check -
fi
fi
popd
fi
# Extract the base image (use --numeric-owner to avoid UID/GID mismatch between