summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-10-15 18:17:19 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-10-15 18:17:19 +0000
commit28304259ca5315041425156cfcf7aea48374aee8 (patch)
tree566cddd03078970b9d71e8fb777d47b6d923d18c
parent5cd8644faf7aacec9e6ebf03f3e8e0823c28cc80 (diff)
pkg_add will need to track installation progress globally, so that we don't
solve dependencies with stuff that we want to update later... create that information, to be used...
-rw-r--r--usr.sbin/pkg_add/Makefile3
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Tracker.pm65
-rw-r--r--usr.sbin/pkg_add/pkg_add6
3 files changed, 72 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/Makefile b/usr.sbin/pkg_add/Makefile
index ba6cf384294..3f80f3022f7 100644
--- a/usr.sbin/pkg_add/Makefile
+++ b/usr.sbin/pkg_add/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.53 2009/10/14 22:59:34 espie Exp $
+# $OpenBSD: Makefile,v 1.54 2009/10/15 18:17:18 espie Exp $
.include <bsd.own.mk>
@@ -45,6 +45,7 @@ PACKAGES= \
OpenBSD/SharedLibs.pm \
OpenBSD/Subst.pm \
OpenBSD/Temp.pm \
+ OpenBSD/Tracker.pm \
OpenBSD/Update.pm \
OpenBSD/UpdateSet.pm \
OpenBSD/Ustar.pm \
diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
new file mode 100644
index 00000000000..ebfc6c5b544
--- /dev/null
+++ b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
@@ -0,0 +1,65 @@
+# ex:ts=8 sw=4:
+# $OpenBSD: Tracker.pm,v 1.1 2009/10/15 18:17:18 espie Exp $
+#
+# Copyright (c) 2009 Marc Espie <espie@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+#
+
+use strict;
+use warnings;
+
+# the tracker class is used to track what's going on during a complicated
+# install. Specifically: what packages are installed, what's left to do,
+# etc
+
+package OpenBSD::Tracker;
+sub new
+{
+ my $class = shift;
+ return bless {}, $class;
+}
+
+sub add_set
+{
+ my ($self, $set) = @_;
+ for my $n ($set->newer) {
+ $self->{to_install}->{$n->pkgname} = $set;
+ }
+ for my $n ($set->older) {
+ $self->{to_update}->{$n->pkgname} = $set;
+ }
+ return $self;
+}
+
+sub add_sets
+{
+ my ($self, @sets) = @_;
+ for my $set (@sets) {
+ $self->add_set($set);
+ }
+ return $self;
+}
+
+sub mark_installed
+{
+ my ($self, $set) = @_;
+ for my $n ($set->newer) {
+ undef $self->{to_install}->{$n->pkgname};
+ $self->{installed}->{$n->pkgname} = 1;
+ }
+ for my $n ($set->older) {
+ undef $self->{to_update}->{$n->pkgname};
+ }
+}
+
+1;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 4fa3825e749..7f68e18bc2c 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.353 2009/10/15 10:45:47 espie Exp $
+# $OpenBSD: pkg_add,v 1.354 2009/10/15 18:17:18 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -527,6 +527,7 @@ sub install_set
really_add($set, $state);
$location->wipe_info;
delete $handle->{plist};
+ $state->{tracker}->mark_installed($set);
$state->mark_installed($handle->pkgname);
return ();
}
@@ -777,6 +778,9 @@ if ($bad) {
# This is the actual very small loop that adds all packages
eval {
+require OpenBSD::Tracker;
+$state->{tracker} = OpenBSD::Tracker->new;
+$state->{tracker}->add_sets(@todo2);
while (my $set = shift @todo2) {
unshift(@todo2, install_set($set, $state, @todo2));
}