summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-06-29 07:16:51 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-06-29 07:16:51 +0000
commitc9e1ae1c9a310d2d1f237646ed381632cf071d4a (patch)
tree650ee1fa057c3ca2905ac318c173578d314e8773 /urpm
parente1d903c8ea73f57ca704720dacc747c66a785a32 (diff)
downloadurpmi-c9e1ae1c9a310d2d1f237646ed381632cf071d4a.tar
urpmi-c9e1ae1c9a310d2d1f237646ed381632cf071d4a.tar.gz
urpmi-c9e1ae1c9a310d2d1f237646ed381632cf071d4a.tar.bz2
urpmi-c9e1ae1c9a310d2d1f237646ed381632cf071d4a.tar.xz
urpmi-c9e1ae1c9a310d2d1f237646ed381632cf071d4a.zip
Support for setting proxy per-media in proxy.cfg
Diffstat (limited to 'urpm')
-rw-r--r--urpm/args.pm7
-rw-r--r--urpm/download.pm23
2 files changed, 24 insertions, 6 deletions
diff --git a/urpm/args.pm b/urpm/args.pm
index 67da7130..c55bf10e 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -4,6 +4,7 @@ use strict;
use warnings;
no warnings 'once';
use Getopt::Long;# 2.33;
+use urpm::download;
# The program that invokes us
(my $tool = $0) =~ s!.*/!!;
@@ -85,12 +86,14 @@ my %options_spec = (
my ($proxy, $port) = $value =~ m,^(?:http://)?([^:]+(:\d+)?)/*$,
or die N("bad proxy declaration on command line\n");
$proxy .= ":1080" unless $port;
- $urpm->{proxy}{http_proxy} = "http://$proxy";
+ $urpm->{proxy}{http_proxy} = "http://$proxy"; #- obsolete, for compat
+ urpm::download::set_cmdline_proxy(http_proxy => "http://$proxy");
},
'proxy-user=s' => sub {
my (undef, $value) = @_;
$value =~ /(.+):(.+)/ or die N("bad proxy declaration on command line\n");
- @{$urpm->{proxy}}{qw(user pwd)} = ($1, $2);
+ @{$urpm->{proxy}}{qw(user pwd)} = ($1, $2); #- obsolete, for compat
+ urpm::download::set_cmdline_proxy(user => $1, pwd => $2);
},
'bug=s' => \$options{bug},
'env=s' => \$::env,
diff --git a/urpm/download.pm b/urpm/download.pm
index 4308f9f6..8f46df6d 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -47,12 +47,27 @@ sub load_proxy_config () {
sub get_proxy (;$) {
my ($o_media) = @_; $o_media ||= '';
load_proxy_config();
- return $proxy_config->{$o_media} || {
- http_proxy => undef ,
- ftp_proxy => undef ,
+ return $proxy_config->{cmd_line}
+ || $proxy_config->{$o_media}
+ || $proxy_config->{''}
+ || {
+ http_proxy => undef,
+ ftp_proxy => undef,
+ user => undef,
+ pwd => undef,
+ };
+}
+
+#- overrides the config file proxy settings with values passed via command-line
+sub set_cmdline_proxy {
+ my (%h) = @_;
+ $proxy_config->{cmd_line} ||= {
+ http_proxy => undef,
+ ftp_proxy => undef,
user => undef,
- pwd => undef
+ pwd => undef,
};
+ $proxy_config->{cmd_line}{$_} = $h{$_} for keys %h;
}
#- set up the environment for proxy usage for the appropriate tool.