summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-10 09:19:22 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-10 09:19:22 +0000
commitb306c1a29317c0f0af8d07d2b9026959c339d033 (patch)
tree2c72fea4d685fd51000e5f19c51cf991aa8be47e
parent5b6ff038ec8e4bdc82ed221f02a57e6a7ebc4a5f (diff)
downloadurpmi-b306c1a29317c0f0af8d07d2b9026959c339d033.tar
urpmi-b306c1a29317c0f0af8d07d2b9026959c339d033.tar.gz
urpmi-b306c1a29317c0f0af8d07d2b9026959c339d033.tar.bz2
urpmi-b306c1a29317c0f0af8d07d2b9026959c339d033.tar.xz
urpmi-b306c1a29317c0f0af8d07d2b9026959c339d033.zip
- adapt ->translate_why_unselected to do what each callers do: sort its args and return a single string
- create translate_why_unselected_one to make function smaller
-rwxr-xr-xgurpmi22
-rw-r--r--urpm.pm42
-rwxr-xr-xurpmi2
3 files changed, 25 insertions, 21 deletions
diff --git a/gurpmi2 b/gurpmi2
index 947c1c73..21a30ce3 100755
--- a/gurpmi2
+++ b/gurpmi2
@@ -79,7 +79,7 @@ my @ask_unselect = $urpm->unselected_packages($state);
@ask_unselect
? ask_continue(N(
"Some requested packages cannot be installed:\n%s\nContinue installation anyway?",
- join "\n", $urpm->translate_why_unselected($state, sort @ask_unselect)
+ $urpm->translate_why_unselected($state, @ask_unselect)
), \&do_install)
: do_install();
diff --git a/urpm.pm b/urpm.pm
index 0ad56704..7d0570ae 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -3264,25 +3264,29 @@ sub unselected_packages {
sub uniq { my %l; $l{$_} = 1 foreach @_; grep { delete $l{$_} } @_ }
sub translate_why_unselected {
- my ($urpm, $state, @l) = @_;
-
- map {
- my $rb = $state->{rejected}{$_}{backtrack};
- my @froms = keys %{$rb->{closure} || {}};
- my @unsatisfied = @{$rb->{unsatisfied} || []};
- my $s = join ", ", (
- (map { N("due to missing %s", $_) } @froms),
- (map { N("due to unsatisfied %s", $_) } uniq(map {
- #- XXX in theory we shouldn't need this, dependencies (and not ids) should
- #- already be present in @unsatisfied. But with biarch packages this is
- #- not always the case.
- /\D/ ? $_ : scalar($urpm->{depslist}[$_]->fullname);
- } @unsatisfied)),
- $rb->{promote} && !$rb->{keep} ? N("trying to promote %s", join(", ", @{$rb->{promote}})) : @{[]},
- $rb->{keep} ? N("in order to keep %s", join(", ", @{$rb->{keep}})) : @{[]},
- );
- $_ . ($s ? " ($s)" : '');
- } @l;
+ my ($urpm, $state, @fullnames) = @_;
+
+ join("\n", map { translate_why_unselected_one($urpm, $state, $_) } sort @fullnames);
+}
+
+sub translate_why_unselected_one {
+ my ($urpm, $state, $fullname) = @_;
+
+ my $rb = $state->{rejected}{$fullname}{backtrack};
+ my @froms = keys %{$rb->{closure} || {}};
+ my @unsatisfied = @{$rb->{unsatisfied} || []};
+ my $s = join ", ", (
+ (map { N("due to missing %s", $_) } @froms),
+ (map { N("due to unsatisfied %s", $_) } uniq(map {
+ #- XXX in theory we shouldn't need this, dependencies (and not ids) should
+ #- already be present in @unsatisfied. But with biarch packages this is
+ #- not always the case.
+ /\D/ ? $_ : scalar($urpm->{depslist}[$_]->fullname);
+ } @unsatisfied)),
+ $rb->{promote} && !$rb->{keep} ? N("trying to promote %s", join(", ", @{$rb->{promote}})) : (),
+ $rb->{keep} ? N("in order to keep %s", join(", ", @{$rb->{keep}})) : (),
+ );
+ $fullname . ($s ? " ($s)" : '');
}
sub removed_packages {
diff --git a/urpmi b/urpmi
index 98078b17..1dca3df5 100755
--- a/urpmi
+++ b/urpmi
@@ -499,7 +499,7 @@ that are older than the installed ones:\n%s", $list);
my @ask_unselect = $urpm->unselected_packages($state);
if (@ask_unselect) {
- my $list = join "\n", $urpm->translate_why_unselected($state, sort @ask_unselect);
+ my $list = $urpm->translate_why_unselected($state, @ask_unselect);
my $msg = N("Some requested packages cannot be installed:\n%s", $list);
if ($urpm->{options}{auto}) {
print "$msg\n";