From e01b90507760a7795601e4326f95d4a7c844821b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 18 Jun 2009 21:28:27 +0200 Subject: apt-why: Added --deptype to filter packages by dependency type --- bin/apt-why | 12 +++++++++--- 1 file 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}); -- cgit v1.2.3