X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/59ba108361c2e13273fd282526c7a17822411748..8d6baf0057572fba7f20c4824918fcbebc86edc5:/openwrt/scripts/download.pl?ds=sidebyside diff --git a/openwrt/scripts/download.pl b/openwrt/scripts/download.pl index edd32d5c8..08caa03e7 100755 --- a/openwrt/scripts/download.pl +++ b/openwrt/scripts/download.pl @@ -5,11 +5,11 @@ use warnings; my $target = shift @ARGV; my $filename = shift @ARGV; my $md5sum = shift @ARGV; -my @mirrors = @ARGV; +my @mirrors; my $ok; -@mirrors > 0 or die "Syntax: $0 [ ...]\n"; +@ARGV > 0 or die "Syntax: $0 [ ...]\n"; sub download { @@ -54,10 +54,7 @@ sub cleanup unlink "$target/$filename.md5sum"; } -while (!$ok) { - my $mirror = shift @mirrors; - $mirror or die "No more mirrors to try - giving up.\n"; - +foreach my $mirror (@ARGV) { if ($mirror =~ /^\@SF\/(.+)$/) { my $sfpath = $1; open SF, "wget -t1 -q -O- 'http://prdownloads.sf.net/$sfpath/$filename' |"; @@ -67,9 +64,26 @@ while (!$ok) { }; } close SF; + } elsif ($mirror =~ /^\@GNU\/(.+)$/) { + my $gnupath = $1; + push @mirrors, "ftp://ftp.gnu.org/gnu/$gnupath"; + push @mirrors, "ftp://ftp.belnet.be/mirror/ftp.gnu.org/gnu/$gnupath"; + push @mirrors, "ftp://ftp.mirror.nl/pub/mirror/gnu/$gnupath"; + push @mirrors, "http://mirror.switch.ch/ftp/mirror/gnu/$gnupath"; } else { - download($mirror); + push @mirrors, $mirror; } +} + +push @mirrors, 'http://mirror1.openwrt.org/'; +push @mirrors, 'http://mirror2.openwrt.org/'; +push @mirrors, 'http://downloads.openwrt.org/sources/'; + +while (!$ok) { + my $mirror = shift @mirrors; + $mirror or die "No more mirrors to try - giving up.\n"; + + download($mirror); -f "$target/$filename" and $ok = 1; }