From 043fdd448a6ef60b48c6b54e67108cc091bfc40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Sun, 19 Mar 2023 12:28:09 +0100 Subject: [PATCH] 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. --- download-distfiles.sh | 2 +- sysa/helpers.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/download-distfiles.sh b/download-distfiles.sh index 2877cfd..c393ad2 100755 --- a/download-distfiles.sh +++ b/download-distfiles.sh @@ -15,7 +15,7 @@ download_source() { local dest_path="${distfiles}/${fname}" if ! [ -e "${dest_path}" ]; then echo "Downloading ${fname}" - curl -L "${url}" --output "${dest_path}" + curl --fail --location "${url}" --output "${dest_path}" fi echo "${checksum} ${dest_path}" | sha256sum -c } diff --git a/sysa/helpers.sh b/sysa/helpers.sh index baa466b..7b9f1ea 100755 --- a/sysa/helpers.sh +++ b/sysa/helpers.sh @@ -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"