diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-02-02 08:53:51 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-02-02 08:53:51 +0000 |
commit | 1c5b14dd6547cebb52ad5c74b3ca91dd9310f81e (patch) | |
tree | 12569b6c5f8a54540554ba94e1093f9f63bbb0e3 | |
parent | 156d4977f20acc229436679eb0f1204ac2fc9c7d (diff) | |
download | urpmi-1c5b14dd6547cebb52ad5c74b3ca91dd9310f81e.tar urpmi-1c5b14dd6547cebb52ad5c74b3ca91dd9310f81e.tar.gz urpmi-1c5b14dd6547cebb52ad5c74b3ca91dd9310f81e.tar.bz2 urpmi-1c5b14dd6547cebb52ad5c74b3ca91dd9310f81e.tar.xz urpmi-1c5b14dd6547cebb52ad5c74b3ca91dd9310f81e.zip |
Make rpm-find-leaves strict-compliant (Michael Scherer);
remove main() and reindent.
-rw-r--r-- | rpm-find-leaves | 95 |
1 files changed, 46 insertions, 49 deletions
diff --git a/rpm-find-leaves b/rpm-find-leaves index 58787184..6d32dfe2 100644 --- a/rpm-find-leaves +++ b/rpm-find-leaves @@ -1,15 +1,16 @@ #!/usr/bin/perl + +use strict; + use urpm; use urpm::msg; -sub main { - - my %options; - $options{restrict_group} = 0; - $options{group} = 'System/Libraries'; - $options{root} = ''; - - my $usage = N("usage: %s [options] +my %options; +$options{restrict_group} = 0; +$options{group} = 'System/Libraries'; +$options{root} = ''; + +my $usage = N("usage: %s [options] where [options] are from ", $0) . N(" -h|--help - print this help message. ") . N(" --root <path> - use the given root instead of / @@ -17,46 +18,42 @@ where [options] are from ") . N(" defaults is %s. ", $options{group}); - my $group; - - while ($_ = shift @_) { - /^--root$/ and do { - $root=shift @_; - $root and $options{root}=$root; - next; - - }; - /^-g$/ and do { - $options{restrict_group}=1; - $group=shift @_; - $group and $options{group}=$group; - next; - }; - die $usage; - } - - - my @packages; - { - my $db = URPM::DB::open($options{root}) 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; - } - - print "$_\n" foreach sort keys %l; +while ($_ = shift) { + /^--root$/ and do { + my $root = shift; + $root and $options{root} = $root; + next; + + }; + /^-g$/ and do { + $options{restrict_group} = 1; + my $group = shift; + $group and $options{group} = $group; + next; + }; + print $usage; exit 0; +} + +my @packages; +{ + my $db = URPM::DB::open($options{root}) or die "Can't open RPM db\n"; + $db->traverse(sub { + my ($p) = @_; + $p->pack_header; + push @packages, $p; + }); +} + +my %l; +my %provides; +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; } -main(@ARGV); +print "$_\n" foreach sort keys %l; |