aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorwsnipex <wsnipex@a1.net>2022-02-13 08:40:16 +0100
committerwsnipex <wsnipex@a1.net>2022-02-13 08:43:39 +0100
commit7097baf8e116264d225631bc23cb4c8324051e9b (patch)
tree797b2d7015564d88c5fa896ceedf202abd835d24 /tools
parenta5f198796d15dea79dc6f35ad3a064d762fa628f (diff)
[depends] retry downloading tarballs up to 3 times
Diffstat (limited to 'tools')
-rw-r--r--tools/depends/download-files.include20
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/depends/download-files.include b/tools/depends/download-files.include
index de5bf438bb..9b09fc574e 100644
--- a/tools/depends/download-files.include
+++ b/tools/depends/download-files.include
@@ -18,6 +18,12 @@ ifeq ($(NATIVE_OS), osx)
SED_FLAG = -i ''
endif
+# non-depends builds might not set this, use defaults
+ifeq ($(HASH_TOOL),)
+ HASH_TOOL = sha512sum
+ HASH_TOOL_FLAGS = -c --status
+endif
+
HASH_SUM = $($(shell echo $(HASH_TYPE) | tr '[:lower:]' '[:upper:]'))
.PHONY: $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
@@ -34,6 +40,18 @@ ifeq ($(HASH_FOUND),no)
endif
ifeq ($(HASH_FOUND),yes)
# we really need 2 spaces between sha hash and file name!
+# if the hash sum doesn't match we retry up to 3 times
@cd $(TARBALLS_LOCATION); echo "$(HASH_SUM) $(ARCHIVE)" > $(ARCHIVE).$(HASH_TYPE) && $(HASH_TOOL) $(HASH_TOOL_FLAGS) $(ARCHIVE).$(HASH_TYPE) \
- || { echo "Error: failed to verify hash sum of $(ARCHIVE), expected type: $(HASH_TYPE) value $(HASH_SUM)"; exit 3; }
+ || {\
+ echo "Error: failed to verify hash sum of $(ARCHIVE), expected type: $(HASH_TYPE) value $(HASH_SUM), retrying.." ;\
+ tries=1 ;\
+ while [ $$tries -le 3 ]; do \
+ echo "download $(ARCHIVE) retry $$tries" ;\
+ rm $(TARBALLS_LOCATION)/$(ARCHIVE) ;\
+ sleep 3 ;\
+ $(RETRIEVE_TOOL) $(RETRIEVE_TOOL_FLAGS) $(BASE_URL)/$(ARCHIVE) ;\
+ $(HASH_TOOL) $(HASH_TOOL_FLAGS) $(ARCHIVE).$(HASH_TYPE) && exit 0 || tries=$$((tries + 1)) ;\
+ done ;\
+ exit 1 ;\
+ }
endif