X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/65cfd58a27b7f3e348bb0c2cd54a38909f68880b..a53693f2f5dc5fea6eac79a71d7c7fb9002f49b7:/scripts/download.pl diff --git a/scripts/download.pl b/scripts/download.pl index e7c7ee32e..8f5d1d6b4 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -18,15 +18,27 @@ my $ok; @ARGV > 0 or die "Syntax: $0 [ ...]\n"; -my $md5cmd = `which md5sum`; -$md5cmd =~ /not found/ and $md5cmd = `which md5`; -$md5cmd =~ /not found/ and die 'no md5 checksum program found, please install md5 or md5sum'; +sub which($) { + my $prog = shift; + my $res = `which $prog`; + $res or return undef; + $res =~ /^no / and return undef; + $res =~ /not found/ and return undef; + return $res; +} + +my $md5cmd = which("md5sum"); +$md5cmd or $md5cmd = which("md5"); +$md5cmd or die 'no md5 checksum program found, please install md5 or md5sum'; +chomp $md5cmd; sub download { my $mirror = shift; + my $options = $ENV{WGET_OPTIONS}; + $options or $options = ""; - open WGET, "wget -t1 --timeout=20 -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n"; + open WGET, "wget -t1 --timeout=20 $options -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n"; open MD5SUM, "| $md5cmd > \"$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; @@ -43,7 +55,6 @@ sub download cleanup(); return; } - $? = 0; my $sum = `cat "$target/$filename.md5sum"`; $sum =~ /^(\w+)\s*/ or die "Could not generate md5sum\n";