From 381b83ea90db49a4bd03c9dc45aedbb876f32242 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 28 Jul 2020 11:57:30 +0900 Subject: [PATCH] tools/check-hash.sh: Add shasum to use checking hash In macOS, sha*sum tools not found, but shasum can be use instead of them. --- tools/check-hash.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/check-hash.sh b/tools/check-hash.sh index a61cf5c9f..7163fbb5e 100755 --- a/tools/check-hash.sh +++ b/tools/check-hash.sh @@ -71,7 +71,14 @@ esac # Calculate hash value of passed file -calc_hash=$( ${hash_algo}sum "${file_to_check}" | cut -d' ' -f1 ) +if [ `which ${hash_algo}sum 2> /dev/null` ]; then + hash_algo_cmd="${hash_algo}sum" +elif [ `which shasum 2> /dev/null` ]; then + hash_algo_len=$( echo ${hash_algo} | cut -c 4- ) + hash_algo_cmd="shasum -a ${hash_algo_len}" +fi + +calc_hash=$( ${hash_algo_cmd} "${file_to_check}" | cut -d' ' -f1 ) # Does it match expected hash?