summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2010-01-02 12:52:19 +0000
committerMarc Espie <espie@cvs.openbsd.org>2010-01-02 12:52:19 +0000
commit4893a508cc75d4392470e57f63263db944fc2c8e (patch)
treea5e790d9f8115a5dc76cdb47bdc2b4eae9c80c54 /usr.sbin/pkg_add/OpenBSD
parent4f326cf2825008ca1b36472028d1020626c5fec8 (diff)
first step in comparing full signatures: make them full objects, with
proper sign/compare interfaces.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm65
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm19
2 files changed, 58 insertions, 26 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index 86cafbdfc4f..7bfea41c668 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingList.pm,v 1.98 2010/01/01 16:09:35 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.99 2010/01/02 12:52:18 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -538,22 +538,6 @@ sub to_installation
}
-sub signature
-{
- my $self = shift;
- if ($self->has('always-update')) {
- my $s;
- open my $fh, '>', \$s;
- $self->write_no_sig($fh);
- close $fh;
- return $s;
- } else {
- my $k = {};
- $self->visit('signature', $k);
- return join(',', $self->pkgname, sort keys %$k);
- }
-}
-
sub forget
{
}
@@ -581,4 +565,51 @@ sub AUTOLOAD
}
}
+sub signature
+{
+ my $self = shift;
+ if ($self->has('always-update')) {
+ my $s;
+ open my $fh, '>', \$s;
+ $self->write_no_sig($fh);
+ close $fh;
+ return OpenBSD::PackingList::FullSignature->new($self->pkgname,
+ $s);
+ } else {
+ my $k = {};
+ $self->visit('signature', $k);
+ my $o = [$self->pkgname, sort keys %$k];
+ return OpenBSD::PackingList::Signature->new($self->pkgname,
+ [sort keys %$k]);
+ }
+}
+
+package OpenBSD::PackingList::Signature;
+sub new
+{
+ my ($class, $pkgname, $extra) = @_;
+ bless { name => $pkgname, extra => $extra }, $class;
+}
+
+sub string
+{
+ my $self = shift;
+ return join(',', $self->{name}, @{$self->{extra}});
+}
+
+sub compare
+{
+ my ($a, $b) = @_;
+ return $a->string cmp $b->string;
+}
+
+package OpenBSD::PackingList::FullSignature;
+our @ISA=qw(OpenBSD::PackingList::Signature);
+
+sub string
+{
+ my $self = shift;
+ return $self->{extra};
+}
+
1;
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index a0258edfbe2..95001f90b7c 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.126 2010/01/01 17:37:08 espie Exp $
+# $OpenBSD: Update.pm,v 1.127 2010/01/02 12:52:18 espie Exp $
#
# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
#
@@ -146,12 +146,12 @@ sub process_handle
return $l;
}
my @l2 = ();
- for my $handle (@$l) {
- $handle->set_arch($state->{arch});
- if (!$handle) {
+ for my $loc (@$l) {
+ $loc->set_arch($state->{arch});
+ if (!$loc) {
next;
}
- my $p2 = $handle->update_info;
+ my $p2 = $loc->update_info;
if (!$p2) {
next;
}
@@ -164,13 +164,14 @@ sub process_handle
$oldfound = 1;
next;
}
- if ($plist->signature eq $p2->signature) {
- $found = $handle;
- push(@l2, $handle);
+ if ($plist->signature->compare($p2->signature) eq 0) {
+ $found = $loc;
+ push(@l2, $loc);
next;
}
if ($plist->match_pkgpath($p2)) {
- push(@l2, $handle);
+ push(@l2, $loc);
+ next
}
}
return \@l2;