diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-01-10 12:38:28 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-01-10 12:38:28 +0000 |
commit | ce04fd2bd6c5d214b1dd2e216264a172bbc9666a (patch) | |
tree | 5f36974ddd0c060921148005c956954195da1f50 | |
parent | 57e2f01933b107b8c662b9afa1141b4899984034 (diff) |
follow logic: if same packagename, but different signature elements,
something very bad happened.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Signature.pm | 24 |
1 files 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 <espie@openbsd.org> # @@ -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) { |