From aea302356f82e5e92da1219ac8d3a35645a36e1e Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sun, 23 Oct 2016 07:47:52 -0400 Subject: [PATCH] Better checksum messages --- build-package.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build-package.sh b/build-package.sh index a0dd449f5..9584b2b8d 100755 --- a/build-package.sh +++ b/build-package.sh @@ -164,12 +164,16 @@ termux_download() { TRYMAX=6 for try in $(seq 1 $TRYMAX); do if curl -L --fail --retry 2 -o "$TMPFILE" "$URL"; then + local ACTUAL_CHECKSUM=`sha256sum $TMPFILE | cut -f 1 -d ' '` if [ $# = 3 ]; then # Optional checksum argument: - echo $3 "$TMPFILE" | sha256sum --check --strict --quiet + local EXPECTED=$3 + if [ $EXPECTED != $ACTUAL_CHECKSUM ]; then + >&2 printf "Wrong checksum for $URL:\nExpected: $EXPECTED\nActual: $ACTUAL_CHECKSUM\n" + exit 1 + fi else - echo "Note: No checksum of file" - sha256sum $TMPFILE + printf "No validation of checksum for $URL:\nActual: $ACTUAL_CHECKSUM\n" fi mv "$TMPFILE" "$DESTINATION" return