diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-16 11:50:50 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-16 11:50:50 +0000 |
commit | f044668231961c710a4134edb0c03f2f8bb19e83 (patch) | |
tree | cd372c817c85a65e17dbc9e0fe0d68a4a2b411b7 /usr.sbin/pkg_add/OpenBSD | |
parent | 1df63c925498514714e0c21bdfa76c271b121acc (diff) |
Add variation on exec/unexec:
@exec-always @unexec-always
@exec-add @unexec-delete
@exec-update @unexec-update
with the obvious semantics that *update are only run during updates,
and *add/delete are only run during `pure' additions/removals.
This should solve the problem of those packages that `lose' manual
configuration when you update them (e.g., all the mod_xxx apache stuff
and postfix).
caveat: you will need to go through one finaly broken update before the
new stuff kicks in.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 22 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 22 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 38 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Replace.pm | 49 |
4 files changed, 107 insertions, 24 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index 79572f0e029..c61b55904d7 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.78 2007/06/16 09:29:37 espie Exp $ +# $OpenBSD: Add.pm,v 1.79 2007/06/16 11:50:49 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -613,7 +613,25 @@ sub install my ($self, $state) = @_; $self->SUPER::install($state); - $self->run($state); + if ($self->should_run($state)) { + $self->run($state); + } +} + +sub should_run() { 1 } + +package OpenBSD::PackingElement::ExecAdd; +sub should_run +{ + my ($self, $state) = @_; + return !$state->{replacing}; +} + +package OpenBSD::PackingElement::ExecUpdate; +sub should_run +{ + my ($self, $state) = @_; + return $state->{replacing}; } package OpenBSD::PackingElement::Lib; diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index e8f77a8c5f0..39e469aa154 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.67 2007/06/16 09:29:37 espie Exp $ +# $OpenBSD: Delete.pm,v 1.68 2007/06/16 11:50:49 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -321,7 +321,25 @@ package OpenBSD::PackingElement::Unexec; sub delete { my ($self, $state) = @_; - $self->run($state); + if ($self->should_run($state)) { + $self->run($state); + } +} + +sub should_run() { 1 } + +package OpenBSD::PackingElement::UnexecDelete; +sub should_run +{ + my ($self, $state) = @_; + return !$state->{replacing}; +} + +package OpenBSD::PackingElement::UnexecUpdate; +sub should_run +{ + my ($self, $state) = @_; + return $state->{replacing}; } package OpenBSD::PackingElement::FileBase; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index b97ded0a837..717ea1f6e5c 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.136 2007/06/16 09:29:37 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.137 2007/06/16 11:50:49 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -1032,12 +1032,48 @@ our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); sub keyword() { "exec" } __PACKAGE__->register_with_factory; +package OpenBSD::PackingElement::ExecAlways; +our @ISA=qw(OpenBSD::PackingElement::Exec); + +sub keyword() { "exec-always" } +__PACKAGE__->register_with_factory; + +package OpenBSD::PackingElement::ExecInstall; +our @ISA=qw(OpenBSD::PackingElement::Exec); + +sub keyword() { "exec-add" } +__PACKAGE__->register_with_factory; + +package OpenBSD::PackingElement::ExecUpdate; +our @ISA=qw(OpenBSD::PackingElement::Exec); + +sub keyword() { "exec-update" } +__PACKAGE__->register_with_factory; + package OpenBSD::PackingElement::Unexec; our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); sub keyword() { "unexec" } __PACKAGE__->register_with_factory; +package OpenBSD::PackingElement::UnexecAlways; +our @ISA=qw(OpenBSD::PackingElement::Unexec); + +sub keyword() { "unexec-always" } +__PACKAGE__->register_with_factory; + +package OpenBSD::PackingElement::UnexecUpdate; +our @ISA=qw(OpenBSD::PackingElement::Unexec); + +sub keyword() { "unexec-update" } +__PACKAGE__->register_with_factory; + +package OpenBSD::PackingElement::UnexecDelete; +our @ISA=qw(OpenBSD::PackingElement::Unexec); + +sub keyword() { "unexec-delete" } +__PACKAGE__->register_with_factory; + package OpenBSD::PackingElement::ExtraUnexec; our @ISA=qw(OpenBSD::PackingElement::ExeclikeAction); diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index f31443359df..c4f2418b4b4 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Replace.pm,v 1.40 2007/06/10 15:11:05 espie Exp $ +# $OpenBSD: Replace.pm,v 1.41 2007/06/16 11:50:49 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -24,9 +24,9 @@ use OpenBSD::Interactive; package OpenBSD::PackingElement; sub can_update { - my ($self, $install, $state) = @_; + my ($self, $installing, $state) = @_; - my $issue = $self->update_issue($install); + my $issue = $self->update_issue($installing); if (defined $issue) { $state->{okay} = 0; @@ -38,7 +38,7 @@ sub validate_depend { } -sub update_issue($$) { undef } +sub update_issue { undef } sub extract { @@ -151,41 +151,52 @@ sub extract } package OpenBSD::PackingElement::ScriptFile; -sub update_issue($$) +sub update_issue { - return $_[0]->{name}." script"; + my ($self, $installing) = @_; + return $self->{name}." script"; } package OpenBSD::PackingElement::FINSTALL; -sub update_issue($$) +sub update_issue { - return if !$_[1]; - return $_[0]->SUPER::update_issue($_[1]); + my ($self, $installing) = @_; + return if !$installing; + return $self->SUPER::update_issue($installing); } package OpenBSD::PackingElement::FDEINSTALL; -sub update_issue($$) +sub update_issue { - return if $_[1]; - return $_[0]->SUPER::update_issue($_[1]); + my ($self, $installing) = @_; + return if $installing; + return $self->SUPER::update_issue($installing); } package OpenBSD::PackingElement::Exec; -sub update_issue($$) +sub update_issue { - return if !$_[1]; - return '@exec '.$_[0]->{expanded}; + my ($self, $installing) = @_; + return if !$installing; + return '@'.$self->keyword.' '.$self->{expanded}; } +package OpenBSD::PackingElement::ExecAdd; +sub update_issue { undef } + package OpenBSD::PackingElement::Unexec; -sub update_issue($$) +sub update_issue { - return if $_[1]; - my $self = $_[0]; + my ($self, $installing) = @_; + + return if $installing; - return '@unexec '.$self->{expanded}; + return '@'.$self->keyword.' '.$self->{expanded}; } +package OpenBSD::PackingElement::UnexecDelete; +sub update_issue { undef } + package OpenBSD::PackingElement::Depend; sub separate_element { |