[Buildroot] [PATCH 2/3] support/download: properly catch missing hashes
Yann E. MORIN
yann.morin.1998 at free.fr
Mon Mar 16 22:41:48 UTC 2015
When checking hashes reports no hash for a file, and this is treated as
an error (now: because BR2_ENFORCE_CHECK_HASH is set; later: becasue
that will be the new and only behaviour), exit promptly in error.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
---
support/download/dl-wrapper | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index 3b30840..d93a159 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -48,10 +48,19 @@ main() {
error "no hash-file specified, use -H\n"
fi
- # If the output file already exists, do not download it again
+ # If the output file already exists and:
+ # - there's no .hash file: do not download it again and exit promptly
+ # - matches all its hashes: do not download it again and exit promptly
+ # - fails at least one of its hashes: force a re-download
+ # - there's no hash (but a .hash file): consider it a hard error
if [ -e "${output}" ]; then
if support/download/check-hash ${quiet} "${hfile}" "${output}" "${output##*/}"; then
exit 0
+ elif [ ${?} -eq 2 ]; then
+ # Do not remove the file, otherwise it might get re-downloaded
+ # from a later location (i.e. primary -> upstream -> mirror).
+ # Do not print a message, check-hash already did
+ exit 2
fi
rm -f "${output}"
warn "Re-downloading '%s'...\n" "${output##*/}"
--
1.9.1
More information about the buildroot
mailing list