summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-06-02 12:37:38 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-06-02 12:37:38 +0000
commitc6b3b36856c4cf696cde8eae0c0cc5c5b3c253d3 (patch)
tree0242068f1b1d677a968ca810ae5211c01efdad6a /usr.sbin/pkg_add
parent918e6d8248ee4db4c1f6cfa815dbb844121bbd4c (diff)
move the check that dependencies are satisfied inside the solver object
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm13
-rw-r--r--usr.sbin/pkg_add/pkg_add11
2 files changed, 18 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index ea81feb1756..56f883f429e 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.48 2007/06/02 12:21:14 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.49 2007/06/02 12:37:37 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -165,6 +165,17 @@ sub solve_depends
return @{$self->{deplist}};
}
+sub check_depends
+{
+ my $self = shift;
+ my @bad = ();
+
+ for my $dep ($self->dependencies) {
+ push(@bad, $dep) unless is_installed($dep);
+ }
+ return @bad;
+}
+
sub dump
{
my $self = shift;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 1cdef2d9f7f..0b350a97005 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.307 2007/06/02 12:21:14 espie Exp $
+# $OpenBSD: pkg_add,v 1.308 2007/06/02 12:37:37 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -497,11 +497,12 @@ sub install_package
}
}
- # verify dependencies and register them
+ # verify dependencies have been installed
+ my @baddeps = $set->{solver}->check_depends;
- for my $dep ($set->{solver}->dependencies) {
- next if is_installed($dep);
- print "Can't install $pkg: can't resolve $dep\n";
+ if (@baddeps) {
+ print "Can't install $pkg: can't resolve ",
+ join(',', @baddeps), "\n";
$location->close_now;
$bad++;
return ();