Skip to content

Commit c5a3bf8

Browse files
authored
Merge pull request kubernetes#95341 from zshihang/hash
make download-or-bust compatible with both sha512/sha1
2 parents 7a5b058 + e0dcfbf commit c5a3bf8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cluster/gce/gci/configure.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ function validate-hash {
126126
local -r file="$1"
127127
local -r expected="$2"
128128

129-
actual=$(sha512sum ${file} | awk '{ print $1 }') || true
130-
if [[ "${actual}" != "${expected}" ]]; then
131-
echo "== ${file} corrupted, sha512 ${actual} doesn't match expected ${expected} =="
129+
actual_sha1=$(sha1sum "${file}" | awk '{ print $1 }') || true
130+
actual_sha512=$(sha512sum "${file}" | awk '{ print $1 }') || true
131+
if [[ "${actual_sha1}" != "${expected}" ]] && [[ "${actual_sha512}" != "${expected}" ]]; then
132+
echo "== ${file} corrupted, sha1 ${actual_sha1}/sha512 ${actual_sha512} doesn't match expected ${expected} =="
132133
return 1
133134
fi
134135
}
@@ -146,7 +147,7 @@ function valid-storage-scope {
146147

147148
# Retry a download until we get it. Takes a hash and a set of URLs.
148149
#
149-
# $1 is the sha512 of the URL. Can be "" if the sha512 is unknown.
150+
# $1 is the sha512/sha1 hash of the URL. Can be "" if the sha512/sha1 hash is unknown.
150151
# $2+ are the URLs to download.
151152
function download-or-bust {
152153
local -r hash="$1"
@@ -168,7 +169,7 @@ function download-or-bust {
168169
echo "== Hash validation of ${url} failed. Retrying. =="
169170
else
170171
if [[ -n "${hash}" ]]; then
171-
echo "== Downloaded ${url} (SHA512 = ${hash}) =="
172+
echo "== Downloaded ${url} (HASH = ${hash}) =="
172173
else
173174
echo "== Downloaded ${url} =="
174175
fi

0 commit comments

Comments
 (0)