diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2009-06-18 21:28:27 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2009-06-18 21:28:27 +0200 |
commit | e01b90507760a7795601e4326f95d4a7c844821b (patch) | |
tree | 2c69f6fcd93c45db4c213a5006d5946456ca1d2e | |
parent | 2587c396df6b5016679a44e7bacf2e238eaf66fa (diff) |
apt-why: Added --deptype to filter packages by dependency type
-rwxr-xr-x | bin/apt-why | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/apt-why b/bin/apt-why index f78d2c4..9af7283 100755 --- a/bin/apt-why +++ b/bin/apt-why @@ -9,12 +9,16 @@ use Getopt::Long; my $cache = AptPkg::Cache->new; my $not = 0; +my @deptypes; GetOptions( - "not" => \$not, + 'not' => \$not, + 'deptype=s' => \@deptypes, ); my $packagename = shift or die("No packagename given"); my @known; +@deptypes = split(/,/, join(',', @deptypes)); + sub revdeps { my $name = shift; my $package = $cache->{$name}; @@ -22,8 +26,10 @@ sub revdeps { my $rdeps = $package->{RevDependsList}; foreach (@$rdeps) { if ( - $cache->{$_->{ParentPkg}{Name}}->{CurrentState} eq 'Installed' - and $_->{DepType} !~ /^(Conflicts|Replaces|Obsoletes)$/ + $cache->{$_->{ParentPkg}{Name}}->{CurrentState} eq 'Installed' and ( + (not @deptypes and $_->{DepType} !~ /^(Conflicts|Replaces|Obsoletes)$/) or + (@deptypes and "$_->{DepType}" ~~ @deptypes) + ) ) { next if ($_->{ParentPkg}{Name} ~~ @known); push(@return, $_->{ParentPkg}{Name}); |