aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/host-build.mk2
-rw-r--r--include/package.mk2
-rwxr-xr-xscripts/download.pl18
3 files changed, 22 insertions, 0 deletions
diff --git a/include/host-build.mk b/include/host-build.mk
index 827ea6bbfb..79a9b1f8d6 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -184,6 +184,8 @@ ifndef DUMP
clean-build: host-clean-build
endif
+ $(DL_DIR)/$(FILE): FORCE
+
$(_host_target)host-prepare: $(HOST_STAMP_PREPARED)
$(_host_target)host-configure: $(HOST_STAMP_CONFIGURED)
$(_host_target)host-compile: $(HOST_STAMP_BUILT) $(HOST_STAMP_INSTALLED)
diff --git a/include/package.mk b/include/package.mk
index c541f6edf7..f6aa5ea8d0 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -185,6 +185,8 @@ define Build/CoreTargets
$(call Build/Autoclean)
$(call DefaultTargets)
+ $(DL_DIR)/$(FILE): FORCE
+
download:
$(foreach hook,$(Hooks/Download),
$(call $(hook))$(sep)
diff --git a/scripts/download.pl b/scripts/download.pl
index 5739c20cea..c1623bf91f 100755
--- a/scripts/download.pl
+++ b/scripts/download.pl
@@ -263,6 +263,24 @@ foreach my $mirror (@ARGV) {
push @mirrors, 'https://sources.openwrt.org';
push @mirrors, 'https://mirror2.openwrt.org/sources';
+if (-f "$target/$filename") {
+ $hash_cmd and do {
+ if (system("cat '$target/$filename' | $hash_cmd > '$target/$filename.hash'")) {
+ die "Failed to generate hash for $filename\n";
+ }
+
+ my $sum = `cat "$target/$filename.hash"`;
+ $sum =~ /^(\w+)\s*/ or die "Could not generate file hash\n";
+ $sum = $1;
+
+ exit 0 if $sum eq $file_hash;
+
+ die "Hash of the local file $filename does not match (file: $sum, requested: $file_hash) - deleting download.\n";
+ unlink "$target/$filename";
+ cleanup();
+ };
+}
+
while (!-f "$target/$filename") {
my $mirror = shift @mirrors;
$mirror or die "No more mirrors to try - giving up.\n";