0006-build-add-support-for-choosing-a-different-url-filename-part-than-the-output-file.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Tue, 9 Feb 2016 13:49:01 +0100
  3. Subject: build: add support for choosing a different url filename part than the output file
  4. Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  5. Backport of r47591 and r48427
  6. diff --git a/include/download.mk b/include/download.mk
  7. index 937b5d3..e518cce 100644
  8. --- a/include/download.mk
  9. +++ b/include/download.mk
  10. @@ -44,11 +44,11 @@ define DownloadMethod/unknown
  11. endef
  12. define DownloadMethod/default
  13. - $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" $(foreach url,$(URL),"$(url)")
  14. + $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MD5SUM)" "$(URL_FILE)" $(foreach url,$(URL),"$(url)")
  15. endef
  16. define wrap_mirror
  17. - $(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" || ( $(1) ),$(1))
  18. + $(if $(if $(MIRROR),$(filter-out x,$(MIRROR_MD5SUM))),@$(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(FILE)" "$(MIRROR_MD5SUM)" "" || ( $(1) ),$(1))
  19. endef
  20. define DownloadMethod/cvs
  21. @@ -157,6 +157,7 @@ Validate/darcs=VERSION SUBDIR
  22. define Download/Defaults
  23. URL:=
  24. FILE:=
  25. + URL_FILE:=
  26. PROTO:=
  27. MD5SUM:=
  28. SUBDIR:=
  29. diff --git a/scripts/download.pl b/scripts/download.pl
  30. index cd68a7b..111d03c 100755
  31. --- a/scripts/download.pl
  32. +++ b/scripts/download.pl
  33. @@ -11,15 +11,19 @@ use warnings;
  34. use File::Basename;
  35. use File::Copy;
  36. -@ARGV > 2 or die "Syntax: $0 <target dir> <filename> <md5sum> [<mirror> ...]\n";
  37. +@ARGV > 2 or die "Syntax: $0 <target dir> <filename> <md5sum> <url filename> [<mirror> ...]\n";
  38. +my $url_filename;
  39. my $target = shift @ARGV;
  40. my $filename = shift @ARGV;
  41. my $md5sum = shift @ARGV;
  42. +$url_filename = shift @ARGV unless $ARGV[0] =~ /:\/\//;
  43. my $scriptdir = dirname($0);
  44. my @mirrors;
  45. my $ok;
  46. +$url_filename or $url_filename = $filename;
  47. +
  48. sub localmirrors {
  49. my @mlist;
  50. open LM, "$scriptdir/localmirrors" and do {
  51. @@ -106,7 +110,7 @@ sub download
  52. return;
  53. }
  54. } else {
  55. - open WGET, "wget -t5 --timeout=20 --no-check-certificate $options -O- '$mirror/$filename' |" or die "Cannot launch wget.\n";
  56. + open WGET, "wget -t5 --timeout=20 --no-check-certificate $options -O- '$mirror/$url_filename' |" or die "Cannot launch wget.\n";
  57. open MD5SUM, "| $md5cmd > '$target/$filename.md5sum'" or die "Cannot launch md5sum.\n";
  58. open OUTPUT, "> $target/$filename.dl" or die "Cannot create file $target/$filename.dl: $!\n";
  59. my $buffer;