logo

live-bootstrap

Mirror of <https://github.com/fosslinux/live-bootstrap>
commit: 043fdd448a6ef60b48c6b54e67108cc091bfc40c
parent 514190c4c257e1aaeebdc7e1439fda17a37fc14b
Author: Eduardo Sánchez Muñoz <eduardosm-dev@e64.io>
Date:   Sun, 19 Mar 2023 12:28:09 +0100

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.

Diffstat:

Mdownload-distfiles.sh2+-
Msysa/helpers.sh2+-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 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 @@ -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"