summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2009-12-14 18:11:27 +0000
committerMarc Espie <espie@cvs.openbsd.org>2009-12-14 18:11:27 +0000
commit7674533e6a2badacb685368c66008f13385558d1 (patch)
tree2edf3592cfd7085b1316925abd8034308a864211 /usr.sbin
parente6042e09cd6a4ab6af45b46a78f83abad92192e3 (diff)
since some packages in updatesets don't need updates, be explicit about it.
This is more complex and simpler at the same time...
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Replace.pm9
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Tracker.pm10
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm8
-rw-r--r--usr.sbin/pkg_add/OpenBSD/UpdateSet.pm45
-rw-r--r--usr.sbin/pkg_add/pkg_add18
5 files changed, 58 insertions, 32 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm
index f11ef8947f0..507ffa099a7 100644
--- a/usr.sbin/pkg_add/OpenBSD/Replace.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Replace.pm,v 1.59 2009/12/14 09:12:43 espie Exp $
+# $OpenBSD: Replace.pm,v 1.60 2009/12/14 18:11:26 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -344,7 +344,8 @@ sub can_old_package_be_replaced
$state->errsay("Error: $wanting missing from installation");
} else {
$p2->validate_depend($state, $wanting,
- $old_plist->pkgname, $set->newer_names);
+ $old_plist->pkgname, $set->newer_names,
+ $set->kept_names);
}
}
}
@@ -470,8 +471,7 @@ sub save_libs_from_handle
for my $n ($set->newer) {
$n->plist->unmark_lib($libs, $p);
}
- for my $n ($set->older) {
- next unless $n->{keepit};
+ for my $n ($set->kept) {
$n->plist->unmark_lib($libs, $p);
}
@@ -489,7 +489,6 @@ sub save_old_libraries
my ($set, $state) = @_;
for my $o ($set->older) {
- next if $o->{keepit};
save_libs_from_handle($o, $set, $state);
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Tracker.pm b/usr.sbin/pkg_add/OpenBSD/Tracker.pm
index 924fbc0353b..485e14b0797 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.15 2009/12/14 13:50:28 espie Exp $
+# $OpenBSD: Tracker.pm,v 1.16 2009/12/14 18:11:26 espie Exp $
#
# Copyright (c) 2009 Marc Espie <espie@openbsd.org>
#
@@ -55,6 +55,10 @@ sub add_set
for my $n ($set->older, $set->hints) {
$self->{to_update}->{$n->pkgname} = $set;
}
+ for my $n ($set->kept) {
+ delete $self->{to_update}->{$n->pkgname};
+ $self->{uptodate}->{$n->pkgname} = 1;
+ }
$self->known($set);
return $self;
}
@@ -74,7 +78,7 @@ sub remove_set
for my $n ($set->newer) {
delete $self->{to_install}->{$n->pkgname};
}
- for my $n ($set->older, $set->hints) {
+ for my $n ($set->kept, $set->older, $set->hints) {
delete $self->{to_update}->{$n->pkgname};
delete $self->{cant_update}->{$n->pkgname};
}
@@ -84,7 +88,7 @@ sub uptodate
{
my ($self, $set) = @_;
$self->remove_set($set);
- for my $n ($set->older) {
+ for my $n ($set->older, $set->kept) {
$self->{uptodate}->{$n->pkgname} = 1;
}
}
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index b1afb9cfa52..c65cc94d4fa 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.117 2009/12/14 11:19:04 espie Exp $
+# $OpenBSD: Update.pm,v 1.118 2009/12/14 18:11:26 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -92,7 +92,7 @@ sub process_handle
}
if ($pkgname =~ m/^partial\-/o) {
$state->say("Not updating $pkgname, remember to clean it");
- $h->{keepit} = 1;
+ $set->move_kept($h);
return 0;
}
@@ -174,7 +174,7 @@ sub process_handle
if (@$l == 0) {
if ($oldfound) {
$h->{update_found} = $h;
- $h->{keepit} = 1;
+ $set->move_kept($h);
$self->progress_message($state,
"No need to update $pkgname");
@@ -187,7 +187,7 @@ sub process_handle
if (defined $found && $found eq $l->[0] &&
!$plist->uses_old_libs && !$state->{defines}->{installed}) {
$h->{update_found} = $h;
- $h->{keepit} = 1;
+ $set->move_kept($h);
$self->progress_message($state,
"No need to update $pkgname");
diff --git a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
index 46bb9babd1b..8551035a3c6 100644
--- a/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
+++ b/usr.sbin/pkg_add/OpenBSD/UpdateSet.pm
@@ -1,7 +1,7 @@
# ex:ts=8 sw=4:
-# $OpenBSD: UpdateSet.pm,v 1.38 2009/12/13 17:58:55 espie Exp $
+# $OpenBSD: UpdateSet.pm,v 1.39 2009/12/14 18:11:26 espie Exp $
#
-# Copyright (c) 2007 Marc Espie <espie@openbsd.org>
+# Copyright (c) 2007-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
@@ -17,10 +17,11 @@
# an UpdateSet is a list of packages to remove/install.
-# it contains three things:
+# it contains several things:
# -> a list of older packages to remove (installed locations)
# -> a list of newer packages to add (might be very simple locations)
# -> a list of "hints", as package names to install
+# -> a list of packages that are kept throughout an update
# every add/remove operations manipulate UpdateSet.
#
# Since older packages are always installed, they're organized as a hash.
@@ -32,6 +33,14 @@
# Normal UpdateSets contain one newer package at most.
# Bigger UpdateSets can be created through the merge operation, which
# will be used only when necessary.
+#
+# kept packages are needed after merges, where some dependencies may
+# not need updating, and to distinguish from old packages that will be
+# removed.
+#
+# for instance, package installation will check UpdateSets for internal
+# dependencies and for conflicts. For that to work, we need kept stuff
+#
use strict;
use warnings;
@@ -56,7 +65,7 @@ package OpenBSD::UpdateSet;
sub new
{
my $class = shift;
- return bless {newer => {}, older => {}, hints => [], updates => 0},
+ return bless {newer => {}, older => {}, kept => {}, hints => [], updates => 0},
$class;
}
@@ -94,6 +103,16 @@ sub add_older
return $self;
}
+sub move_kept
+{
+ my $self = shift;
+ for my $h (@_) {
+ delete $self->{older}->{$h->pkgname};
+ $self->{kept}->{$h->pkgname} = $h;
+ }
+ return $self;
+}
+
sub add_hints
{
my $self = shift;
@@ -124,6 +143,12 @@ sub older
return values %{$self->{older}};
}
+sub kept
+{
+ my $self = shift;
+ return values %{$self->{kept}};
+}
+
sub hints
{
my $self =shift;
@@ -142,6 +167,12 @@ sub newer_names
return keys %{$self->{newer}};
}
+sub kept_names
+{
+ my $self = shift;
+ return keys %{$self->{kept}};
+}
+
sub hint_names
{
my $self =shift;
@@ -157,8 +188,7 @@ sub older_to_do
require OpenBSD::PackageInfo;
my @l = ();
for my $h ($self->older) {
- if (!defined $h->{keepit} &&
- OpenBSD::PackageInfo::is_installed($h->pkgname)) {
+ if (OpenBSD::PackageInfo::is_installed($h->pkgname)) {
push(@l, $h);
}
}
@@ -169,6 +199,9 @@ sub print
{
my $self = shift;
my $result = "";
+ if ($self->kept > 0) {
+ $result = "[".join('+', $self->kept_names)."]";
+ }
if ($self->older > 0) {
$result .= join('+',$self->older_names)."->";
}
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 33aa8428076..60518b071e4 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.426 2009/12/14 09:35:56 espie Exp $
+# $OpenBSD: pkg_add,v 1.427 2009/12/14 18:11:26 espie Exp $
#
# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org>
#
@@ -296,9 +296,9 @@ sub recheck_conflicts
{
my ($set, $state) = @_;
- # no conflicts between newer sets
- for my $h ($set->newer) {
- for my $h2 ($set->newer) {
+ # no conflicts between newer sets nor kept sets
+ for my $h ($set->newer, $set->kept) {
+ for my $h2 ($set->newer, $set->kept) {
next if $h2 == $h;
if ($h->plist->conflict_list->conflicts_with($h2->pkgname)) {
$state->errsay($set->print, ": internal conflict between ", $h->pkgname, " and ", $h2->pkgname);
@@ -307,16 +307,6 @@ sub recheck_conflicts
}
}
- # and between newer sets and kept sets neither
- for my $h ($set->newer) {
- for my $h2 ($set->older) {
- next unless $h2->{keepit};
- if ($h->plist->conflict_list->conflicts_with($h2->pkgname) || $h2->plist->conflict_list->conflicts_with($h->pkgname)) {
- $state->errsay($set->print, ": internal conflict between ", $h->pkgname, " and ", $h2->pkgname);
- return 0;
- }
- }
- }
return 1;
}