Skip to content

Commit

Permalink
Use shasum --check on macOS
Browse files Browse the repository at this point in the history
It expects exactly two spaces separating digests from filenames. Nudge it towards succeess by making it so.
  • Loading branch information
nil4 committed Nov 8, 2024
1 parent 296570b commit f570a95
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ 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"
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"

# `shasum --check` expects exactly two spaces separating digest and filename on macOS -- help it succeed
pushd "${BUILD_ROOT_DIR}"
sed -e 's/ / /g' "openssl-${OPENSSL_VERSION}.tar.gz.sha256" > "openssl-${OPENSSL_VERSION}.tar.gz.sha256-macOS"
shasum -a 256 --strict --check "openssl-${OPENSSL_VERSION}.tar.gz.sha256-macOS"
popd
fi

BUILD_DIR="${BUILD_ROOT_DIR}/openssl-${OPENSSL_VERSION}"
Expand Down

0 comments on commit f570a95

Please sign in to comment.