+
+
+sub find_dep($$) {
+ my $pkg = shift;
+ my $name = shift;
+ my $deps = ($pkg->{vdepends} or $pkg->{depends});
+
+ return 0 unless defined $deps;
+ foreach my $dep (@{$deps}) {
+ return 1 if $dep eq $name;
+ return 1 if ($package{$dep} and (find_dep($package{$dep},$name) == 1));
+ }
+ return 0;
+}
+
+sub depends($$) {
+ my $a = shift;
+ my $b = shift;
+ my $ret;
+
+ return 0 if ($a->{submenu} ne $b->{submenu});
+ if (find_dep($a, $b->{name}) == 1) {
+ $ret = 1;
+ } elsif (find_dep($b, $a->{name}) == 1) {
+ $ret = -1;
+ } else {
+ return 0;
+ }
+# print STDERR "depends($a->{name}, $b->{name}) == $ret\n";
+ return $ret;
+}
+