diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-03-31 14:44:41 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-03-31 14:44:41 +0000 |
commit | 60002eef0eb1e4002135b6bf16c67d692c8dd746 (patch) | |
tree | 7048c08b4cc4dc00ab2225fe258b574bc5a53c97 /rpme | |
parent | 64f720ff50491bf8eff620a154d5318ab34912d9 (diff) | |
download | urpmi-60002eef0eb1e4002135b6bf16c67d692c8dd746.tar urpmi-60002eef0eb1e4002135b6bf16c67d692c8dd746.tar.gz urpmi-60002eef0eb1e4002135b6bf16c67d692c8dd746.tar.bz2 urpmi-60002eef0eb1e4002135b6bf16c67d692c8dd746.tar.xz urpmi-60002eef0eb1e4002135b6bf16c67d692c8dd746.zip |
no_comment
Diffstat (limited to 'rpme')
-rw-r--r-- | rpme | 68 |
1 files changed, 0 insertions, 68 deletions
@@ -1,68 +0,0 @@ -#!/usr/bin/perl - -local $_ = join '', @ARGV; - -/-h/ || @ARGV == 0 and die "usage: rpme [-a] [--auto] <packages...>\n"; - -$matches = /-a/; -$auto = /-auto/; - -my $DIR = "/var/lib/urpmi"; - -@l = grep { !/^-/ } @ARGV; -if (!$matches) { - @m = map { chop; $_ } `rpm -q @l 2>&1`; - if ($?) { - $maymatch = "unknown package(s) " . join(", ", map { /package (\S+) is not installed/ ? $1 : () } @m) . "\n"; - $auto || @l > 1 and die $maymatch; - } -} -if ($matches || $maymatch) { - my $match = join "|", @l; - @m = grep { /$match/ } map { chop; $_ } `rpm -qa`; - - if ($maymatch) { - @m or die $maymatch; - print "Using $match as a substring, I found:\n@m\nRemove them all? (y/N) "; - <STDIN> =~ /y/i or exit 1; - } -} - -load_provides(); -my %toremove; @toremove{$_, @{$provides{$_} || []}} = () foreach @m; -my $changed = 1; while ($changed) { $changed = 0; - local *F; - open F, "rpm -e --test " . join(" ", keys %toremove) . " 2>&1 |"; - foreach (<F>) { - if (/package (\S+) is not installed/) { - delete $toremove{$1}; - } elsif (/is needed by (\S+)/ && ! exists $toremove{$1}) { - $toremove{$1} = 1; - $changed = 1; - } - } -} -my @toremove = keys %toremove or die "nothing to remove\n"; -if (@toremove > @l && !$auto) { - my $sum = 0; map { $sum += $_ } `rpm -q --queryformat "%{SIZE}\n" @toremove`; - print "To satisfy dependencies, the following packages are going to be removed"; - printf " (%d MB)", toMb($sum); - print ":\n@toremove\nIs it ok? (Y/n) "; - <STDIN> =~ /n/i and exit 0; -} -system("rpm", "-e", @toremove); - - -sub load_provides { - local *F; - open F, "$DIR/depslist" or return; - foreach (<F>) { - my ($p, $size, @l) = split; - $size{$p} = $size; - push @{$provides{$_}}, $p foreach @l; - } -} -sub toMb { - my $nb = $_[0] / 1024 / 1024; - int $nb + 0.5; -} |