From: Fabian Castelli <50630942+gfcas@users.noreply.github.com> Date: Thu, 17 Jun 2021 21:06:03 +0000 (+0200) Subject: Update checksum verification (#187) X-Git-Tag: v9.3.0-r3~13 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9becec58c14693b609d1d3d7b51df13351cb9e15;p=candi.git Update checksum verification (#187) * Update checksum verification * Minor corrections --- diff --git a/candi.sh b/candi.sh index fb26899..b161021 100755 --- a/candi.sh +++ b/candi.sh @@ -202,7 +202,12 @@ quit_if_fail() { # return 1: No checksum provided (archive found, but unable to verify) # return 2: ARCHIVE_FILE not found (archive NOT found) # return 3: CHECKSUM mismatch (archive file corrupted) -# return 4: Neither md5 nor md5sum found (archive found, but unable to verify) +# return 4: Not able to compute checksum (archive found, but unable to verify) +# return 5: Checksum algorithm not found (archive found, but unable to verify) +# This function tries to verify the downloaded archive by determing and +# comparing checksums. For a specific package several checksums might be +# defined. Based on the length of the given checksum the underlying algorithm +# is determined. The first matching checksum verifies the archive. verify_archive() { ARCHIVE_FILE=$1 @@ -222,34 +227,64 @@ verify_archive() { return 1 fi - # Skip verifying archive, if CHECKSUM=ignore - if [ "${CHECKSUM}" = "ignore" ]; then + # Skip verifying archive, if CHECKSUM=skip + if [ "${CHECKSUM}" = "skip" ]; then cecho ${WARN} "Skipped checksum check for ${ARCHIVE_FILE}" return 1 fi cecho ${INFO} "Verifying ${ARCHIVE_FILE}" - # Verify CHECKSUM using md5/md5sum - if builtin command -v md5 > /dev/null; then - CURRENT="$(md5 -q ${ARCHIVE_FILE})" - elif builtin command -v md5sum > /dev/null; then - CURRENT=$(md5sum ${ARCHIVE_FILE} | awk '{print $1}') - else - cecho ${BAD} "Neither md5 nor md5sum were found in the PATH" - return 4 - fi - for CHECK in ${CHECKSUM}; do + # Verify CHECKSUM using md5/sha1/sha256 + if [ ${#CHECK} = 32 ]; then + ALGORITHM="md5" + if builtin command -v md5sum > /dev/null; then + CURRENT=$(md5sum ${ARCHIVE_FILE} | awk '{print $1}') + elif builtin command -v md5 > /dev/null; then + CURRENT="$(md5 -q ${ARCHIVE_FILE})" + else + cecho ${BAD} "Neither md5sum nor md5 were found in the PATH" + return 4 + fi + elif [ ${#CHECK} = 40 ]; then + ALGORITHM="sha1" + if builtin command -v sha1sum > /dev/null; then + CURRENT=$(sha1sum ${ARCHIVE_FILE} | awk '{print $1}') + elif builtin command -v shasum > /dev/null; then + CURRENT=$(shasum -a 1 ${ARCHIVE_FILE} | awk '{print $1}') + else + cecho ${BAD} "Neither sha1sum nor shasum were found in the PATH" + return 4 + fi + elif [ ${#CHECK} = 64 ]; then + ALGORITHM="sha256" + if builtin command -v sha256sum > /dev/null; then + CURRENT=$(sha256sum ${ARCHIVE_FILE} | awk '{print $1}') + elif builtin command -v shasum > /dev/null; then + CURRENT=$(shasum -a 256 ${ARCHIVE_FILE} | awk '{print $1}') + else + cecho ${BAD} "Neither sha256sum nor shasum were found in the PATH" + return 4 + fi + else + cecho ${BAD} "Checksum algorithm could not be determined" + exit 5 + fi + test "${CHECK}" = "${CURRENT}" if [ $? = 0 ]; then - echo "${ARCHIVE_FILE}: OK" + cecho ${GOOD} "${ARCHIVE_FILE}: OK(${ALGORITHM})" return 0 - fi + else + cecho ${BAD} "${ARCHIVE_FILE}: FAILED(${ALGORITHM})" + cecho ${BAD} "${CURRENT} does not match given checksum ${CHECK}" + fi done + unset ALGORITHM cecho ${BAD} "${ARCHIVE_FILE}: FAILED" - cecho ${BAD} "${CURRENT} does not match any in ${CHECKSUM}" + cecho ${BAD} "Checksum does not match any in ${CHECKSUM}" return 3 } @@ -313,7 +348,7 @@ download_archive () { verify_archive ${ARCHIVE_FILE} archive_state=$? if [ ${archive_state} = 0 ] || [ ${archive_state} = 1 ] || [ ${archive_state} = 4 ]; then - # If the download was successful, and the CHECKSUM is matching, ignored, or not possible + # If the download was successful, and the CHECKSUM is matching, skipped, or not possible return 0; fi unset archive_state diff --git a/deal.II-toolchain/packages/p4est.package b/deal.II-toolchain/packages/p4est.package index 578dd0a..ecdfbd2 100644 --- a/deal.II-toolchain/packages/p4est.package +++ b/deal.II-toolchain/packages/p4est.package @@ -1,6 +1,10 @@ #VERSION=1.1;CHECKSUM=37ba7f4410958cfb38a2140339dbf64f #VERSION=2.0;CHECKSUM=1b7440a78a28ebf713361acfea70ee78 -VERSION=2.2;CHECKSUM=6943949a6678589ebf1686ee7bad7ea1 + +VERSION=2.2 +CHECKSUM=1549cbeba29bee2c35e7cc50a90a04961da5f23b6eada9c8047f511b90a8e438 +CHECKSUM="${CHECKSUM} 28cbaf51a335c8cc8e78bb38bbb99251ba7ebf80" +CHECKSUM="${CHECKSUM} 6943949a6678589ebf1686ee7bad7ea1" NAME=p4est-$VERSION EXTRACTSTO=p4est-${VERSION}