commit 0cd6ca8f4fae9e7dcdb1a96428cd2997a4969435
parent e153109808d54418af1fa47f2845c24f657e269f
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 31 Aug 2026 16:08:47 +0200
Improve the portability of checksum calculations
The -a option of cksum is not widely supported. Unfortunately, there is
no standard way to calculate an SHA512 checksum. This commit adds a
sha512.sh script that calculates it using the sha512sum, shasum, or
sha512 utility, depending on which one is available on the system.
Diffstat:
5 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/art/hooks/00-compute-digests.sh b/art/hooks/00-compute-digests.sh
@@ -32,7 +32,7 @@ file="$(basename "${i}")" # Rm the "./" prefix
if ! [ -f "${sign}" ]; then
>&2 printf 'Computing digest for %s\n' "${file}"
- cksum -a "${algo}" "${file}" > "${sign}"
+ sh ../../scripts/${algo}.sh "${file}" > "${sign}"
fi
# Write the generated files to standard output to inform the build
diff --git a/htrdr/hooks/00-compute-digests.sh b/htrdr/hooks/00-compute-digests.sh
@@ -32,7 +32,7 @@ find . -name "*Starter-Pack*.tar.gz" -o -name "*.nc.xz"\
if ! [ -f "${sign}" ]; then
>&2 printf 'Computing digest for %s\n' "${file}"
- cksum -a "${algo}" "${file}" > "${sign}"
+ sh ../../scripts/${algo}.sh "${file}" > "${sign}"
fi
# Write the generated files to standard output to inform the build
diff --git a/scripts/sha512.sh b/scripts/sha512.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+# Copyright (C) 2017-2026 |Méso|Star> (contact@meso-star.com)
+#
+# This file is part of Méso-Web.
+#
+# Méso-Web is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Méso-Web is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Méso-Web. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+if command -v sha512sum 1> /dev/null 2>&1; then
+ sha512sum "$@"
+elif command -v shasum 1> /dev/null 2>&1; then
+ shasum -a 512 "$@"
+elif command -v sha256 1> /dev/null 2>&1; then
+ sha512 "$@"
+else
+ >&2 printf 'No tool to compute SHA512 checksum\n'
+ exit 1
+fi
diff --git a/solstice/hooks/00-compute-digests.sh b/solstice/hooks/00-compute-digests.sh
@@ -35,7 +35,7 @@ find . \
if ! [ -f "${sign}" ]; then
>&2 printf 'Computing digest for %s\n' "${file}"
- cksum -a "${algo}" "${file}" > "${sign}"
+ sh ../../scripts/${algo}.sh "${file}" > "${sign}"
fi
# Write the generated files to standard output to inform the build
diff --git a/stardis/hooks/00-compute-digests.sh b/stardis/hooks/00-compute-digests.sh
@@ -32,7 +32,7 @@ find . -name "Stardis*.tar.gz" \
if ! [ -f "${sign}" ]; then
>&2 printf 'Computing digest for %s\n' "${file}"
- cksum -a "${algo}" "${file}" > "${sign}"
+ sh ../../scripts/${algo}.sh "${file}" > "${sign}"
fi
# Write the generated files to standard output to inform the build