You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2020/07/29 13:22:35 UTC

[incubator-nuttx-apps] 04/05: tools/check-hash.sh: Add shasum to use checking hash

This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 381b83ea90db49a4bd03c9dc45aedbb876f32242
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Jul 28 11:57:30 2020 +0900

    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 a61cf5c..7163fbb 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?