Merge pull request #17425 from Homebrew/handle_broken_shasum

cmd/vendor-install: handle broken `shasum`.
This commit is contained in:
Mike McQuaid 2024-06-04 14:00:13 +01:00 committed by GitHub
commit 2051e053ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -186,10 +186,16 @@ EOS
if [[ -x "/usr/bin/shasum" ]] if [[ -x "/usr/bin/shasum" ]]
then then
sha="$(/usr/bin/shasum -a 256 "${CACHED_LOCATION}" | cut -d' ' -f1)" sha="$(/usr/bin/shasum -a 256 "${CACHED_LOCATION}" | cut -d' ' -f1)"
elif [[ -x "$(type -P sha256sum)" ]] fi
if [[ -z "${sha}" && -x "$(type -P sha256sum)" ]]
then then
sha="$(sha256sum "${CACHED_LOCATION}" | cut -d' ' -f1)" sha="$(sha256sum "${CACHED_LOCATION}" | cut -d' ' -f1)"
elif [[ -x "$(type -P ruby)" ]] fi
if [[ -z "${sha}" ]]
then
if [[ -x "$(type -P ruby)" ]]
then then
sha="$( sha="$(
ruby <<EOSCRIPT ruby <<EOSCRIPT
@ -200,7 +206,13 @@ puts digest.hexdigest
EOSCRIPT EOSCRIPT
)" )"
else else
odie "Cannot verify checksum ('shasum' or 'sha256sum' not found)!" odie "Cannot verify checksum ('shasum', 'sha256sum' and 'ruby' not found)!"
fi
fi
if [[ -z "${sha}" ]]
then
odie "Could not get checksum ('shasum', 'sha256sum' and 'ruby' produced no output)!"
fi fi
if [[ "${sha}" != "${VENDOR_SHA}" ]] if [[ "${sha}" != "${VENDOR_SHA}" ]]