From 296570b5d909c6d142ba755fec37e51e5a140878 Mon Sep 17 00:00:00 2001 From: nil4 Date: Fri, 8 Nov 2024 10:34:56 +0100 Subject: [PATCH] Update checksum verification `sha256sum` is not available in GH CI, and `shasum` on macOS expects a different format for `--check` (two spaces between the digest and the filename.) Fall back to verify only the digest manually, and print out the mismatch if any. --- scripts/build.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 1ea8dc3..e6f5749 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -23,8 +23,15 @@ if [[ ! -f "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz" ]]; then echo "Downloading openssl-${OPENSSL_VERSION}.tar.gz" curl -fL "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz" -o "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz" curl -fL "https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz.sha256" -o "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz.sha256" - - sha256sum --strict --check "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz.sha256" + DIGEST_EXPECTED=$( cat "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz.sha256" | awk '{ print " "$1}' ) + DIGEST_ACTUAL=$( shasum -a 256 "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz" | awk '{ print " "$1}' ) + + if [[ "${DIGEST_EXPECTED}" != "${DIGEST_ACTUAL}" ]]; then + echo "openssl-${OPENSSL_VERSION}.tar.gz: checksum mismatch" + echo "expected: ${DIGEST_EXPECTED}" + echo "found: ${DIGEST_ACTUAL}" + exit 1 + fi rm -f "${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}.tar.gz.sha256" fi