From ce04fd2bd6c5d214b1dd2e216264a172bbc9666a Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sun, 10 Jan 2010 12:38:28 +0000 Subject: follow logic: if same packagename, but different signature elements, something very bad happened. --- usr.sbin/pkg_add/OpenBSD/Signature.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/Signature.pm b/usr.sbin/pkg_add/OpenBSD/Signature.pm index 5d7a37a449d..05d6f5c1dcb 100644 --- a/usr.sbin/pkg_add/OpenBSD/Signature.pm +++ b/usr.sbin/pkg_add/OpenBSD/Signature.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Signature.pm,v 1.1 2010/01/10 11:31:08 espie Exp $ +# $OpenBSD: Signature.pm,v 1.2 2010/01/10 12:38:27 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -87,14 +87,28 @@ sub compare } } +sub print_error +{ + my ($a, $b) = @_; + + print STDERR "Error: $a->{name} exists in two non-comparable versions\n"; + print STDERR "Someone forgot to bump a PKGNAME\n"; + print STDERR $a->string, " vs. ", $b->string, "\n"; +} + sub revert_compare { my ($b, $a) = @_; my $awins = 0; my $bwins = 0; + my $done = {}; while (my ($k, $v) = each %{$a->{extra}}) { - next if !defined $b->{extra}{$k}; + if (!defined $b->{extra}{$k}) { + $a->print_error($b); + return undef; + } + $done->{$k} = 1; my $r = $v->compare($b->{extra}{$k}); if ($r > 0) { $awins++; @@ -102,6 +116,12 @@ sub revert_compare $bwins++; } } + for my $k (keys %{$b->{extra}}) { + if (!$done->{$k}) { + $a->print_error($b); + return undef; + } + } if ($awins == 0) { return -$bwins; } elsif ($bwins == 0) { -- cgit v1.2.3