#! /usr/bin/perl # # $Id$ use strict; use LWP::UserAgent; # to retrieve url my $ua = LWP::UserAgent->new; use Getopt::Long; my %param; sub urltofile { my $file; if ($param{url} =~ m{^(http|ftp)://}) { $file = ($ENV{TMPDIR} || $ENV{TMP} || "/tmp")."setup.list.tmp"; if ($ENV{http_proxy}) { $ua->proxy(['http', 'ftp'], $ENV{http_proxy}) } my $req = HTTP::Request->new('GET', $param{'url'}); my $res = $ua->request($req, $file); return $res->is_success ? $file : ''; } $param{url} =~ /^file:(.*)/; $1; } GetOptions ( 'url=s' => \$param{url} ); $ua->agent("CheckUrl/0.1"); # my $realurl; open (URLLIST, urltofile()) or die "Unable to open file"; while () { s/#.*//; # no comments s/^\s+//; # no leading white s/\s+$//; # no trailing white length or next; # anything left? my %info; @info{qw(name mdkver arch location url)} = split(':',$_,5); next if (!$info{name}); my $realurl=$info{url}; $realurl =~ s/ with /\//; $realurl =~ s/ //g; #print $realurl."\n"; my ($fic) = $realurl =~ /\/([^\/]+)$/; $fic ||= $realurl; my $res; $res=system("curl -s -S $realurl > /tmp/$fic") if ( $realurl =~ m/^(http|ftp):\/\//); if ($realurl =~ m/^rsync:\/\// ) { $realurl =~ s/^rsync:\/\///; $res=system("rsync -aq --progress --no-whole-file $realurl /tmp/$fic"); } print "error $res $realurl\n" if ($res); } close URLLIST;