summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-07 12:19:05 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-07 12:19:05 +0000
commitebdd94005903d6d9363e31333098c0e909b23edc (patch)
tree2e9cd08cbe355574217e22b19d0035567cf3ba34 /usr.sbin
parentce574503607a9aea8cfcab6ed4b605f71520758d (diff)
refactor: create a solver object to handle state issues in a simpler way.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm10
-rw-r--r--usr.sbin/pkg_add/pkg_add5
2 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 07baf5fd136..78ffbbe5dfc 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.16 2007/05/07 08:18:02 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.17 2007/05/07 12:19:04 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -51,9 +51,15 @@ sub find_candidate
}
}
+sub solver
+{
+ my $class = shift;
+ bless {}, $class;
+}
+
sub solve
{
- my ($state, $handle, @extra) = @_;
+ my ($self, $state, $handle, @extra) = @_;
my $plist = $handle->{plist};
my $verbose = $state->{verbose};
my $to_register = $handle->{solved_dependencies} = {};
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 604e12b2f10..2413116c778 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.233 2007/05/07 08:10:45 espie Exp $
+# $OpenBSD: pkg_add,v 1.234 2007/05/07 12:19:04 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -531,7 +531,8 @@ sub install_package
}
}
if (!defined $handle->{solved_dependencies}) {
- my @deps = OpenBSD::Dependencies::solve($state, $handle, @todo);
+ my $solver = OpenBSD::Dependencies->solver;
+ my @deps = $solver->solve($state, $handle, @todo);
if (@deps > 0) {
build_deptree($state, $pkg, @deps);
return (@deps, $pkg);