From 6465cb85a73fc1f0465d56867d6c3cee71d44b67 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 29 Dec 2014 11:33:57 -0500 Subject: [PATCH] rustup: allow the use of either sha256sum or shasum to verify the download hash --- src/etc/rustup.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/etc/rustup.sh b/src/etc/rustup.sh index 653eb96fa20..b41d3db22e4 100755 --- a/src/etc/rustup.sh +++ b/src/etc/rustup.sh @@ -244,7 +244,21 @@ create_tmp_dir() { probe_need CFG_CURL curl probe_need CFG_TAR tar probe_need CFG_FILE file -probe_need CFG_SHASUM shasum + +probe CFG_SHA256SUM sha256sum +probe CFG_SHASUM shasum + +if [ -z "$CFG_SHA256SUM" -a -z "$CFG_SHASUM" ]; then + err "unable to find either sha256sum or shasum" +fi + +calculate_hash() { + if [ -n "$CFG_SHA256SUM" ]; then + ${CFG_SHA256SUM} $@ + else + ${CFG_SHASUM} -a 256 $@ + fi +} CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" CFG_SELF="$0" @@ -474,7 +488,7 @@ verify_hash() { fi msg "Verifying hash" - local_sha256=`"${CFG_SHASUM}" -a 256 "${local_file}"` + local_sha256=$(calculate_hash "${local_file}") if [ "$?" -ne 0 ]; then rm -Rf "${CFG_TMP_DIR}" err "Failed to compute hash for ${local_tarball}"