diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2018-06-22 13:58:56 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2018-06-22 13:58:56 +0000 |
commit | 12a7e5168c4299f5137c967d20a8b1f4233775f6 (patch) | |
tree | e090d8d09257b50b37c4dfa11d96895426ceb894 | |
parent | 3e95cf9f2a9c7abd493a82e5592d4a87bf8389f4 (diff) |
let the tag logic migrate into state for running atend,
have expand work on the appropriate string
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 12 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 72 |
3 files changed, 84 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index 4e00d7af7a6..2bfb909e246 100644 --- a/usr.sbin/pkg_add/OpenBSD/Add.pm +++ b/usr.sbin/pkg_add/OpenBSD/Add.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Add.pm,v 1.175 2018/06/15 09:37:29 espie Exp $ +# $OpenBSD: Add.pm,v 1.176 2018/06/22 13:58:55 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -783,6 +783,17 @@ sub should_run return $state->replacing; } +package OpenBSD::PackingElement::Tag; + +sub install +{ + my ($self, $state) = @_; + + for my $d (@{$self->{definition_list}}) { + $d->add_tag($self, "install", $state); + } +} + package OpenBSD::PackingElement::Lib; sub install diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 6c3829dbcc9..4e6d7ab911a 100644 --- a/usr.sbin/pkg_add/OpenBSD/Delete.pm +++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Delete.pm,v 1.153 2018/06/20 10:15:42 espie Exp $ +# $OpenBSD: Delete.pm,v 1.154 2018/06/22 13:58:55 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -374,6 +374,16 @@ sub should_run return $state->replacing; } +package OpenBSD::PackingElement::Tag; +sub delete +{ + my ($self, $state) = @_; + + for my $d (@{$self->{definition_list}}) { + $d->add_tag($self, "delete", $state); + } +} + package OpenBSD::PackingElement::FileBase; use OpenBSD::Error; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index c33f86b3a2f..7b63d96ab65 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.253 2018/06/19 13:23:08 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.254 2018/06/22 13:58:55 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -1288,10 +1288,16 @@ use File::Basename; use OpenBSD::Error; our @ISA=qw(OpenBSD::PackingElement::Action); +sub command +{ + my $self = shift; + return $self->name; +} + sub expand { my ($self, $state) = @_; - my $e = $self->name; + my $e = $self->command; if ($e =~ m/\%F/o) { die "Bad expand" unless defined $state->{lastfile}; $e =~ s/\%F/$state->{lastfile}->{name}/g; @@ -1335,28 +1341,34 @@ sub run package OpenBSD::PackingElement::TagBase; our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); +sub command +{ + my $self = shift; + return $self->{params}; +} + +package OpenBSD::PackingElement::Tag; +our @ISA=qw(OpenBSD::PackingElement::TagBase); +sub keyword() { 'tag' } + +__PACKAGE__->register_with_factory; + sub new { my ($class, $args) = @_; - my ($tag, @params) = split(/\s+/, $args); + my ($tag, $params) = split(/\s+/, $args, 2); bless { name => $tag, - params => \@params, + params => $params, }, $class; } sub stringize { my $self = shift; - return join(' ', $self->name, @{$self->{params}}); + 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 @@ -1375,13 +1387,51 @@ sub category() {'define-tag'} sub keyword() { 'define-tag' } __PACKAGE__->register_with_factory; +sub new +{ + my ($class, $args) = @_; + my ($tag, $mode, $params) = split(/\s+/, $args, 3); + bless { + name => $tag, + mode => $mode, + params => $params, + }, $class; +} + +sub stringize +{ + my $self = shift; + return join(' ', $self->name, $self->{mode}, $self->{params}); +} + sub add_object { my ($self, $plist) = @_; + if ($self->{mode} ne 'at-end') { + die "\@define-tag only has at-end mode so far"; + } push(@{$plist->{tags_definitions}{$self->name}}, $self); $self->SUPER::add_object($plist); } +sub add_tag +{ + my ($self, $tag, $mode, $state) = @_; + # special case: we have to run things *now* if deleting + if ($mode eq 'delete' && $tag->{found_in_self}) { + $self->run_tag($state); + delete $state->{atend}{$self->name}; + } else { + $state->{atend}{$self->name} = $self; + } +} + +sub run_tag +{ + my ($self, $state) = @_; + $self->run($state); +} + package OpenBSD::PackingElement::Exec; our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); |