From 8f2e61c9289ad7e65fdd9a9f1c387043a30d1335 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Thu, 14 Sep 2017 04:39:51 +0100 Subject: [PATCH] scripts/get: fix logic error when download is successful, but checksum is invalid A download might succeed from, say, github, but have an invalid checksum. In this case it would not attempt the alternative download from the mirror (which might have the correct checksum), but instead it would repeatedly download from github until the download limit is exceeded, and then fail completely. --- scripts/get | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/get b/scripts/get index 4ac885b7e4..dc9f209e72 100755 --- a/scripts/get +++ b/scripts/get @@ -73,15 +73,16 @@ rm -f $STAMP_URL $STAMP_SHA NBWGET=10 while [ $NBWGET -gt 0 ]; do - rm -f $PACKAGE + for url in "$PKG_URL" "$PACKAGE_MIRROR"; do + rm -f $PACKAGE + if $WGET_CMD "$url"; then + CALC_SHA256="$(sha256sum $PACKAGE | cut -d" " -f1)" - if $WGET_CMD "$PKG_URL" || $WGET_CMD "$PACKAGE_MIRROR"; then - CALC_SHA256="$(sha256sum $PACKAGE | cut -d" " -f1)" + [ -z "${PKG_SHA256}" -o "${PKG_SHA256}" == "${CALC_SHA256}" ] && break 2 - [ -z "${PKG_SHA256}" -o "${PKG_SHA256}" == "${CALC_SHA256}" ] && break - - printf "%${BUILD_INDENT}c $(print_color CLR_WARNING "WARNING") Incorrect checksum calculated on downloaded file: got ${CALC_SHA256}, wanted ${PKG_SHA256}\n\n" ' '>&$SILENT_OUT - fi + printf "%${BUILD_INDENT}c $(print_color CLR_WARNING "WARNING") Incorrect checksum calculated on downloaded file: got ${CALC_SHA256}, wanted ${PKG_SHA256}\n\n" ' '>&$SILENT_OUT + fi + done NBWGET=$((NBWGET - 1)) done