diff options
author | 2018-06-19 10:19:04 +0000 | |
---|---|---|
committer | 2018-06-19 10:19:04 +0000 | |
commit | e9ae3a042315170362ff9515736f00ea5ad717a0 (patch) | |
tree | c85ec2eed84152bb3eb0868cb3bebe3475a1bd6c | |
parent | Correct pfCntProtoCksum description. (diff) | |
download | wireguard-openbsd-e9ae3a042315170362ff9515736f00ea5ad717a0.tar.xz wireguard-openbsd-e9ae3a042315170362ff9515736f00ea5ad717a0.zip |
getting closer to having actual tags working.
I now know under which form they need to be stored
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 111 |
1 files changed, 54 insertions, 57 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 6d552d8e7bf..0f1c7be4173 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.251 2018/05/26 18:12:43 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.252 2018/06/19 10:19:04 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -305,18 +305,6 @@ sub compute_digest return $class->new($filename); } -sub write -{ - my ($self, $fh) = @_; - - $self->SUPER::write($fh); - if (defined $self->{tags}) { - for my $tag (sort keys %{$self->{tags}}) { - print $fh "\@tag ", $tag, "\n"; - } - } -} - # exec/unexec and friends package OpenBSD::PackingElement::Action; our @ISA=qw(OpenBSD::PackingElement::Object); @@ -764,50 +752,6 @@ sub add return; } -package OpenBSD::PackingElement::tag; -our @ISA=qw(OpenBSD::PackingElement::Annotation); - -__PACKAGE__->register_with_factory('tag'); - -sub add -{ - my ($class, $plist, $args) = @_; - - if ($args eq 'no checksum') { - $plist->{state}{lastfile}{nochecksum} = 1; - } else { - my $object = $plist->{state}{lastfileobject}; - $object->{tags}{$args} = 1; - push(@{$plist->{tags}{$args}}, $object); - } - return undef; -} - -package OpenBSD::PackingElement::DefineTag; -our @ISA=qw(OpenBSD::PackingElement::Meta); - -sub category() { 'define-tag' } -sub keyword() { 'define-tag' } -__PACKAGE__->register_with_factory; - -sub new -{ - my ($class, $args) = @_; - my ($tag, $condition, @command) = split(/\s+/, $args); - bless { - name => $tag, - when => $condition, - command => join(' ', @command) - }, $class; -} - -sub stringize -{ - my $self = shift; - return join(' ', map { $self->{$_}} - (qw(name when command))); -} - package OpenBSD::PackingElement::symlink; our @ISA=qw(OpenBSD::PackingElement::Annotation); @@ -1384,6 +1328,59 @@ sub run unless $state->{not}; } +# so tags are going to get triggered by packages we depend on. +# turns out it's simpler to have them as "actions" because that's basically +# what's going to happen, so destate is good for them, gives us access +# to things like %D +package OpenBSD::PackingElement::TagBase; +our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); + +sub new +{ + my ($class, $args) = @_; + my ($tag, @params) = split(/\s+/, $args); + bless { + name => $tag, + params => \@params, + }, $class; +} + +sub stringize +{ + my $self = shift; + return join(' ', $self->name, @{$self->{params}}); +} + +package OpenBSD::PackingElement::Tag; +our @ISA=qw(OpenBSD::PackingElement::TagBase); +sub keyword() { 'tag' } + +__PACKAGE__->register_with_factory; + +# tags are a kind of dependency, we have a special list for them, BUT +# they're still part of the normal packing-list +sub add_object +{ + my ($self, $plist) = @_; + push(@{$plist->{tags}}, $self); + $self->SUPER::add_object($plist); +} + +# and the define tag thingy is very similar... the main difference being +# how it's actually registered +package OpenBSD::PackingElement::DefineTag; +our @ISA=qw(OpenBSD::PackingElement::TagBase); + +sub keyword() { 'define-tag' } +__PACKAGE__->register_with_factory; + +sub add_object +{ + my ($self, $plist) = @_; + push(@{$plist->{tags_definitions}{$self->name}}, $self); + $self->SUPER::add_object($plist); +} + package OpenBSD::PackingElement::Exec; our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); |