diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-08-17 18:24:54 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-08-17 18:24:54 +0000 |
commit | e873d1e448c09a2784816d83d6399147840e0473 (patch) | |
tree | 11551fdb9cf591c6fab06789053f786f6d419e12 | |
parent | 75a12dbbd37fbb2a0efa09c978987d2f02f9da45 (diff) |
clean-up, move the compute_closure code to RequiredBy, since it's
quite generic.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/RequiredBy.pm | 20 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 28 |
2 files changed, 23 insertions, 25 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; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 75947003eee..69383b88351 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.191 2005/08/17 11:01:07 espie Exp $ +# $OpenBSD: pkg_add,v 1.192 2005/08/17 18:24:52 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -555,28 +555,6 @@ sub install_package return (); } -sub compute_closure -{ - require OpenBSD::RequiredBy; - - my $old = shift; - my @todo; - my %done; - my %toupdate = map {($_, 1)} @$old; - push(@todo, keys %toupdate); - while (my $pkgname = pop @todo) { - next if $done{$pkgname}; - $done{$pkgname} = 1; - for my $dep (OpenBSD::Requiring->new($pkgname)->list()) { - next if defined $done{$dep}; - next if defined $toupdate{$dep}; - $toupdate{$dep} = 1; - push(@todo, $dep); - } - } - return keys %toupdate; -} - sub find_updates { my ($old, $new, $state) = @_; @@ -596,7 +574,9 @@ sub find_updates } } unless (defined $state->{full_update} or defined $state->{forced}->{noclosure}) { - @list = compute_closure(\@list); + require OpenBSD::RequiredBy; + + @list = OpenBSD::Requiring->compute_closure(@list); } my @cantupdate = (); my $hash = OpenBSD::PackageName::compile_stemlist(OpenBSD::PackageLocator::distant_available()); |