summaryrefslogtreecommitdiffstats
path: root/rpm-find-leaves
blob: f94190c59fbbe061280eb023585b22cb9b3cb13b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl

local $_ = join '', @ARGV;

/-h/ and die "usage: rpm-find-leaves [--show-unknown]\n";

$show_unknown = /-show-unknown/;

$r = join '|', map { chop; $l{$_} = 1; quotemeta } `rpm -qa --queryformat "%{NAME}\n"`;
$R = qr/ ($r)-\d/;
$R2 = qr/$r /;
open F, "/var/lib/urpmi/depslist" or die "can't find depslist\n";
F: foreach (<F>) {
    my ($p) = /(\S+)-[^-]+-[^-]+ /;
    $p =~ $R2 or next; # not installed
    $L{$p} = 1;
    delete $l{$1} while /$R/g;
}
$show_unknown || $L{$_} and print "$_\n" foreach keys %l;