diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-14 18:19:26 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-14 18:19:26 +0000 |
commit | 4f48903f154249e718e00517236bcf574fa21101 (patch) | |
tree | fcecf7d4cee582e8600eeb942f8d5fef82699542 | |
parent | e38100debf2e39e58c0f9e49530ca8cb73badb5a (diff) |
put the solver into its own class.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Dependencies.pm | 19 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 4 |
2 files changed, 14 insertions, 9 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm index ef512f23f4c..e5fb18af201 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.29 2007/05/14 17:52:08 espie Exp $ +# $OpenBSD: Dependencies.pm,v 1.30 2007/05/14 18:19:25 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org> # @@ -18,13 +18,9 @@ use strict; use warnings; -package OpenBSD::Dependencies; +package OpenBSD::Dependencies::Solver; -use OpenBSD::PackageName; use OpenBSD::PackageInfo; -use OpenBSD::SharedLibs; -use OpenBSD::Error; -use OpenBSD::Interactive; sub find_candidate { @@ -37,7 +33,7 @@ sub find_candidate } } -sub solver +sub new { my $class = shift; bless {to_install => {}, deplist => [], to_register => {} }, $class; @@ -46,6 +42,9 @@ sub solver sub add_todo { my ($self, @extra) = @_; + + require OpenBSD::PackageName; + for my $fullname (@extra) { $self->{to_install}-> {OpenBSD::PackageName::url2pkgname($fullname)} = $fullname; @@ -103,6 +102,8 @@ sub solve_dependency return; } if (@candidates > 1) { + require OpenBSD::Interactive; + # put default first if available @candidates = ((grep {$_ eq $dep->{def}} @candidates), (sort (grep {$_ ne $dep->{def}} @candidates))); @@ -145,6 +146,10 @@ sub dump } } +package OpenBSD::Dependencies; + +use OpenBSD::SharedLibs; + sub check_lib_spec { my ($base, $spec, $dependencies) = @_; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 380fe2c45ff..eb7d07f039f 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.246 2007/05/14 17:52:08 espie Exp $ +# $OpenBSD: pkg_add,v 1.247 2007/05/14 18:19:25 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -530,7 +530,7 @@ sub install_package } } if (!defined $handle->{solved_dependencies}) { - my $solver = OpenBSD::Dependencies->solver; + my $solver = OpenBSD::Dependencies::Solver->new; my @deps = $solver->solve($state, $handle, @todo); if ($state->{verbose}) { $solver->dump; |