summaryrefslogtreecommitdiff
path: root/bin/apt-why
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-09-20 11:13:38 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-09-20 11:13:38 +0200
commit9ed5424a5563a73700852a290e2b5ebbfb554289 (patch)
tree2f24d0a4210aa94d25662011a4bf06e978161c11 /bin/apt-why
parent9e417157cddb48b7942bb76870858bec477000bb (diff)
Code cleanup
Diffstat (limited to 'bin/apt-why')
-rwxr-xr-xbin/apt-why18
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/apt-why b/bin/apt-why
index f19cc2d..991449c 100755
--- a/bin/apt-why
+++ b/bin/apt-why
@@ -29,7 +29,8 @@ sub revdeps {
my $package = $cache->{$name};
my @return;
my $rdeps = $package->{RevDependsList};
- foreach (@$rdeps) {
+
+ foreach (@{$rdeps}) {
if (
not $_->{ParentPkg}{Name} ~~ @known
and ($all or $cache->{$_->{ParentPkg}{Name}}->{CurrentState} eq 'Installed')
@@ -38,6 +39,7 @@ sub revdeps {
push(@return, $_->{ParentPkg}{Name});
}
}
+
push(@known, @return);
return(@return);
}
@@ -45,13 +47,21 @@ sub revdeps {
sub recurse {
my $name = shift;
my $depth = (shift) + 1;
+
printf("%s%s\n", " " x ($depth-1), $name);
- return if ($depth >= $max_depth);
- recurse($_, $depth) foreach revdeps($name);
+
+ if ($depth >= $max_depth) {
+ return;
+ }
+
+ foreach (revdeps($name)) {
+ recurse($_, $depth);
+ }
+
return;
}
-unless ($cache->{$packagename}) {
+if (not defined $cache->{$packagename}) {
print STDERR "No such package: $packagename\n";
exit(1);
}