aboutsummaryrefslogtreecommitdiffstats
path: root/grpmi/curl_download/curl_download.pm
diff options
context:
space:
mode:
Diffstat (limited to 'grpmi/curl_download/curl_download.pm')
-rw-r--r--grpmi/curl_download/curl_download.pm27
1 files changed, 26 insertions, 1 deletions
diff --git a/grpmi/curl_download/curl_download.pm b/grpmi/curl_download/curl_download.pm
index 329a05c2..7c6ec472 100644
--- a/grpmi/curl_download/curl_download.pm
+++ b/grpmi/curl_download/curl_download.pm
@@ -1,14 +1,39 @@
package curl_download;
use strict;
-use vars qw($VERSION @ISA);
+use vars qw($VERSION @ISA @EXPORT);
+use MDK::Common;
require DynaLoader;
@ISA = qw(DynaLoader);
+@EXPORT = qw(download readproxy writeproxy);
$VERSION = '1.0';
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 writeproxy {
+ my ($proxy, $proxy_user) = @_;
+ output("/etc/urpmi/proxy.cfg",
+ if_($proxy, "http_proxy=$proxy\n"),
+ if_($proxy_user, "proxy_user=$proxy_user\n"));
+}
+
+sub download {
+ my ($url, $location, $downloadprogress_callback) = @_;
+
+ download_real($url, $location, $downloadprogress_callback, readproxy());
+}
+
1;