summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-06-02 12:21:15 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-06-02 12:21:15 +0000
commit918e6d8248ee4db4c1f6cfa815dbb844121bbd4c (patch)
tree9fbf9c5b1e7636a6545c9a091976ae1ca069a157 /usr.sbin/pkg_add
parent87d7f68e052ce47136a997db0b6ee7d7eb55aa1b (diff)
slight refactor, move wantlib dependencies handling inside the solver.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm26
-rw-r--r--usr.sbin/pkg_add/pkg_add19
2 files changed, 27 insertions, 18 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 0a29aa02b5b..ea81feb1756 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.47 2007/06/02 11:30:06 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.48 2007/06/02 12:21:14 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -146,7 +146,7 @@ sub solve_dependency
$self->add_new_dep($v, $dep);
}
-sub solve
+sub solve_depends
{
my ($self, $state, @extra) = @_;
@@ -227,8 +227,6 @@ sub adjust_old_dependencies
}
}
-
-
use OpenBSD::SharedLibs;
sub check_lib_spec
@@ -313,4 +311,24 @@ sub lookup_library
return;
}
+
+sub solve_wantlibs
+{
+ my ($solver, $state) = @_;
+ my $okay = 1;
+
+ for my $h ($solver->{set}->newer) {
+ for my $lib (@{$h->{plist}->{wantlib}}) {
+ if (!$solver->lookup_library($state, $lib->{name})) {
+ OpenBSD::Error::Warn "Can't install ",
+ $h->{pkgname}, ": lib not found ",
+ $lib->{name}, "\n";
+ $solver->dump if $okay;
+ $okay = 0;
+ }
+ }
+ }
+ return $okay;
+}
+
1;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 4e1f678e851..1cdef2d9f7f 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.306 2007/06/02 11:24:22 espie Exp $
+# $OpenBSD: pkg_add,v 1.307 2007/06/02 12:21:14 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -486,11 +486,10 @@ sub install_package
}
}
if (!defined $set->{solver}) {
- my $solver = OpenBSD::Dependencies::Solver->new($set);
- my @deps = $solver->solve($state, @todo);
- $set->{solver} = $solver;
+ $set->{solver} = OpenBSD::Dependencies::Solver->new($set);
+ my @deps = $set->{solver}->solve_depends($state, @todo);
if ($state->{verbose}) {
- $solver->dump;
+ $set->{solver}->dump;
}
if (@deps > 0) {
$state->build_deptree($pkg, @deps);
@@ -508,16 +507,8 @@ sub install_package
return ();
}
- my $okay = 1;
- for my $lib (@{$plist->{wantlib}}) {
- if (!$set->{solver}->lookup_library($state, $lib->{name})) {
- Warn "Can't install $pkg: lib not found ", $lib->{name}, "\n";
- $set->{solver}->dump if $okay;
- $okay = 0;
- }
- }
# print "Didn't need to process: ", join(',', @{$set->{solver}->{todo}}), "\n";
- if (!$okay) {
+ if (!$set->{solver}->solve_wantlibs($state)) {
$location->close_now;
if (!$forced{libdepends}) {
$bad++;