diff options
-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; - |