diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-06-30 12:30:30 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-06-30 12:30:30 +0000 |
commit | 02c778bacdc79d03e37e71271f99980e369fcbfa (patch) | |
tree | 37ba98d8b0c875a147824f0a6061aab4cee50722 | |
parent | 42736422591a62e37d56746bb34af60a9037acd4 (diff) | |
download | rpmdrake-02c778bacdc79d03e37e71271f99980e369fcbfa.tar rpmdrake-02c778bacdc79d03e37e71271f99980e369fcbfa.tar.gz rpmdrake-02c778bacdc79d03e37e71271f99980e369fcbfa.tar.bz2 rpmdrake-02c778bacdc79d03e37e71271f99980e369fcbfa.tar.xz rpmdrake-02c778bacdc79d03e37e71271f99980e369fcbfa.zip |
Factorize the proxy.cfg code
-rw-r--r-- | grpmi/curl_download/curl_download.pm | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/grpmi/curl_download/curl_download.pm b/grpmi/curl_download/curl_download.pm index 7a3e07fb..e8583d03 100644 --- a/grpmi/curl_download/curl_download.pm +++ b/grpmi/curl_download/curl_download.pm @@ -1,34 +1,30 @@ package curl_download; use strict; -use vars qw($VERSION @ISA @EXPORT); use MDK::Common; +use urpm::download; require DynaLoader; -@ISA = qw(DynaLoader); -@EXPORT = qw(download readproxy writeproxy); -$VERSION = '1.0'; +our @ISA = qw(DynaLoader); +our @EXPORT = qw(download readproxy writeproxy); +our $VERSION = '1.1'; bootstrap curl_download $VERSION; -sub readproxy { - my ($proxy, $proxy_user); - foreach (cat_('/etc/urpmi/proxy.cfg')) { - /^http_proxy\s*=\s*(.*)$/ and $proxy = $1; - /^ftp_proxy\s*=\s*(.*)$/ and $proxy = $1; - /^proxy_user\s*=\s*(.*)$/ and $proxy_user = $1; - } - ($proxy, $proxy_user); +sub readproxy (;$) { + my $proxy = get_proxy(@_); + ($proxy->{http_proxy} || $proxy->{ftp_proxy} || '', + defined $proxy->{user} ? "$proxy->{user}:$proxy->{pwd}" : ''); } sub writeproxy { my ($proxy, $proxy_user) = @_; - my $f = '/etc/urpmi/proxy.cfg'; - output($f, - if_($proxy, "http_proxy=$proxy\n"), - if_($proxy_user, "proxy_user=$proxy_user\n")); - chmod 0600, $f; + my ($user, $pwd) = split /:/, $proxy_user; + set_proxy_config(user => $user); + set_proxy_config(pwd => $pwd); + set_proxy_config(http_proxy => $proxy); + dump_proxy_config(); } sub download { @@ -38,4 +34,3 @@ sub download { } 1; - |