summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2005-08-17 18:24:54 +0000
committerMarc Espie <espie@cvs.openbsd.org>2005-08-17 18:24:54 +0000
commite873d1e448c09a2784816d83d6399147840e0473 (patch)
tree11551fdb9cf591c6fab06789053f786f6d419e12 /usr.sbin/pkg_add/OpenBSD
parent75a12dbbd37fbb2a0efa09c978987d2f02f9da45 (diff)
clean-up, move the compute_closure code to RequiredBy, since it's
quite generic.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/RequiredBy.pm20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
index cb915e9ac4d..143e0eb9a95 100644
--- a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
+++ b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: RequiredBy.pm,v 1.10 2005/08/17 09:19:09 espie Exp $
+# $OpenBSD: RequiredBy.pm,v 1.11 2005/08/17 18:24:53 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -130,6 +130,24 @@ sub forget
}
}
+sub compute_closure
+{
+ my ($class, @seed) = @_;
+
+ my @todo = @seed;
+ my %done = ();
+
+ while (my $pkgname = pop @todo) {
+ next if $done{$pkgname};
+ $done{$pkgname} = 1;
+ for my $dep ($class->new($pkgname)->list()) {
+ next if defined $done{$dep};
+ push(@todo, $dep);
+ }
+ }
+ return keys %done;
+}
+
package OpenBSD::RequiredBy;
our @ISA=qw(OpenBSD::RequirementList);
use OpenBSD::PackageInfo;