summaryrefslogtreecommitdiffstats
path: root/urpme
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2002-02-21 17:25:49 +0000
committerFrancois Pons <fpons@mandriva.com>2002-02-21 17:25:49 +0000
commitef6c8731743d0180a82448fcf9a4683a2f4deace (patch)
tree31efa5920c4e42be187a607aadf11ed488eb5856 /urpme
parente9f56a7dce168f420edaedd56daf40921b0e8568 (diff)
downloadurpmi-ef6c8731743d0180a82448fcf9a4683a2f4deace.tar
urpmi-ef6c8731743d0180a82448fcf9a4683a2f4deace.tar.gz
urpmi-ef6c8731743d0180a82448fcf9a4683a2f4deace.tar.bz2
urpmi-ef6c8731743d0180a82448fcf9a4683a2f4deace.tar.xz
urpmi-ef6c8731743d0180a82448fcf9a4683a2f4deace.zip
3.3-14mdk
Diffstat (limited to 'urpme')
-rw-r--r--urpme56
1 files changed, 34 insertions, 22 deletions
diff --git a/urpme b/urpme
index 085e2075..20c58a49 100644
--- a/urpme
+++ b/urpme
@@ -20,12 +20,13 @@
use strict;
#use strict qw(subs vars refs);
+use rpmtools;
use urpm;
#- get I18N translation method.
import urpm _;
-my ($auto, $matches, $maymatch, %provides, @l, @m, @toremove);
+my ($auto, $matches, $maymatch, @l, @m, @toremove);
my $askok = _("Is it OK?");
my $askrm = _("Remove them all?");
# Translator: Add here the keys which might be pressed in the "No"-case.
@@ -43,8 +44,6 @@ if ( / --?h/ || @ARGV == 0 ) {
$matches = / -a /;
$auto = / --?auto /;
-my $DIR = "/var/lib/urpmi";
-
@l = grep { !/^-/ } @ARGV;
if (!$matches) {
@m = map { chop; $_ } `rpm -q @l 2>&1`;
@@ -65,10 +64,7 @@ if ($matches || $maymatch) {
}
}
-load_provides();
-my %toremove;
-@toremove{$_, @{$provides{$_} || []}} = () foreach @m;
-
+my %toremove; @toremove{@m} = ();
my $changed = 1;
while ($changed) {
$changed = 0;
@@ -87,6 +83,37 @@ if ( ! (@toremove = keys %toremove) ) {
print _("Nothing to remove.\n");
exit(0);
}
+
+#- check if a package to be removed is a part of basesystem requires.
+my %base;
+my @base = qw(basesystem);
+my %basepackages;
+my $db = rpmtools::db_open('');
+while (defined($_ = shift @base)) {
+ exists $basepackages{$_} and next;
+ rpmtools::db_traverse_tag($db, /^\// ? 'path' : 'whatprovides', [ $_ ], [ qw(name version release requires) ], sub {
+ my ($p) = @_;
+ push @{$basepackages{$_} ||= []}, "$p->{name}-$p->{version}-$p->{release}";
+ push @base, @{$p->{requires} || []};
+ });
+}
+rpmtools::db_close($db);
+foreach (values %basepackages) {
+ my $n = @$_;
+ foreach (@$_) {
+ $base{$_} = \$n;
+ }
+}
+my $base_str = '';
+foreach (@toremove) {
+ my $rn = $base{$_};
+ if ($rn) {
+ $$rn == 1 and $base_str .= _("removing package %s will break your system\n", $_);
+ --$$rn;
+ }
+}
+$base_str and die $base_str;
+
if (@toremove > @l && !$auto) {
my $sum = 0;
map { $sum += $_ } `rpm -q --queryformat "%{SIZE}\n" @toremove`;
@@ -97,21 +124,6 @@ if (@toremove > @l && !$auto) {
system("rpm", "-e", @toremove);
-sub load_provides {
- local *F;
- open F, "$DIR/depslist.ordered" or return;
- my @packages_id;
- my %provides_id;
- foreach (<F>) {
- my ($p, $size, @l) = split;
- #$size{$p} = $size;
- push @packages_id, $p;
- push @{$provides_id{$_}}, $p foreach @l;
- }
- foreach (keys %provides_id) {
- $provides{$packages_id[$_]} = $provides_id{$_};
- }
-}
sub toMb {
my $nb = $_[0] / 1024 / 1024;
int $nb + 0.5;