X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=scripts%2Fdownload.pl;h=40b8d212a5f4f832cddbc61da30513a987455b91;hb=3cb6e4ad50c7d3935da161273c093992534b5a0e;hp=cbe19348e224ad486657789ca961655a358dfb1e;hpb=b7f006cdab078b95ddb8585750c71877946490df;p=openwrt.git diff --git a/scripts/download.pl b/scripts/download.pl index cbe19348e2..40b8d212a5 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -1,21 +1,28 @@ #!/usr/bin/perl +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + use strict; 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 { my $mirror = shift; - open WGET, "wget -t1 --connect-timeout=20 --read-timeout=15 -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n"; + open WGET, "wget -t1 --timeout=20 -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n"; open MD5SUM, "| md5sum > \"$target/$filename.md5sum\"" or die "Cannot launch md5sum.\n"; open OUTPUT, "> $target/$filename.dl" or die "Cannot create file $target/$filename.dl: $!\n"; my $buffer; @@ -54,22 +61,44 @@ 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' |"; + open SF, "wget -t1 -q -O- 'http://prdownloads.sourceforge.net/$sfpath/$filename' |"; while () { - /RADIO NAME=use_default VALUE=(\w+) OnClick="form\.submit\(\)">/ and do { + /RADIO NAME=use_default VALUE=(\w+) OnClick="form\.submit\(\)">/ or + /type="radio" name="use_default" value="(\w+)" onclick="form\.submit\(\)"\/>/ and do { + push @mirrors, "http://$1.dl.sourceforge.net/sourceforge/$sfpath"; + }; + /Download/ and do { push @mirrors, "http://$1.dl.sourceforge.net/sourceforge/$sfpath"; }; } + push @mirrors, "http://dl.sourceforge.net/sourceforge/$sfpath"; 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"; + push @mirrors, "ftp://ftp.uu.net/archive/systems/gnu/$gnupath"; + push @mirrors, "ftp://ftp.eu.uu.net/pub/gnu/$gnupath"; + push @mirrors, "ftp://ftp.leo.org/pub/comp/os/unix/gnu/$gnupath"; + push @mirrors, "ftp://ftp.digex.net/pub/gnu/$gnupath"; } else { - download($mirror); + push @mirrors, $mirror; } +} + +push @mirrors, 'http://mirror1.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; }