From 204a7e3a40c97cc47faf3a4ca04d2055e8177799 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 24 Jul 2024 18:03:52 +1000 Subject: [PATCH 1/2] tarball checksum check - use sha256sum -c There where some failures. Might be a divering implemnation on output but eitherway, sha256sum can check directly without needed to do the comparision in bash. Adjust path so the tarball can be found by sha256sum. --- script_templates/get_tarball.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/script_templates/get_tarball.sh b/script_templates/get_tarball.sh index a92e907fe..17e6bde36 100644 --- a/script_templates/get_tarball.sh +++ b/script_templates/get_tarball.sh @@ -26,10 +26,9 @@ f="${tarbuildnum}/$tarball" verify_checksum() { echo "verify checksum" - checksum=$(wget -qO- "$artifacts_url/$tarbuildnum/sha256sums.txt" | awk '{print $1}') - checksum_file=$(sha256sum "$1" | awk '{print $1}') + wget -qO- "$artifacts_url/$tarbuildnum/sha256sums.txt" | sha256sum -c - - if [[ "$checksum_file" == "$checksum" ]]; then + if [ $? ]; then echo "checksum match" return 0 else @@ -61,29 +60,31 @@ download_tarball() { fi } -if [[ -f $d/$tarball ]]; then - echo "$d/$tarball already present" - if verify_checksum "$d/$tarball"; then +pushd "$d" +if [[ -f $tarball ]]; then + echo "$tarball already present" + if verify_checksum; then true else echo "download tarball again" - rm -f $d/$tarball + rm -f $tarball download_tarball - if verify_checksum "$d/$tarball"; then + if verify_checksum; then true else err "checksum does not match, aborting" fi fi else - echo "$d/$tarball does not exist, download tarball" + echo "$tarball does not exist, download tarball" download_tarball - if verify_checksum "$d/$tarball"; then + if verify_checksum "$tarball"; then true else err "checksum does not match, aborting" fi fi +popd echo "extract $d/$tarball" #//TEMP path on AIX are specific From b2ad5151f56aa98b4dcc7d09b43fec4b4b2bc58f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 25 Jul 2024 17:55:22 +1000 Subject: [PATCH 2/2] tarball show failed checksum calculations --- script_templates/get_tarball.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/script_templates/get_tarball.sh b/script_templates/get_tarball.sh index 17e6bde36..84697b29d 100644 --- a/script_templates/get_tarball.sh +++ b/script_templates/get_tarball.sh @@ -26,13 +26,18 @@ f="${tarbuildnum}/$tarball" verify_checksum() { echo "verify checksum" - wget -qO- "$artifacts_url/$tarbuildnum/sha256sums.txt" | sha256sum -c - + wget -qO- "$artifacts_url/$tarbuildnum/sha256sums.txt" | tee sha256sums.txt | sha256sum -c - if [ $? ]; then echo "checksum match" + rm sha256sums.txt return 0 else echo "checksum does not match" + sha256sum "$tarball" + echo "previous calculation" + cat sha256sums.txt + rm sha256sums.txt return 1 fi }