#!/usr/bin/perl

@ARGV and die "usage: rpm-find-leaves\n";

use URPM;
my @packages;
{
    my $db = URPM::DB::open or die;
    $db->traverse(sub {
	my ($p) = @_;
	$p->pack_header;
	push @packages, $p;
    });
}

foreach my $pkg (@packages) {
    $l{$pkg->name} = 1;
    push @{$provides{$_}}, $pkg->name foreach $pkg->provides_nosense;
}

foreach my $pkg (@packages) {
    delete @l{grep { $_ ne $pkg->name } @{$provides{$_} || []}} foreach $pkg->requires_nosense;
}

print "$_\n" foreach sort keys %l;