summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2002-07-11 14:01:58 +0000
committerFrancois Pons <fpons@mandriva.com>2002-07-11 14:01:58 +0000
commit5af1271ab553aa62a3ef995d173a45e1907d8bd2 (patch)
treeed4741d9b11c877cc893ae00f059b3d0a45db203
parent226d3fc89d5ae6c5c5c86394e86b4fe16740c271 (diff)
downloadurpmi-5af1271ab553aa62a3ef995d173a45e1907d8bd2.tar
urpmi-5af1271ab553aa62a3ef995d173a45e1907d8bd2.tar.gz
urpmi-5af1271ab553aa62a3ef995d173a45e1907d8bd2.tar.bz2
urpmi-5af1271ab553aa62a3ef995d173a45e1907d8bd2.tar.xz
urpmi-5af1271ab553aa62a3ef995d173a45e1907d8bd2.zip
3.7-3mdk
-rw-r--r--urpm.pm83
-rwxr-xr-xurpmi20
-rwxr-xr-xurpmi.addmedia16
-rw-r--r--urpmi.spec7
-rwxr-xr-xurpmi.update16
-rwxr-xr-xurpmq18
6 files changed, 147 insertions, 13 deletions
diff --git a/urpm.pm b/urpm.pm
index 2760a7b2..df204f06 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -121,6 +121,7 @@ sub new {
depslist => [],
sync => \&sync_webfetch, #- first argument is directory, others are url to fetch.
+ proxy => get_proxy(),
fatal => sub { printf STDERR "%s\n", $_[1]; exit($_[0]) },
error => sub { printf STDERR "%s\n", $_[0] },
@@ -128,6 +129,57 @@ sub new {
}, $class;
}
+sub get_proxy {
+ my $proxy = {
+ http_proxy => undef ,
+ user => undef,
+ pwd => undef
+ };
+ local (*F, $_);
+ # open F, "$ENV{HOME}/.wgetrc" or return;
+ open F, "/etc/urpmi/proxy.cfg" or return;
+ while (<F>) {
+ chomp; s/#.*$//; s/^\s*//; s/\s*$//;
+ /^http_proxy\s*=\s*(.*)$/ and $proxy->{http_proxy} = $1, next;
+ /^ftp_proxy\s*=\s*(.*)$/ and $proxy->{ftp_proxy} = $1, next;
+ /^proxy_user\s*=\s*(.*):(.*)$/ and do {
+ $proxy->{user} = $1;
+ $proxy->{pwd} = $2;
+ next;
+ };
+ next;
+ }
+ close F;
+ $proxy;
+}
+
+sub set_proxy {
+ my $proxy = shift @_;
+ my @res;
+ if (defined $proxy->{proxy}->{http_proxy} or defined $proxy->{proxy}->{ftp_proxy}) {
+ for ($proxy->{type}) {
+ /wget/ && do {
+ for ($proxy->{proxy}) {
+ $ENV{http_proxy} = $_->{http_proxy} if defined $_->{http_proxy};
+ $ENV{ftp_proxy} = $_->{ftp_proxy} if defined $_->{ftp_proxy};
+ @res = ("--proxy-user=$_->{user}", "--proxy-passwd=$_->{pwd}") if defined $_->{user} && defined $_->{pwd};
+ }
+ last;
+ };
+ /curl/ && do {
+ for ($proxy->{proxy}) {
+ push @res, "-x $_->{http_proxy}" if defined $_->{http_proxy};
+ push @res, "-x $_->{ftp_proxy}" if defined $_->{ftp_proxy};
+ push @res, "-U $_->{user}:$_->{pwd}" if defined $_->{user} && defined $_->{pwd};
+ }
+ last;
+ };
+ die _("Unknown webfetch `$proxy->{type}' !!!\n");
+ }
+ }
+ return @res;
+}
+
#- quoting/unquoting a string that may be containing space chars.
sub quotespace { local $_ = $_[0]; s/(\s)/\\$1/g; $_ }
sub unquotespace { local $_ = $_[0]; s/\\(\s)/$1/g; $_ }
@@ -167,8 +219,10 @@ sub sync_webfetch {
sub sync_wget {
-x "/usr/bin/wget" or die _("wget is missing\n");
my $options = shift @_;
- system "/usr/bin/wget", (ref $options && $options->{quiet} ? ("-q") : ()), "-NP",
- (ref $options ? $options->{dir} : $options), @_;
+ system "/usr/bin/wget",
+ (ref $options && set_proxy({type => "wget", proxy => $options->{proxy}})),
+ (ref $options && $options->{quiet} ? ("-q") : ()), "-NP",
+ (ref $options ? $options->{dir} : $options), @_;
$? == 0 or die _("wget failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
}
sub sync_curl {
@@ -187,7 +241,10 @@ sub sync_curl {
#- prepare to get back size and time stamp of each file.
local *CURL;
- open CURL, "/usr/bin/curl -I " . join(" ", map { "'$_'" } @ftp_files) . " |";
+ open CURL, "/usr/bin/curl" .
+ " " . (ref $options && set_proxy({type => "curl", proxy => $options->{proxy}})) .
+ " " . (ref $options && $options->{quiet} ? ("-s") : ()) .
+ " -I " . join(" ", map { "'$_'" } @ftp_files) . " |";
while (<CURL>) {
if (/Content-Length:\s*(\d+)/) {
!$cur_ftp_file || exists $ftp_files_info{$cur_ftp_file}{size} and $cur_ftp_file = shift @ftp_files;
@@ -222,7 +279,10 @@ sub sync_curl {
#- options for ftp files, -R (-O <file>)*
#- options for http files, -R (-z file -O <file>)*
if (my @all_files = ((map { ("-O", $_ ) } @ftp_files), (map { /\/([^\/]*)$/ ? ("-z", $1, "-O", $_) : () } @other_files))) {
- system "/usr/bin/curl", (ref $options && $options->{quiet} ? ("-s") : ()), "-R", "-f", @all_files;
+ system "/usr/bin/curl",
+ (ref $options && set_proxy({type => "curl", proxy => $options->{proxy}})),
+ (ref $options && $options->{quiet} ? ("-s") : ()), "-R", "-f",
+ @all_files;
$? == 0 or die _("curl failed: exited with %d or signal %d\n", $? >> 8, $? & 127);
}
}
@@ -560,7 +620,8 @@ sub add_distrib_media {
unlink "$urpm->{cachedir}/partial/hdlists";
eval {
$urpm->{log}(_("retrieving hdlists file..."));
- $urpm->{sync}("$urpm->{cachedir}/partial", reduce_pathname("$url/Mandrake/base/hdlists"));
+# $urpm->{sync}({proxy => $urpm->{proxy}}, "$urpm->{cachedir}/partial", reduce_pathname("$url/Mandrake/base/hdlists"));
+ $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy}}, reduce_pathname("$url/Mandrake/base/hdlists"));
$urpm->{log}(_("...retrieving done"));
};
$@ and $urpm->{log}(_("...retrieving failed: %s", $@));
@@ -859,7 +920,7 @@ sub update_media {
}
eval {
$urpm->{log}(_("retrieving description file of \"%s\"...", $medium->{name}));
- $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1 },
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} },
reduce_pathname("$medium->{url}/../descriptions"));
$urpm->{log}(_("...retrieving done"));
};
@@ -884,7 +945,7 @@ sub update_media {
unlink "$urpm->{cachedir}/partial/$basename";
eval {
- $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1 }, reduce_pathname("$medium->{url}/$_"));
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy} }, reduce_pathname("$medium->{url}/$_"));
};
if (!$@ && -s "$urpm->{cachedir}/partial/$basename" > 32) {
$medium->{with_hdlist} = $_;
@@ -905,7 +966,8 @@ sub update_media {
system("cp", "-a", "$urpm->{statedir}/$medium->{hdlist}", "$urpm->{cachedir}/partial/$basename");
}
eval {
- $urpm->{sync}("$urpm->{cachedir}/partial", reduce_pathname("$medium->{url}/$medium->{with_hdlist}"));
+# $urpm->{sync}({proxy => $urpm->{proxy}}, "$urpm->{cachedir}/partial", reduce_pathname("$medium->{url}/$medium->{with_hdlist}"));
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy}}, reduce_pathname("$medium->{url}/$medium->{with_hdlist}"));
};
if ($@) {
$urpm->{log}(_("...retrieving failed: %s", $@));
@@ -942,7 +1004,7 @@ sub update_media {
unlink "$urpm->{cachedir}/partial/list";
my $local_list = $medium->{with_hdlist} =~ /hd(list.*)\.cz$/ ? $1 : 'list';
eval {
- $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1},
+ $urpm->{sync}({ dir => "$urpm->{cachedir}/partial", quiet => 1, proxy => $urpm->{proxy}},
reduce_pathname("$medium->{url}/$local_list"));
$local_list ne 'list' and
rename("$urpm->{cachedir}/partial/$local_list", "$urpm->{cachedir}/partial/list");
@@ -1681,7 +1743,8 @@ sub download_source_packages {
foreach (map { m|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)| ? "$1xxxx$2" : $_ } @distant_sources) {
$urpm->{log}(" $_") ;
}
- $urpm->{sync}("$urpm->{cachedir}/rpms", @distant_sources);
+# $urpm->{sync}({proxy => $urpm->{proxy}}, "$urpm->{cachedir}/rpms", @distant_sources);
+ $urpm->{sync}({dir => "$urpm->{cachedir}/rpms", quiet => 1, proxy => $urpm->{proxy}}, @distant_sources);
$urpm->{log}(_("...retrieving done"));
};
$@ and $urpm->{log}(_("...retrieving failed: %s", $@));
diff --git a/urpmi b/urpmi
index 4dff3378..49c7692f 100755
--- a/urpmi
+++ b/urpmi
@@ -71,6 +71,10 @@ usage:
") . _(" --force - force invocation even if some packages do not exist.
") . _(" --wget - use wget to retrieve distant files.
") . _(" --curl - use curl to retrieve distant files.
+") . _(" --proxy - use specified HTTP proxy, the port number is assumed
+ to be 1080 by default (format is <proxyhost[:port]>).
+") . _(" --proxy-user - specify user and password to use for proxy
+ authentication (format is <user:password>).
") . _(" --bug - output a bug report in directory indicated by next arg.
") . _(" --env - use specific environment (typically a bug report).
") . _(" --X - use X interface.
@@ -107,6 +111,18 @@ for (@ARGV) {
else { $options = { dir => $options, prefer => 'wget' } }
urpm::sync_webfetch($options, @_) }; next };
/^--curl$/ and do { $sync = \&urpm::sync_webfetch; next };
+ /^--proxy$/ and do {
+ ($_ = shift @_) =~ m,^http://([^:]+)(:([\d]+)|[^:])$, or die $usage;
+ $_ .= ":1080" if /[^\d]/;
+ $urpm->{proxy}->{http_proxy} = $_;
+ next;
+ };
+ /^--proxy-user$/ and do {
+ ($_ = shift @_) =~ /(.+):(.+)/, or die $usage;
+ $urpm->{proxy}->{user} = $1;
+ $urpm->{proxy}->{pwd} = $2;
+ next;
+ };
/^--bug$/ and do { push @nextargv, \$bug; next };
/^--env$/ and do { push @nextargv, \$env; next };
/^--X$/ and do { $X = 1; next };
@@ -460,7 +476,7 @@ if (%sources_install || %sources) {
} else {
my @l = $urpm->install($root, \%sources_install, \%sources);
if (@l) {
- message(_("Installation failed"));
+ message(_("Installation failed") . ":\n" . join("\n", @l));
m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file
$auto and exit 1; #- if auto has been set, avoid asking user.
@@ -472,7 +488,7 @@ if (%sources_install || %sources) {
$urpm->{log}("starting installing packages without deps");
@l = $urpm->install($root, \%sources_install, \%sources, nodeps => 1);
if (@l) {
- message(_("Installation failed"));
+ message(_("Installation failed") . ":\n" . join("\n", @l));
message_input(_("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/
or exit 1;
$urpm->{log}("starting force installing packages without deps");
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 3ef542e9..083b34f3 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -40,6 +40,10 @@ and [options] are from
") . _(" -f - force generation of hdlist files.
") . _(" --wget - use wget to retrieve distant files.
") . _(" --curl - use curl to retrieve distant files.
+") . _(" --proxy - use specified HTTP proxy, the port number is assumed
+ to be 1080 by default (format is <proxyhost[:port]>).
+") . _(" --proxy-user - specify user and password to use for proxy
+ authentication (format is <user:password>).
") . _(" --update - create an update medium.
") . _(" --distrib - automatically create all media from an installation medium.
");
@@ -56,6 +60,18 @@ and [options] are from
else { $options = { dir => $options, prefer => 'wget' } }
urpm::sync_webfetch($options, @_) }, next;
/^--curl/ and $urpm->{sync} = \&urpm::sync_webfetch, next;
+ /^--proxy$/ and do {
+ ($_ = shift @_) =~ m,^http://([^:]+)(:([\d]+)|[^:])$, or die $usage;
+ $_ .= ":1080" if /[^\d]/;
+ $urpm->{proxy}->{http_proxy} = $_;
+ next;
+ };
+ /^--proxy-user$/ and do {
+ ($_ = shift @_) =~ /(.+):(.+)/, or die $usage;
+ $urpm->{proxy}->{user} = $1;
+ $urpm->{proxy}->{pwd} = $2;
+ next;
+ };
/^--distrib$/ and $options{distrib} = 1, next;
/^--update$/ and $options{update} = 1, next;
/^-/ and die $usage . _("\nunknown options '%s'\n", $_);
diff --git a/urpmi.spec b/urpmi.spec
index 0f3a9d06..844e4b47 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 3.7
-Release: 2mdk
+Release: 3mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
@@ -144,6 +144,11 @@ fi
%changelog
+* Thu Jul 11 2002 François Pons <fpons@mandrakesoft.com> 3.7-3mdk
+- incorporated proxy patch of Andre Duclos <shirka@wanadoo.fr>.
+- added tempory error message (before message and translation are
+ done).
+
* Tue Jul 9 2002 Pixel <pixel@mandrakesoft.com> 3.7-2mdk
- rebuild for perl 5.8.0
diff --git a/urpmi.update b/urpmi.update
index 1454d16a..7560bd9c 100755
--- a/urpmi.update
+++ b/urpmi.update
@@ -40,6 +40,18 @@ sub main {
else { $options = { dir => $options, prefer => 'wget' } }
urpm::sync_webfetch($options, @_) }, next;
/^--curl/ and $urpm->{sync} = \&urpm::sync_webfetch, next;
+ /^--proxy$/ and do {
+ ($_ = shift @_) =~ m,^http://([^:]+)(:([\d]+)|[^:])$, or die $usage;
+ $_ .= ":1080" if /[^\d]/;
+ $urpm->{proxy}->{http_proxy} = $_;
+ next;
+ };
+ /^--proxy-user$/ and do {
+ ($_ = shift @_) =~ /(.+):(.+)/, or die $usage;
+ $urpm->{proxy}->{user} = $1;
+ $urpm->{proxy}->{pwd} = $2;
+ next;
+ };
/^--?noa/ and next; #- default, keeped for compability.
/^-/ and die _("usage: urpmi.update [options] <name> ...
where <name> is a medium name to update.
@@ -49,6 +61,10 @@ where <name> is a medium name to update.
") . _(" -f - force generation of hdlist files.
") . _(" --wget - use wget to retrieve distant files.
") . _(" --curl - use curl to retrieve distant files.
+") . _(" --proxy - use specified HTTP proxy, the port number is assumed
+ to be 1080 by default (format is <proxyhost[:port]>).
+") . _(" --proxy-user - specify user and password to use for proxy
+ authentication (format is <user:password>).
") . _("\nunknown options '%s'\n", $_);
push @toupdates, $_;
}
diff --git a/urpmq b/urpmq
index 35f7b095..900980d4 100755
--- a/urpmq
+++ b/urpmq
@@ -58,6 +58,12 @@ usage:
stdout (root only).
") . _(" --sources - give all source packages before downloading (root only).
") . _(" --force - force invocation even if some packages do not exist.
+") . _(" --wget - use wget to retrieve distant files.
+") . _(" --curl - use curl to retrieve distant files.
+") . _(" --proxy - use specified HTTP proxy, the port number is assumed
+ to be 1080 by default (format is <proxyhost[:port]>).
+") . _(" --proxy-user - specify user and password to use for proxy
+ authentication (format is <user:password>).
") . "\n" . _(" names or rpm files given on command line are queried.
", $urpm::VERSION);
exit(0);
@@ -86,6 +92,18 @@ for (@ARGV) {
else { $options = { dir => $options, prefer => 'wget' } }
urpm::sync_webfetch($options, @_) }; next };
/^--curl$/ and do { $urpm->{sync} = \&urpm::sync_webfetch; next };
+ /^--proxy$/ and do {
+ ($_ = shift @_) =~ m,^http://([^:]+)(:([\d]+)|[^:])$, or usage;
+ $_ .= ":1080" if /[^\d]/;
+ $urpm->{proxy}->{http_proxy} = $_;
+ next;
+ };
+ /^--proxy-user$/ and do {
+ ($_ = shift @_) =~ /(.+):(.+)/, or usage;
+ $urpm->{proxy}->{user} = $1;
+ $urpm->{proxy}->{pwd} = $2;
+ next;
+ };
/^-(.*)$/ and do { foreach (split //, $1) {
/[\?h]/ and do { usage; next };
/d/ and do { $query->{deps} = 1; next };