diff options
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/Signature.pm')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Signature.pm | 73 |
1 files changed, 48 insertions, 25 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Signature.pm b/usr.sbin/pkg_add/OpenBSD/Signature.pm index 302298f18e0..f3a73e58d55 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.19 2017/09/18 13:01:10 espie Exp $ +# $OpenBSD: Signature.pm,v 1.20 2018/02/06 15:17:26 espie Exp $ # # Copyright (c) 2010 Marc Espie <espie@openbsd.org> # @@ -18,56 +18,79 @@ use strict; use warnings; -package OpenBSD::PackageName::Name; -sub long_string +package OpenBSD::PackingElement; +sub signature {} + +package OpenBSD::PackingElement::VersionElement; +sub signature { - my $self = shift; - return '@'.$self->to_string; + my ($self, $hash) = @_; + $hash->{$self->signature_key} = $self; } sub always { - return 0; + return 1; } -package OpenBSD::LibObject; -sub long_string +package OpenBSD::PackingElement::Dependency; +sub signature_key { my $self = shift; - return $self->to_string; + return $self->{pkgpath}; } -sub always +sub sigspec { - return 1; + my $self = shift; + return OpenBSD::PackageName->from_string($self->{def}); } -package OpenBSD::PackingElement; -sub signature {} +sub long_string +{ + my $self = shift; + return '@'.$self->sigspec->to_string; +} -package OpenBSD::PackingElement::Dependency; -sub signature +sub compare { - my ($self, $hash) = @_; - $hash->{$self->{pkgpath}} = OpenBSD::PackageName->from_string($self->{def}); + my ($a, $b) = @_; + return $a->sigspec->compare($b->sigspec); } -package OpenBSD::PackingElement::Wantlib; -sub signature +sub always { - my ($self, $hash) = @_; + return 0; +} +package OpenBSD::PackingElement::Wantlib; +sub signature_key +{ + my $self = shift; my $spec = $self->spec; if ($spec->is_valid) { - $hash->{$spec->key} = $spec; + return $spec->key; + } else { + return "???"; } } -package OpenBSD::PackingElement::Version; +sub compare +{ + my ($a, $b) = @_; + return $a->spec->compare($b->spec); +} -sub signature +sub long_string { - my ($self, $hash) = @_; - $hash->{VERSION} = $self; + my $self = shift; + return $self->spec->to_string; +} + + +package OpenBSD::PackingElement::Version; +sub signature_key +{ + return 'VERSION'; } sub long_string |