From eca284cab782a9fff14b4ecd598cb7e14f2f7a47 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Wed, 9 Jul 2014 08:07:58 +1200 Subject: [PATCH] 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 --- elements/ubuntu/root.d/10-cache-ubuntu-tarball | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/elements/ubuntu/root.d/10-cache-ubuntu-tarball b/elements/ubuntu/root.d/10-cache-ubuntu-tarball index 96667fce..1bd38106 100755 --- a/elements/ubuntu/root.d/10-cache-ubuntu-tarball +++ b/elements/ubuntu/root.d/10-cache-ubuntu-tarball @@ -24,10 +24,17 @@ 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 - grep "$BASE_IMAGE_FILE" $CACHED_SUMS | sha256sum --check - + 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