mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #95341 from zshihang/hash
make download-or-bust compatible with both sha512/sha1
This commit is contained in:
commit
c5a3bf8b04
@ -126,9 +126,10 @@ function validate-hash {
|
|||||||
local -r file="$1"
|
local -r file="$1"
|
||||||
local -r expected="$2"
|
local -r expected="$2"
|
||||||
|
|
||||||
actual=$(sha512sum ${file} | awk '{ print $1 }') || true
|
actual_sha1=$(sha1sum "${file}" | awk '{ print $1 }') || true
|
||||||
if [[ "${actual}" != "${expected}" ]]; then
|
actual_sha512=$(sha512sum "${file}" | awk '{ print $1 }') || true
|
||||||
echo "== ${file} corrupted, sha512 ${actual} doesn't match expected ${expected} =="
|
if [[ "${actual_sha1}" != "${expected}" ]] && [[ "${actual_sha512}" != "${expected}" ]]; then
|
||||||
|
echo "== ${file} corrupted, sha1 ${actual_sha1}/sha512 ${actual_sha512} doesn't match expected ${expected} =="
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -146,7 +147,7 @@ function valid-storage-scope {
|
|||||||
|
|
||||||
# Retry a download until we get it. Takes a hash and a set of URLs.
|
# Retry a download until we get it. Takes a hash and a set of URLs.
|
||||||
#
|
#
|
||||||
# $1 is the sha512 of the URL. Can be "" if the sha512 is unknown.
|
# $1 is the sha512/sha1 hash of the URL. Can be "" if the sha512/sha1 hash is unknown.
|
||||||
# $2+ are the URLs to download.
|
# $2+ are the URLs to download.
|
||||||
function download-or-bust {
|
function download-or-bust {
|
||||||
local -r hash="$1"
|
local -r hash="$1"
|
||||||
@ -168,7 +169,7 @@ function download-or-bust {
|
|||||||
echo "== Hash validation of ${url} failed. Retrying. =="
|
echo "== Hash validation of ${url} failed. Retrying. =="
|
||||||
else
|
else
|
||||||
if [[ -n "${hash}" ]]; then
|
if [[ -n "${hash}" ]]; then
|
||||||
echo "== Downloaded ${url} (SHA512 = ${hash}) =="
|
echo "== Downloaded ${url} (HASH = ${hash}) =="
|
||||||
else
|
else
|
||||||
echo "== Downloaded ${url} =="
|
echo "== Downloaded ${url} =="
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user