Add --fail flag to curl download commands

By default, curls downloads the HTML error page and exits with code 0 when a server replies with a HTTP error code (e.g., 404), causing a SHA256 mismatch afterwards.

Adding the `--fail` flag makes curl exit with non-zero error code and print an error like "The requested URL returned error: 404", making it a bit easier to diagnose distfile download issues.

Also replaced `-L` with `--location` for the sake of script readability.
This commit is contained in:
Eduardo Sánchez Muñoz 2023-03-19 12:28:09 +01:00
parent 514190c4c2
commit 043fdd448a
2 changed files with 2 additions and 2 deletions

View file

@ -208,7 +208,7 @@ interpret_source_line() {
# Default to basename of url if not given
fname="${fname:-$(basename "${url}")}"
if ! [ -e "${fname}" ]; then
curl -L "${url}" --output "${fname}"
curl --fail --location "${url}" --output "${fname}"
fi
echo "${checksum} ${fname}" > "${fname}.sum"
sha256sum -c "${fname}.sum"