summaryrefslogtreecommitdiffstats
path: root/rpm-find-leaves
blob: 781422b71607bf930c4312e5b3f96da470ce799d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

use lib "../rpmtools";

local $_ = join '', @ARGV;

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

$show_unknown = /-show-unknown/;

use rpmtools;

$f = "/var/lib/urpmi/depslist.ordered";
open F, $f or die "read_depslist: can't open file $f\n";
$o = new rpmtools;
$o->read_depslist(\*F);

chop, $l{$_} = 1 foreach `rpm -qa --queryformat "%{name}\n"`;

%m = %l;

foreach (@{$o->{depslist}}) {    
    delete $m{$_->{name}} or next;
    delete $l{$o->{depslist}[$_]{name}} foreach split ' ', $_->{deps};
}

!$m{$_} and print "$_\n" foreach sort keys %l;

if ($show_unknown) {
    print "\n";
    print "$_\n" foreach sort keys %m;
}