summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2004-01-13 01:00:14 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2004-01-13 01:00:14 +0000
commit4e17a6dee03f78e739cdf85d482dd1a2677d54cc (patch)
tree2a88aa22737f21d96db78d9db9de65a90fe059d4
parentc80509f5785b7f53c18f3b823648f96ced2c7b24 (diff)
downloadurpmi-4e17a6dee03f78e739cdf85d482dd1a2677d54cc.tar
urpmi-4e17a6dee03f78e739cdf85d482dd1a2677d54cc.tar.gz
urpmi-4e17a6dee03f78e739cdf85d482dd1a2677d54cc.tar.bz2
urpmi-4e17a6dee03f78e739cdf85d482dd1a2677d54cc.tar.xz
urpmi-4e17a6dee03f78e739cdf85d482dd1a2677d54cc.zip
- fix urpmq for virtual medium
- apply blino's patch: - permit urpmq -i for user - fix urpmq --sources for user (don't give a wrong url) - fix urpme --root
-rw-r--r--urpm.pm12
-rw-r--r--urpme2
-rwxr-xr-xurpmq46
3 files changed, 41 insertions, 19 deletions
diff --git a/urpm.pm b/urpm.pm
index bc0ce9ca..8c3e9dca 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -1770,7 +1770,6 @@ this could happen if you mounted manually the directory when creating the medium
$urpm->{error}(N("no hdlist file found for medium \"%s\"", $medium->{name}));
}
- #- make sure group and other does not have any access to this file.
unless ($error || $medium->{virtual}) {
#- sort list file contents according to id.
my %list;
@@ -1852,6 +1851,7 @@ this could happen if you mounted manually the directory when creating the medium
if (%list) {
#- write list file.
local *LIST;
+ #- make sure group and other do not have any access to this file, used to hide passwords.
my $mask = umask 077;
open LIST, ">$urpm->{cachedir}/partial/$medium->{list}"
or $error = 1, $urpm->{error}(N("unable to write list file of \"%s\"", $medium->{name}));
@@ -2532,7 +2532,7 @@ sub get_unwanted_packages {
#- have a null list.
sub get_source_packages {
my ($urpm, $packages, %options) = @_;
- my ($id, $error, %protected_files, %local_sources, @list, %fullname2id, %file2fullnames, %examined);
+ my ($id, $error, @list_error, %protected_files, %local_sources, @list, %fullname2id, %file2fullnames, %examined);
local (*D, *F, $_);
#- build association hash to retrieve id and examine all list files.
@@ -2618,6 +2618,11 @@ sub get_source_packages {
}
}
close F;
+ } elsif (-e $file) {
+ # list file exists but isn't readable
+ # report error only if no result found, list files are only readable by root
+ push @list_error, N("unable to access list file of \"%s\", medium ignored", $medium->{name});
+ next;
}
if (defined $medium->{url}) {
foreach ($medium->{start} .. $medium->{end}) {
@@ -2647,6 +2652,9 @@ sub get_source_packages {
#- examine package list to see if a package has not been found.
foreach (grep { ! exists($examined{$_}) } keys %fullname2id) {
+ # print list errors only once if any
+ @list_error and map { $urpm->{error}($_) } @list_error;
+ @list_error = ();
$error = 1;
$urpm->{error}(N("package %s is not found.", $_));
}
diff --git a/urpme b/urpme
index 97bc4da3..70e03b24 100644
--- a/urpme
+++ b/urpme
@@ -74,7 +74,7 @@ my $state = {};
$verbose or $urpm->{log} = sub {};
#- just configure parallel mode if available.
-$parallel and $urpm->configure(synthesis => 'none',
+$parallel and $urpm->configure(synthesis => ($parallel and 'none'),
root => $root,
parallel => $parallel,
);
diff --git a/urpmq b/urpmq
index 17f651e1..a2a870fd 100755
--- a/urpmq
+++ b/urpmq
@@ -20,6 +20,8 @@
use strict;
use urpm;
+use IO::File;
+use POSIX qw(tmpnam);
#- default options.
my $query = { use_provides => 1, };
@@ -354,7 +356,10 @@ if ($query->{list_aliases}) {
if (-s "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}") {
require packdrake;
- my $packer = new packdrake("$urpm->{statedir}/$urpm->{media}[$_]{hdlist}");
+ my $packer = new packdrake(
+ $urpm->{media}[$_]{virtual} ?
+ ( "$urpm->{media}[$_]{url}/$urpm->{media}[$_]{with_hdlist}" =~ m!^file:/*(/.*)! )[0] :
+ "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}");
$packer->extract_archive(undef, @headers);
} else {
#- fallback to retrieve rpm package before, so that --headers will be ok.
@@ -364,20 +369,23 @@ if ($query->{list_aliases}) {
}
} elsif ($query->{info}) {
my %downloads;
- unless ($>) {
- foreach (0..$#{$urpm->{media} || []}) {
- if (my @headers = (grep { my $file = "$urpm->{cachedir}/headers/$_"; ! -s $file }
- map { my $pkg = $urpm->{depslist}[$_];
- $pkg && $pkg->header_filename } keys %{$list->[$_]})) {
- #map { /(.*)\/([^\/]*)-([^-]*)-([^-]*)\.([^\.]*)\.rpm/ and "$2-$3-$4.$5" } values %{$list->[$_]})) {
- if ($< == 0 && -s "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}") {
- require packdrake;
- my $packer = new packdrake("$urpm->{statedir}/$urpm->{media}[$_]{hdlist}");
- $packer->extract_archive("$urpm->{cachedir}/headers", @headers);
- } elsif (!%downloads) {
- #- fallback to retrieve rpm package before, so that --headers will be ok.
- %downloads = $urpm->download_source_packages({}, $list, force_local => 1);
- }
+ # if not root, use a temporary file to store headers
+ my $tmp_header_dir = ($< != 0 and tmpnam());
+ foreach (0..$#{$urpm->{media} || []}) {
+ if (my @headers = (grep { my $file = "$urpm->{cachedir}/headers/$_"; ! -s $file }
+ map { my $pkg = $urpm->{depslist}[$_];
+ $pkg && $pkg->header_filename } keys %{$list->[$_]})) {
+ #map { /(.*)\/([^\/]*)-([^-]*)-([^-]*)\.([^\.]*)\.rpm/ and "$2-$3-$4.$5" } values %{$list->[$_]})) {
+ if (-s "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}") {
+ require packdrake;
+ my $packer = new packdrake(
+ $urpm->{media}[$_]{virtual} ?
+ ( "$urpm->{media}[$_]{url}/$urpm->{media}[$_]{with_hdlist}" =~ m!^file:/*(/.*)! )[0] :
+ "$urpm->{statedir}/$urpm->{media}[$_]{hdlist}");
+ $packer->extract_archive($< == 0 ? "$urpm->{cachedir}/headers" : $tmp_header_dir, @headers);
+ } elsif (!%downloads) {
+ #- fallback to retrieve rpm package before, so that --headers will be ok.
+ %downloads = $urpm->download_source_packages({}, $list, force_local => 1);
}
}
}
@@ -385,7 +393,12 @@ if ($query->{list_aliases}) {
foreach (split /\|/, $_) {
my $pkg = $urpm->{depslist}[$_] or next;
my $file = $local_sources->{$_} || $downloads{$_} || "$urpm->{cachedir}/headers/".$pkg->header_filename;
- $pkg->update_header($file, keep_all_tags => 1);
+ if (-s $file) {
+ $pkg->update_header($file, keep_all_tags => 1);
+ } elsif ($< != 0) {
+ $pkg->update_header("$tmp_header_dir/".$pkg->header_filename, keep_all_tags => 1);
+ unlink "$tmp_header_dir/".$pkg->header_filename;
+ }
printf "%-12s: %s\n", "Name", $pkg->name;
printf "%-12s: %s\n", "Version", $pkg->version;
printf "%-12s: %s\n", "Release", $pkg->release;
@@ -406,6 +419,7 @@ if ($query->{list_aliases}) {
$pkg->description and printf "%-12s:\n%s\n", "Description", $pkg->description;
}
}
+ -d $tmp_header_dir and rmdir $tmp_header_dir;
} elsif ($query->{sources}) {
print join "\n", values %$local_sources; values %$local_sources and print "\n";
foreach (0..$#{$urpm->{media} || []}) {