summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-10-19 14:07:27 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-10-19 14:07:27 +0000
commit7094a1d6c3f904768d247810bcb24097c6bc2351 (patch)
treed6ad8868338e3b79e80c9bb0ee4a78f8df3f0300 /usr.sbin
parent5ee5e2e3fe83bf75469c502000e0990d8e369b8d (diff)
basic routines to handle the merging of updatesets: mark updatesets as
already done, separate remove/mark_installed in tracker, create a merge method that allows the merging of updatesets.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Tracker.pm14
-rw-r--r--usr.sbin/pkg_add/OpenBSD/UpdateSet.pm24
-rw-r--r--usr.sbin/pkg_add/pkg_add6
3 files changed, 39 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
index fa761ca4ace..bb5af15b4e5 100644
--- a/usr.sbin/pkg_add/OpenBSD/Tracker.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Tracker.pm,v 1.3 2009/10/16 18:29:43 espie Exp $
+# $OpenBSD: Tracker.pm,v 1.4 2009/10/19 14:07:26 espie Exp $
#
# Copyright (c) 2009 Marc Espie <espie@openbsd.org>
#
@@ -50,18 +50,26 @@ sub add_sets
return $self;
}
-sub mark_installed
+sub remove_set
{
my ($self, $set) = @_;
for my $n ($set->newer) {
delete $self->{to_install}->{$n->pkgname};
- $self->{installed}->{$n->pkgname} = 1;
}
for my $n ($set->older) {
delete $self->{to_update}->{$n->pkgname};
}
}
+sub mark_installed
+{
+ my ($self, $set) = @_;
+ for my $n ($set->newer) {
+ $self->{installed}->{$n->pkgname} = 1;
+ }
+ $self->remove_set($set);
+}
+
sub is_installed
{
my ($self, $pkg) = @_;
diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
index ce651f2e8ac..a8c38d0c13c 100644
--- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
+++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: UpdateSet.pm,v 1.9 2009/10/15 10:45:47 espie Exp $
+# $OpenBSD: UpdateSet.pm,v 1.10 2009/10/19 14:07:26 espie Exp $
#
# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
#
@@ -267,6 +267,28 @@ sub from_location
return $set;
}
+# Merge several updatesets together
+sub merge
+{
+ my ($self, $tracker, @sets) = @_;
+ # Apparently simple, just add the missing parts
+ for my $set (@sets) {
+ for my $p ($set->newer) {
+ $self->add_newer($p);
+ }
+ for my $p ($set->older) {
+ $self->add_older($p);
+ }
+ # BUT XXX tell the tracker we killed the set
+ $tracker->remove_set($set);
+ # ... and mark it as already done
+ $set->{finished} = 1;
+ }
+ # then regen tracker info for $self
+ $tracker->add_set($self);
+ return $self;
+}
+
package OpenBSD::PackingList;
sub compute_size
{
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index c57a7f16620..c793948731d 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.360 2009/10/19 14:00:10 espie Exp $
+# $OpenBSD: pkg_add,v 1.361 2009/10/19 14:07:26 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -449,6 +449,10 @@ sub install_set
{
my ($set, $state, @todo) = @_;
+ if ($set->{finished}) {
+ return ();
+ }
+
my $handle = $set->handle;
if ($state->{tracker}->is_installed($handle->pkgname)) {
$handle->cleanup(OpenBSD::Handle::ALREADY_INSTALLED);