summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-17 14:08:50 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-17 14:08:50 +0000
commit9cdd5aefa0e68a0ef1bf8c9810c09549d6faa0be (patch)
treebfb1b84df31be626810c94b2cef5f5d8f79412b6 /usr.sbin
parentfa96d2ce39bd41cf5a64eab209a9f7197d8a57ba (diff)
access solver internals in a clean way through dependencies, uses it
internally. store solver objects along with solved_dependencies. Eventually, all solved_dependencies requests will use solver objects instead.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm16
-rw-r--r--usr.sbin/pkg_add/pkg_add3
2 files changed, 15 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 7e50a4b27fe..bce3d732d73 100644
--- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Dependencies.pm,v 1.32 2007/05/17 13:58:44 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.33 2007/05/17 14:08:49 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -39,6 +39,16 @@ sub new
bless {plist => $plist, to_install => {}, deplist => [], to_register => {} }, $class;
}
+sub dependencies
+{
+ my $self = shift;
+ if (wantarray) {
+ return keys %{$self->{to_register}};
+ } else {
+ return scalar(%{$self->{to_register}});
+ }
+}
+
sub pkgname
{
my $self = shift;
@@ -140,9 +150,9 @@ sub solve
sub dump
{
my $self = shift;
- if (%{$self->{to_register}}) {
+ if ($self->dependencies) {
print "Dependencies for ", $self->pkgname, " resolve to: ",
- join(', ', keys %{$self->{to_register}});
+ join(', ', $self->dependencies);
print " (todo: ", join(',', @{$self->{deplist}}), ")"
if @{$self->{deplist}} > 0;
print "\n";
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 65f3b54ba5b..fcb27b11d91 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.248 2007/05/17 13:36:21 espie Exp $
+# $OpenBSD: pkg_add,v 1.249 2007/05/17 14:08:49 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -532,6 +532,7 @@ sub install_package
if (!defined $handle->{solved_dependencies}) {
my $solver = OpenBSD::Dependencies::Solver->new($handle->{plist});
my @deps = $solver->solve($state, @todo);
+ $handle->{solver} = $solver;
$handle->{solved_dependencies} = $solver->{to_register};
if ($state->{verbose}) {
$solver->dump;