Skip to content

Commit 6465cb8

Browse files
committed
rustup: allow the use of either sha256sum or shasum to verify the download hash
1 parent 13aac00 commit 6465cb8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/etc/rustup.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,21 @@ create_tmp_dir() {
244244
probe_need CFG_CURL curl
245245
probe_need CFG_TAR tar
246246
probe_need CFG_FILE file
247-
probe_need CFG_SHASUM shasum
247+
248+
probe CFG_SHA256SUM sha256sum
249+
probe CFG_SHASUM shasum
250+
251+
if [ -z "$CFG_SHA256SUM" -a -z "$CFG_SHASUM" ]; then
252+
err "unable to find either sha256sum or shasum"
253+
fi
254+
255+
calculate_hash() {
256+
if [ -n "$CFG_SHA256SUM" ]; then
257+
${CFG_SHA256SUM} $@
258+
else
259+
${CFG_SHASUM} -a 256 $@
260+
fi
261+
}
248262

249263
CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
250264
CFG_SELF="$0"
@@ -474,7 +488,7 @@ verify_hash() {
474488
fi
475489

476490
msg "Verifying hash"
477-
local_sha256=`"${CFG_SHASUM}" -a 256 "${local_file}"`
491+
local_sha256=$(calculate_hash "${local_file}")
478492
if [ "$?" -ne 0 ]; then
479493
rm -Rf "${CFG_TMP_DIR}"
480494
err "Failed to compute hash for ${local_tarball}"

0 commit comments

Comments
 (0)