From: Timo Heister Date: Thu, 4 Feb 2016 23:02:37 +0000 (-0500) Subject: curl: report errors and follow redirects X-Git-Tag: v0.8.4~11^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d0857c31fa037a4a67698b1d7183eca2be20ffb;p=candi.git curl: report errors and follow redirects - curl -f will report an error code if the source reports 404 which happens if the mirror doesn't contain the file. Otherwise we are left with an invalid file. - curl -L will follow redirects (302), which sourceforge uses sometimes. Before we downloaded an invalid file (html page). - verify_archive will no longer accept empty files as valid --- diff --git a/candi.sh b/candi.sh index 1d2942d..263f129 100755 --- a/candi.sh +++ b/candi.sh @@ -153,6 +153,11 @@ verify_archive() { if [ ! -e ${ARCHIVE_FILE} ]; then return 2 fi + + # empty file? + if [ ! -s ${ARCHIVE_FILE} ]; then + return 2 + fi # Check CHECKSUM has been specified for the package if [ -z "${CHECKSUM}" ]; then @@ -242,14 +247,14 @@ download_archive () { # Download. # If curl or wget is failing, continue this loop for trying an other mirror. if [ ${DOWNLOADER} = "curl" ]; then - curl -k -O ${url} || continue + curl -f -L -k -O ${url} || continue elif [ ${DOWNLOADER} = "wget" ]; then wget --no-check-certificate ${url} -O ${ARCHIVE_FILE} || continue else cecho ${BAD} "candi: Unknown downloader: ${DOWNLOADER}" exit 1 fi - + unset url # Verify the download