summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-12-11 21:04:02 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-12-11 21:04:02 +0000
commit6af242a3e739f023250684a3d4f905df4a4fb67a (patch)
treef432ae30652ae3077eeb6d0c5b34a1fbbabb42ca /usr.sbin
parentcb8bc2f75993d068c5594621b46dab43a5a26c5b (diff)
record internal updateset dependencies for new packages, and respect them
while installing (need doing something similar for old packages)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm7
-rw-r--r--usr.sbin/pkg_add/pkg_add56
2 files changed, 55 insertions, 8 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 36149c89342..2286ed2e41d 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.96 2009/12/07 13:41:02 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.97 2009/12/11 21:04:01 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -283,7 +283,7 @@ sub find_dep_in_stuff_to_install
sub solve_dependency
{
- my ($self, $state, $dep) = @_;
+ my ($self, $state, $dep, $package) = @_;
my $v;
@@ -291,6 +291,7 @@ sub solve_dependency
$v = $self->find_dep_in_self($state, $dep);
if ($v) {
+ push(@{$package->{before}}, $v);
return $v;
}
$v = $self->find_dep_in_stuff_to_install($state, $dep);
@@ -347,7 +348,7 @@ sub solve_depends
for my $package ($self->{set}->newer) {
for my $dep (@{$package->{plist}->{depend}}) {
- my $v = $self->solve_dependency($state, $dep);
+ my $v = $self->solve_dependency($state, $dep, $package);
$self->{all_dependencies}->{$v} = $dep;
$self->{to_register}->{$package}->{$v} = $dep;
}
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 5aa568eab4d..467bdc9d2f8 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.419 2009/12/07 13:41:02 espie Exp $
+# $OpenBSD: pkg_add,v 1.420 2009/12/11 21:04:01 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -326,6 +326,49 @@ sub partial_install
return failed_message($base_msg, $state->{interrupted}, save_partial_set($set, $state));
}
+sub iterate
+{
+ my $sub = pop @_;
+ for my $p (@_) {
+ &$sub($p);
+ }
+}
+
+sub okay
+{
+ my ($h, $c) = @_;
+
+ for my $d (@{$c->{before}}) {
+ return 0 if !$h->{$d};
+ }
+ return 1;
+}
+
+sub iterate2
+{
+ my $sub = pop @_;
+ my $done = {};
+ my $something_done;
+
+ do {
+ $something_done = 0;
+
+ for my $c (@_) {
+ next if $done->{$c->pkgname};
+ if (okay($done, $c)) {
+ &$sub($c);
+ $done->{$c->pkgname} = 1;
+ $something_done = 1;
+ }
+ }
+ } while ($something_done);
+ # if we can't do stuff in order, do it anyways
+ for my $c (@_) {
+ next if $done->{$c->pkgname};
+ &$sub($c);
+ }
+}
+
sub really_add
{
my ($set, $state) = @_;
@@ -414,7 +457,8 @@ sub really_add
}
$set->{solver}->record_old_dependencies($state);
- for my $o ($set->older_to_do) {
+ iterate($set->older_to_do, sub {
+ my $o = shift;
$set->setup_header($state, $o, "deleting");
my $oldname = $o->pkgname;
$state->set_name_from_handle($o);
@@ -433,12 +477,14 @@ sub really_add
}
OpenBSD::PkgCfl::unregister($o->plist, $state);
$state->progress->clear;
- }
+ });
# Here there should be code to handle old libs
}
my $first = 1;
- for my $handle ($set->newer) {
+ iterate2($set->newer, sub {
+ my $handle = shift;
+
if (!$first) {
$state->progress->next;
$first = 0;
@@ -466,7 +512,7 @@ sub really_add
Fatal partial_install("Installation of $pkgname failed",
$set, $state);
}
- }
+ });
$set->setup_header($state);
$state->progress->next($state->{todo}-1);
for my $handle ($set->newer) {