summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-07-03 11:51:44 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-07-03 11:51:44 +0000
commit793a6259f679ac5f9c123ca9a6827d5ac4250361 (patch)
treebae5bf9f3770b1b567b47d814f5765389b2c6521 /urpm
parentfa8db01a32789f65bfadc99d716dae0ed7f164d5 (diff)
downloadurpmi-793a6259f679ac5f9c123ca9a6827d5ac4250361.tar
urpmi-793a6259f679ac5f9c123ca9a6827d5ac4250361.tar.gz
urpmi-793a6259f679ac5f9c123ca9a6827d5ac4250361.tar.bz2
urpmi-793a6259f679ac5f9c123ca9a6827d5ac4250361.tar.xz
urpmi-793a6259f679ac5f9c123ca9a6827d5ac4250361.zip
- rewrite find_removed_from_basesystem()
- enhance find_removed_from_basesystem: do not return "basesystem" and "basesystem-minimal" when "basesystem" is removed only because "basesystem-minimal" is removed - create rejected_closure() and rejected_unsatisfied()
Diffstat (limited to 'urpm')
-rw-r--r--urpm/select.pm44
1 files changed, 29 insertions, 15 deletions
diff --git a/urpm/select.pm b/urpm/select.pm
index 46defeba..6c3f4cb6 100644
--- a/urpm/select.pm
+++ b/urpm/select.pm
@@ -488,26 +488,32 @@ sub find_packages_to_remove {
sub find_removed_from_basesystem {
my ($urpm, $db, $state, $callback_base) = @_;
-
- $callback_base && %{$state->{rejected} || {}} or return 1;
+ $callback_base or return 1;
+
+ if (my @l = _prohibit_packages_that_would_be_removed($urpm, $db, $state)) {
+ $callback_base->($urpm, @l);
+ } else {
+ 1;
+ }
+
+}
+sub _prohibit_packages_that_would_be_removed {
+ my ($urpm, $db, $state) = @_;
+
+ my @to_remove = removed_packages($urpm, $state) or return 1;
- my %basepackages;
my @dont_remove = ('basesystem', 'basesystem-minimal',
split /,\s*/, $urpm->{global_config}{'prohibit-remove'});
- #- check if a package to be removed is a part of basesystem requires.
+ my (@base_fn, %base);
$db->traverse_tag('whatprovides', \@dont_remove, sub {
my ($p) = @_;
- $basepackages{$p->fullname} = 0;
+ $base{$p->name} = 1;
+ push @base_fn, scalar $p->fullname;
});
- foreach (removed_packages($urpm, $state)) {
- exists $basepackages{$_} or next;
- ++$basepackages{$_};
- }
- if (grep { $_ } values %basepackages) {
- return $callback_base->($urpm, grep { $basepackages{$_} } keys %basepackages);
- }
- 1;
+ grep {
+ ! grep { $base{$_} } rejected_unsatisfied($state, $_);
+ } intersection(\@to_remove, \@base_fn);
}
#- misc functions to help finding ask_unselect and ask_remove elements with their reasons translated.
@@ -568,6 +574,15 @@ sub removed_packages {
$state->{rejected}{$_}{removed} && !$state->{rejected}{$_}{obsoleted};
} keys %{$state->{rejected} || {}};
}
+sub rejected_closure {
+ my ($state, $fullname) = @_;
+ $state->{rejected} && $state->{rejected}{$fullname} && $state->{rejected}{$fullname}{closure};
+}
+sub rejected_unsatisfied {
+ my ($state, $fullname) = @_;
+ my $closure = rejected_closure($state, $fullname) or return;
+ map { $_ ? @$_ : () } map { $_->{unsatisfied} } values %$closure;
+}
sub translate_why_removed {
my ($urpm, $state, @fullnames) = @_;
@@ -576,8 +591,7 @@ sub translate_why_removed {
sub translate_why_removed_one {
my ($urpm, $state, $fullname) = @_;
- my $closure = $state->{rejected} && $state->{rejected}{$fullname} && $state->{rejected}{$fullname}{closure}
- or return $fullname;
+ my $closure = rejected_closure($state, $fullname) or return $fullname;
my ($from) = keys %$closure;
my ($whyk) = keys %{$closure->{$from}};