diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-17 13:36:22 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-17 13:36:22 +0000 |
commit | 75d08106f4156346da597ca3c8f04e4f1444cc68 (patch) | |
tree | 730a23d0d3685cff96ae36abe6720db3128a3566 /usr.sbin/pkg_add | |
parent | 55c3d5892e76b52a6f54fad4c7a259ce1c3bb3a0 (diff) |
tweak the solver object a bit, now that I have a clearer idea of what
it's going to be used for.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Dependencies.pm | 23 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 7 |
2 files changed, 17 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm index e5fb18af201..6901ca72f39 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.30 2007/05/14 18:19:25 espie Exp $ +# $OpenBSD: Dependencies.pm,v 1.31 2007/05/17 13:36:21 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org> # @@ -35,8 +35,14 @@ sub find_candidate sub new { - my $class = shift; - bless {to_install => {}, deplist => [], to_register => {} }, $class; + my ($class, $plist) = @_; + bless {plist => $plist, to_install => {}, deplist => [], to_register => {} }, $class; +} + +sub pkgname +{ + my $self = shift; + return $self->{plist}->pkgname; } sub add_todo @@ -108,7 +114,7 @@ sub solve_dependency @candidates = ((grep {$_ eq $dep->{def}} @candidates), (sort (grep {$_ ne $dep->{def}} @candidates))); my $choice = - OpenBSD::Interactive::ask_list('Ambiguous: choose dependency for '.$self->{pkgname}.': ', + OpenBSD::Interactive::ask_list('Ambiguous: choose dependency for '.$self->pkgname.': ', $state->{interactive}, @candidates); $self->add_new_dep($choice); return; @@ -120,17 +126,14 @@ sub solve_dependency sub solve { - my ($self, $state, $handle, @extra) = @_; - my $plist = $handle->{plist}; + my ($self, $state, @extra) = @_; $self->add_todo(@extra); - $self->{pkgname} = $plist->pkgname; - for my $dep (@{$plist->{depend}}) { + for my $dep (@{$self->{plist}->{depend}}) { $self->solve_dependency($state, $dep); } - $handle->{solved_dependencies} = $self->{to_register}; return @{$self->{deplist}}; } @@ -138,7 +141,7 @@ sub dump { my $self = shift; if (%{$self->{to_register}}) { - print "Dependencies for ", $self->{pkgname}, " resolve to: ", + print "Dependencies for ", $self->pkgname, " resolve to: ", join(', ', keys %{$self->{to_register}}); print " (todo: ", join(',', @{$self->{deplist}}), ")" if @{$self->{deplist}} > 0; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index eb7d07f039f..65f3b54ba5b 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.247 2007/05/14 18:19:25 espie Exp $ +# $OpenBSD: pkg_add,v 1.248 2007/05/17 13:36:21 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -530,8 +530,9 @@ sub install_package } } if (!defined $handle->{solved_dependencies}) { - my $solver = OpenBSD::Dependencies::Solver->new; - my @deps = $solver->solve($state, $handle, @todo); + my $solver = OpenBSD::Dependencies::Solver->new($handle->{plist}); + my @deps = $solver->solve($state, @todo); + $handle->{solved_dependencies} = $solver->{to_register}; if ($state->{verbose}) { $solver->dump; } |