From f856083875faedee07e2f81c0cf3f29bd4fb29d0 Mon Sep 17 00:00:00 2001 From: Hsiaoyi Tsai Date: Fri, 20 Sep 2024 11:33:31 +0800 Subject: [PATCH] Update tool_kit.sh Avoid using sha256sum in Darwin --- tools/toolchain/scripts/tool_kit.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/toolchain/scripts/tool_kit.sh b/tools/toolchain/scripts/tool_kit.sh index a5088b0ee3..f5cfe21517 100644 --- a/tools/toolchain/scripts/tool_kit.sh +++ b/tools/toolchain/scripts/tool_kit.sh @@ -609,8 +609,11 @@ checksum() { local __shasum_command='sha256sum' # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" > /dev/null 2>&1 || + if command -v "$__shasum_command" > /dev/null 2>&1 && ! ${__shasum_command} --version 2>&1 | grep -q 'Darwin'; then + __shasum_command='sha256sum' + else __shasum_command="shasum -a 256" + fi if echo "$__sha256 $__filename" | ${__shasum_command} --check; then echo "Checksum of $__filename Ok" else @@ -651,8 +654,11 @@ verify_checksums() { # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" > /dev/null 2>&1 || + if command -v "$__shasum_command" > /dev/null 2>&1 && ! ${__shasum_command} --version 2>&1 | grep -q 'Darwin'; then + __shasum_command='sha256sum' + else __shasum_command="shasum -a 256" + fi ${__shasum_command} --check "${__checksum_file}" > /dev/null 2>&1 } @@ -665,8 +671,11 @@ write_checksums() { # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 - command -v "$__shasum_command" > /dev/null 2>&1 || + if command -v "$__shasum_command" > /dev/null 2>&1 && ! ${__shasum_command} --version 2>&1 | grep -q 'Darwin'; then + __shasum_command='sha256sum' + else __shasum_command="shasum -a 256" + fi ${__shasum_command} "${VERSION_FILE}" "$@" > "${__checksum_file}" }