diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-12-02 14:37:37 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-12-02 14:37:37 +0000 |
commit | 77b03c95a1f5f69e5f9c40c1deeb89948192ce43 (patch) | |
tree | 39e5be3b372a651082c04d04d5970d082f7fcb6f | |
parent | c0c8d35be233c5202cb9e90ecffdd0a33acee2e8 (diff) | |
download | urpmi-77b03c95a1f5f69e5f9c40c1deeb89948192ce43.tar urpmi-77b03c95a1f5f69e5f9c40c1deeb89948192ce43.tar.gz urpmi-77b03c95a1f5f69e5f9c40c1deeb89948192ce43.tar.bz2 urpmi-77b03c95a1f5f69e5f9c40c1deeb89948192ce43.tar.xz urpmi-77b03c95a1f5f69e5f9c40c1deeb89948192ce43.zip |
Add new switches to the urpm tools, --wget-options, --curl-options and
--rsync-options, to specify additionnal command-line options to pass to the
downloader programs. These are also available as global variables that can
be set in urpmi.cfg.
-rw-r--r-- | urpm.pm | 12 | ||||
-rw-r--r-- | urpm/args.pm | 10 | ||||
-rw-r--r-- | urpm/cfg.pm | 1 | ||||
-rw-r--r-- | urpm/download.pm | 7 |
4 files changed, 23 insertions, 7 deletions
@@ -58,11 +58,9 @@ sub new { } #- syncing algorithms. -#- currently wget and curl methods are implemented; trying to find the best -#- (and one which will work :-) sub sync_webfetch { - my $urpm = shift @_; - my $options = shift @_; + my $urpm = shift; + my $options = shift; my %files; #- currently ftp and http protocols are managed by curl or wget, #- ssh and rsync protocols are managed by rsync *AND* ssh. @@ -77,6 +75,9 @@ sub sync_webfetch { $urpm->{fatal}(10, $@) if $@; delete @files{qw(removable file)}; } + for my $cpt (qw(wget-options curl-options rsync-options)) { + $options->{$cpt} = $urpm->{options}{$cpt} if defined $urpm->{options}{$cpt}; + } if ($files{ftp} || $files{http} || $files{https}) { my @webfetch = qw(curl wget); my @available_webfetch = grep { -x "/usr/bin/$_" } @webfetch; @@ -174,6 +175,9 @@ sub read_config { split-level strict-arch verify-rpm + curl-options + rsync-options + wget-options )) { if (defined $config->{''}{$opt} && !exists $urpm->{options}{$opt}) { $urpm->{options}{$opt} = $config->{''}{$opt}; diff --git a/urpm/args.pm b/urpm/args.pm index 4700402a..9b62d1d8 100644 --- a/urpm/args.pm +++ b/urpm/args.pm @@ -90,6 +90,9 @@ my %options_spec = ( 'parallel=s' => \$::parallel, wget => sub { $urpm->{options}{downloader} = 'wget' }, curl => sub { $urpm->{options}{downloader} = 'curl' }, + 'curl-options=s' => sub { $urpm->{options}{'curl-options'} = $_[1] }, + 'rsync-options=s' => sub { $urpm->{options}{'rsync-options'} = $_[1] }, + 'wget-options=s' => sub { $urpm->{options}{'wget-options'} = $_[1] }, 'limit-rate=s' => sub { $urpm->{options}{'limit-rate'} = $_[1] }, 'resume!' => sub { $urpm->{options}{resume} = $_[1] }, 'retry=s' => sub { $urpm->{options}{retry} = $_[1] }, @@ -349,13 +352,16 @@ foreach my $k ("help|h", "version", "no-locales", "update", "media|mediums=s", $options_spec{urpmf}{$k} = $options_spec{urpmi}{$k}; } -foreach my $k ("help|h", "version", "wget", "curl", "proxy=s", "proxy-user=s") { +foreach my $k ("help|h", "version", "wget", "curl", "proxy=s", "proxy-user=s", + "wget-options=s", "curl-options=s", "rsync-options=s") +{ $options_spec{'urpmi.update'}{$k} = $options_spec{urpmq}{$k} = $options_spec{urpmi}{$k}; } foreach my $k ("help|h", "wget", "curl", "proxy=s", "proxy-user=s", "c", "f", "z", - "limit-rate=s", "no-md5sum", "update", "norebuild!") + "limit-rate=s", "no-md5sum", "update", "norebuild!", + "wget-options=s", "curl-options=s", "rsync-options=s") { $options_spec{'urpmi.addmedia'}{$k} = $options_spec{'urpmi.update'}{$k}; } diff --git a/urpm/cfg.pm b/urpm/cfg.pm index ea233d85..7cf5f62f 100644 --- a/urpm/cfg.pm +++ b/urpm/cfg.pm @@ -150,6 +150,7 @@ sub load_config ($;$) { |prohibit-remove |downloader |retry + |(?:curl|rsync|wget)-options )\s*:\s*['"]?(.*?)['"]?$/x and $config{$medium}{$1} = $2, next; /^key[-_]ids\s*:\s*['"]?(.*?)['"]?$/ diff --git a/urpm/download.pm b/urpm/download.pm index c005ede1..afde787e 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -220,6 +220,7 @@ sub sync_wget { "--no-check-certificate", "--timeout=$CONNECT_TIMEOUT", "-NP", + (defined $options->{'wget-options'} ? split /\s+/, $options->{'wget-options'} : ()), $options->{dir}, @_ ) . " |"; @@ -293,7 +294,9 @@ sub sync_curl { "--stderr", "-", # redirect everything to stdout "--disable-epsv", "--connect-timeout", $CONNECT_TIMEOUT, - "-s", "-I", @ftp_files) . " |"; + "-s", "-I", + (defined $options->{'curl-options'} ? split /\s+/, $options->{'curl-options'} : ()), + @ftp_files) . " |"; while (<$curl>) { if (/Content-Length:\s*(\d+)/) { !$cur_ftp_file || exists($ftp_files_info{$cur_ftp_file}{size}) @@ -353,6 +356,7 @@ sub sync_curl { "-f", "--disable-epsv", "--connect-timeout", $CONNECT_TIMEOUT, + (defined $options->{'curl-options'} ? split /\s+/, $options->{'curl-options'} : ()), "--stderr", "-", # redirect everything to stdout @all_files) . " |"; local $/ = \1; #- read input by only one char, this is slow but very nice (and it works!). @@ -429,6 +433,7 @@ sub sync_rsync { ($options->{compress} ? qw(-z) : @{[]}), ($options->{ssh} ? qw(-e ssh) : @{[]}), qw(--partial --no-whole-file), + (defined $options->{'rsync-options'} ? split /\s+/, $options->{'rsync-options'} : ()), "'$file' '$options->{dir}' |"); local $/ = \1; #- read input by only one char, this is slow but very nice (and it works!). while (<$rsync>) { |