summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2010-01-10 16:03:49 +0000
committerespie <espie@openbsd.org>2010-01-10 16:03:49 +0000
commitf11e17d2df099fa792efdf3ddf1e517982153c56 (patch)
tree6b73c63a817e277ddc3c5487ad876e535829e7ae
parentAdd /var/db/sysmerge, needed for upcoming change in xenocara. (diff)
downloadwireguard-openbsd-f11e17d2df099fa792efdf3ddf1e517982153c56.tar.xz
wireguard-openbsd-f11e17d2df099fa792efdf3ddf1e517982153c56.zip
use full signatures to avoid downgrades.
remove double check in update that properly belongs in pkg_add replace has_new_sig by has_different_sig, with better diagnostic messages.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm22
-rw-r--r--usr.sbin/pkg_add/TODO4
-rw-r--r--usr.sbin/pkg_add/pkg_add33
3 files changed, 30 insertions, 29 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 3000286bd55..e79e4f20788 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.132 2010/01/09 15:10:17 espie Exp $
+# $OpenBSD: Update.pm,v 1.133 2010/01/10 16:03:49 espie Exp $
#
# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
#
@@ -122,7 +122,6 @@ sub process_handle
eval {
$state->quirks->tweak_search(\@search, $h, $state);
};
- my $found;
my $oldfound = 0;
# XXX this is nasty: maybe we added an old set to update
@@ -164,9 +163,9 @@ sub process_handle
$oldfound = 1;
next;
}
- if ($plist->signature->compare($p2->signature) eq 0) {
- $found = $loc;
- push(@l2, $loc);
+ my $r = $plist->signature->compare($p2->signature);
+ if (defined $r && $r > 0 && !$state->{defines}{downgrades}) {
+ $oldfound = 1;
next;
}
if ($plist->match_pkgpath($p2)) {
@@ -194,19 +193,6 @@ sub process_handle
}
return undef;
}
- if (@$l == 1) {
- if (defined $found && $found eq $l->[0] &&
- !$plist->uses_old_libs && !$state->{defines}->{installed}) {
- $h->{update_found} = $h;
- $set->move_kept($h);
-
- $self->progress_message($state,
- "No need to update $pkgname");
-
- return 0;
- }
- }
-
$state->say("Update candidates: $pkgname -> ",
join(' ', map {$_->name} @$l), $state->ntogo) if $state->verbose;
diff --git a/usr.sbin/pkg_add/TODO b/usr.sbin/pkg_add/TODO
index 00a58fe247c..2d0c8f11098 100644
--- a/usr.sbin/pkg_add/TODO
+++ b/usr.sbin/pkg_add/TODO
@@ -11,10 +11,8 @@ full update, for instance... or ignore already installed packages (mostly
done).
- make sure all user-interface is done through a few functions, so that it's
easy to plug another interface in (mostly done)
-- compare full package signatures during updates, to ignore stuff that's
-different but older.
- don't close Location unconditionally while looking for updates. In most
cases, we're going to install this package right away, so we should try to
keep it open to avoid spurious ftp disconnects.
- get an update path for libraries to be able to adjust dependencies correctly.
-- provide a "smart" is it installed ? option. pkg_info -u package ?
+- allow pkg_add newpackage to do updates or install.
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 215585b16c6..26dfbd9a97d 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.463 2010/01/05 12:01:07 espie Exp $
+# $OpenBSD: pkg_add,v 1.464 2010/01/10 16:03:49 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -47,17 +47,34 @@ sub uses_old_libs
OpenBSD::Requiring->new($plist->pkgname)->list;
}
-sub has_new_sig
+sub has_different_sig
{
my ($plist, $state) = @_;
- if (!defined $plist->{new_sig}) {
+ if (!defined $plist->{different_sig}) {
my $n = OpenBSD::PackingList->from_installation($plist->pkgname)->signature;
my $o = $plist->signature;
- $state->say("Comparing full signature for ", $plist->pkgname, " \"".$o->string."\" vs. \"".$n->string."\": ", $n->compare($o) eq 0 ? "equal" : "different")
- if $state->verbose >= 3;
- $plist->{new_sig} = $n->compare($o) ne 0;
+ my $r = $n->compare($o);
+ $state->print("Comparing full signature for ",
+ $plist->pkgname, " \"", $o->string, "\" vs. \"",
+ $n->string,"\": ")
+ if $state->verbose >= 3;
+ if (defined $r) {
+ if ($r == 0) {
+ $plist->{different_sig} = 0;
+ $state->say("equal") if $state->verbose >= 3;
+ } elsif ($r > 0) {
+ $plist->{different_sig} = 1;
+ $state->say("greater") if $state->verbose >= 3;
+ } else {
+ $plist->{different_sig} = 1;
+ $state->say("less") if $state->verbose >= 3;
+ }
+ } else {
+ $plist->{different_sig} = 1;
+ $state->say("non comparable") if $state->verbose >= 3;
+ }
}
- return $plist->{new_sig};
+ return $plist->{different_sig};
}
package OpenBSD::State;
@@ -212,7 +229,7 @@ sub complete
if (is_installed($pkgname) &&
(!$state->{allow_replacing} ||
!$state->{defines}->{installed} &&
- !$plist->has_new_sig($state) &&
+ !$plist->has_different_sig($state) &&
!$plist->uses_old_libs)) {
my $o = $set->{older}->{$pkgname};
if (!defined $o) {