vendor-install: use Ruby as a sha256 fallback

But still prefer shasum/sha256sum where present.
This commit is contained in:
Misty De Meo 2017-05-29 21:48:12 -07:00
parent a40291ee4a
commit 587f338daa
No known key found for this signature in database
GPG Key ID: 76CF846A2F674B2C

View File

@ -82,6 +82,15 @@ fetch() {
elif [[ -x "$(which sha256sum)" ]]
then
sha="$(sha256sum "$CACHED_LOCATION" | cut -d' ' -f1)"
elif [[ -x "$(which ruby)" ]]
then
sha="$(ruby <<EOSCRIPT
require 'digest/sha2'
digest = Digest::SHA256.new
File.open('$CACHED_LOCATION', 'rb') { |f| digest.update(f.read) }
puts digest.hexdigest
EOSCRIPT
)"
else
odie "Cannot verify the checksum ('shasum' or 'sha256sum' not found)!"
fi