fix(macos) Add support for gnu hash algo

This commit is contained in:
Alan Pope 2025-07-28 22:33:09 +01:00 committed by Liam
parent 58d7c41998
commit d912402e32
1 changed files with 14 additions and 0 deletions

View File

@ -5,6 +5,9 @@
# shellcheck disable=SC2317
export LC_ALL=C
# Detect host OS for checksum tool compatibility
HOST_OS=$(uname -s)
function cleanup() {
if [ -n "$(jobs -p)" ]; then
kill "$(jobs -p)" 2>/dev/null
@ -1192,6 +1195,17 @@ function check_hash() {
*) echo "WARNING! Can't guess hash algorithm, not checking ${iso} hash."
return;;
esac
# Use GNU coreutils on macOS/Darwin (prefixed with 'g')
if [ "${HOST_OS}" = "Darwin" ]; then
case ${hash_algo} in
md5sum) hash_algo=gmd5sum;;
sha1sum) hash_algo=gsha1sum;;
sha256sum) hash_algo=gsha256sum;;
sha512sum) hash_algo=gsha512sum;;
esac
fi
echo -n "Checking ${iso} with ${hash_algo}... "
if ! echo "${hash} ${iso}" | ${hash_algo} --check --status; then
echo "ERROR!"