summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2004-03-04 11:26:05 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2004-03-04 11:26:05 +0000
commit3fa90d9f76fbfb84f46aa95a234c61bceb08f096 (patch)
tree96036e1c1b2c9eb4d6f4b082758214a2b84ba2bb
parent474fe09748c334921a7acd6729400c714cf98198 (diff)
downloadurpmi-3fa90d9f76fbfb84f46aa95a234c61bceb08f096.tar
urpmi-3fa90d9f76fbfb84f46aa95a234c61bceb08f096.tar.gz
urpmi-3fa90d9f76fbfb84f46aa95a234c61bceb08f096.tar.bz2
urpmi-3fa90d9f76fbfb84f46aa95a234c61bceb08f096.tar.xz
urpmi-3fa90d9f76fbfb84f46aa95a234c61bceb08f096.zip
indetation, P. Terjan patch
-rw-r--r--rpm-find-leaves64
1 files changed, 46 insertions, 18 deletions
diff --git a/rpm-find-leaves b/rpm-find-leaves
index 3ab5a470..46741906 100644
--- a/rpm-find-leaves
+++ b/rpm-find-leaves
@@ -1,25 +1,53 @@
#!/usr/bin/perl
+use urpm;
-@ARGV and die "usage: rpm-find-leaves\n";
+sub main {
+
+ my %options;
+ $options{restrict_group} = 0;
+ $options{group} = 'System/Libraries';
+
+ my $usage = N("usage: %s [options]
+where [options] are from
+", $0) . N(" -h|--help - print this help message.
+") . N(" -g [group] - restrict results to given group.
+") . N(" defaults is %s.
+", $options{group});
-use URPM;
-my @packages;
-{
- my $db = URPM::DB::open or die;
- $db->traverse(sub {
- my ($p) = @_;
- $p->pack_header;
- push @packages, $p;
- });
-}
+ my $group;
+
+ while ($_ = shift @_) {
+ /^-g$/ and do {
+ $options{restrict_group}=1;
+ $group=shift @_;
+ $group and $options{group}=$group;
+ next;
+ };
+ die $usage;
+ }
-foreach my $pkg (@packages) {
- $l{$pkg->name} = 1;
- push @{$provides{$_}}, $pkg->name foreach $pkg->provides_nosense;
-}
+
+ my @packages;
+ {
+ my $db = URPM::DB::open or die;
+ $db->traverse(sub {
+ my ($p) = @_;
+ $p->pack_header;
+ push @packages, $p;
+ });
+ }
+
+ foreach my $pkg (@packages) {
+ next if $options{restrict_group} && $pkg->group !~ /$options{group}/i;
+ $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;
+ }
-foreach my $pkg (@packages) {
- delete @l{grep { $_ ne $pkg->name } @{$provides{$_} || []}} foreach $pkg->requires_nosense;
+ print "$_\n" foreach sort keys %l;
}
-print "$_\n" foreach sort keys %l;
+main(@ARGV);