summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-06-18 20:21:46 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-06-18 20:23:33 +0200
commit0069bdd868524c67529f99fbd7dd5609560eee52 (patch)
tree17c12d8e62d7c5a8054a9efb3749bf1bd4d9dda3
parent4e227ef57a1870522a653665a8b201770e49f13c (diff)
downloadinit-system-helpers-0069bdd868524c67529f99fbd7dd5609560eee52.tar.gz
remove dh_systemd_disable, this edge case will be handled in maintscripts
To clarify: the edge case is that there is a socket-activated service which has a name for the .socket file that diverges from the basename of the init script. In our case, that is syslog.socket vs. /etc/init.d/rsyslog.
-rw-r--r--Makefile.PL1
-rw-r--r--debian/dh-systemd.install1
-rw-r--r--lib/Debian/Debhelper/Sequence/systemd.pm5
-rwxr-xr-xscript/dh_systemd_disable199
-rwxr-xr-xscript/dh_systemd_enable5
5 files changed, 3 insertions, 208 deletions
diff --git a/Makefile.PL b/Makefile.PL
index ace67ed..ba4bf71 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,7 +5,6 @@ version '1.0';
install_script 'deb-systemd-helper';
install_script 'dh_systemd_enable';
-install_script 'dh_systemd_disable';
install_script 'dh_systemd_start';
postamble <<'END_OF_MAKEFILE';
diff --git a/debian/dh-systemd.install b/debian/dh-systemd.install
index 7bd92b2..da265a0 100644
--- a/debian/dh-systemd.install
+++ b/debian/dh-systemd.install
@@ -1,6 +1,5 @@
usr/bin/dh_systemd_start
usr/bin/dh_systemd_enable
-usr/bin/dh_systemd_disable
usr/share/perl5/Debian/Debhelper/Sequence/systemd.pm
usr/share/debhelper/autoscripts
usr/share/man/man1/dh_systemd_start.1p
diff --git a/lib/Debian/Debhelper/Sequence/systemd.pm b/lib/Debian/Debhelper/Sequence/systemd.pm
index 2ef92e6..bbaa405 100644
--- a/lib/Debian/Debhelper/Sequence/systemd.pm
+++ b/lib/Debian/Debhelper/Sequence/systemd.pm
@@ -11,9 +11,4 @@ insert_before("dh_installinit", "dh_systemd_enable");
# script, so it runs after dh_installinit.
insert_after("dh_installinit", "dh_systemd_start");
-# The prerm and postrm autoscripts are written in reverse order by debhelper,
-# so dh_systemd_disable needs to run after dh_installinit to have its
-# autoscript run before dh_installinit’s.
-insert_after("dh_installinit", "dh_systemd_disable");
-
1
diff --git a/script/dh_systemd_disable b/script/dh_systemd_disable
deleted file mode 100755
index 904ff4f..0000000
--- a/script/dh_systemd_disable
+++ /dev/null
@@ -1,199 +0,0 @@
-#!/usr/bin/perl -w
-
-=head1 NAME
-
-dh_systemd_disable - disable systemd unit files
-
-=cut
-
-use strict;
-use Debian::Debhelper::Dh_Lib;
-use File::Find;
-use Text::ParseWords qw(shellwords); # in core since Perl 5
-
-=head1 SYNOPSIS
-
-B<dh_systemd_disable> [S<I<debhelper options>>] [B<--disable-in-prerm>] [S<I<unit file> ...>]
-
-=head1 DESCRIPTION
-
-B<dh_systemd_disable> is a debhelper program that is responsible for disabling
-systemd unit files.
-
-In the simple case, it finds all unit files installed by a package (e.g.
-bacula-fd.service) and disables them. It is not necessary that the machine
-actually runs systemd during package installation time, enabling happens on all
-machines in order to be able to switch from sysvinit to systemd and back.
-
-In the complex case, you can call B<dh_systemd_disable> and B<dh_systemd_start>
-manually (by overwriting the debian/rules targets) and specify flags per unit
-file. An example is colord, which ships colord.service, a dbus-activated
-service without an [Install] section. This service file cannot be disabled or
-disabled (a state called "static" by systemd) because it has no
-[Install] section. Therefore, running dh_systemd_disable does not make sense.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<--disable-in-prerm>
-
-Call deb-systemd-helper disable in prerm in addition to postrm (calling it in
-postrm is the default). The postrm case always stays so we can delete state
-files at package purge time.
-
-This is necessary in cases where stopping the service can only be done after
-the service file has been disabled. As an example, take rsyslog: due to its
-socket activation, it would get re-enabled immediately when trying to stop it
-as long as there is something on your machine writing to syslog. Even worse,
-this actually makes the stop call fail. Using --disable-in-prerm helps here.
-
-We cannot make this flag the default behavior because for other cases it breaks
-things, e.g. when you have a systemd service file which is called differently
-than the corresponding init script and uses Alias= to handle that behavior
-(e.g. NetworkManager).
-
-=item B<-r>, B<--no-restart-on-upgrade>
-
-Do not stop service on upgrade.
-
-=back
-
-
-=head1 NOTES
-
-Note that this command is not idempotent. L<dh_prep(1)> should be called
-between invocations of this command (with the same arguments). Otherwise, it
-may cause multiple instances of the same text to be added to maintainer
-scripts.
-
-Note that B<dh_systemd_disable> should be run after B<dh_installinit>.
-The default sequence in B<dh> does the right thing, this note is only relevant
-when you are calling B<dh_systemd_after> manually.
-
-=cut
-
-init(options => {
- "disable-in-prerm" => \$dh{DISABLE_IN_PRERM},
-});
-
-foreach my $package (@{$dh{DOPACKAGES}}) {
- my $tmpdir = tmpdir($package);
- my @installed_units;
- my @units;
-
- # XXX: This is duplicated in dh_installinit, which is unfortunate.
- # We do need the service files before running dh_installinit though,
- # every other solution makes things much worse for all the maintainers.
-
- # Figure out what filename to install it as.
- my $script;
- my $jobfile=$package;
- if (defined $dh{NAME}) {
- $jobfile=$script=$dh{NAME};
- }
- elsif ($dh{D_FLAG}) {
- # -d on the command line sets D_FLAG. We will
- # remove a trailing 'd' from the package name and
- # use that as the name.
- $script=$package;
- if ($script=~m/(.*)d$/) {
- $jobfile=$script=$1;
- }
- else {
- warning("\"$package\" has no final d' in its name, but -d was specified.");
- }
- }
- elsif ($dh{INIT_SCRIPT}) {
- $script=$dh{INIT_SCRIPT};
- }
- else {
- $script=$package;
- }
-
- my $service=pkgfile($package,"service");
- if ($service ne '') {
- my $path="$tmpdir/lib/systemd/system";
- if (! -d "$path") {
- doit("install","-d","$path");
- }
-
- doit("install","-p","-m644",$service,"$path/$script.service");
- }
-
- my $tmpfile=pkgfile($package,"tmpfile");
- if ($tmpfile ne '') {
- my $path="$tmpdir/usr/lib/tmpfiles.d";
- if (! -d "$path") {
- doit("install","-d","$path");
- }
-
- doit("install","-p","-m644",$tmpfile,"$path/$script.conf");
- }
-
- find({
- wanted => sub {
- my $name = $File::Find::name;
- return unless -f $name;
- return unless $name =~ m,^$tmpdir/lib/systemd/system/[^/]+$,;
- push @installed_units, $name;
- },
- no_chdir => 1,
- }, $tmpdir);
-
- # Handle either only the unit files which were passed as arguments or
- # all unit files that are installed in this package.
- my @args = @ARGV > 0 ? @ARGV : @installed_units;
-
- # We use while/shift because we push to the list in the body.
- for my $name (@args) {
- my $base = basename($name);
-
- # Try to make the path absolute, so that the user can call
- # dh_installsystemd bacula-fd.service
- if ($base eq $name) {
- # NB: This works because @installed_units contains
- # files from precisely one directory.
- my ($full) = grep { basename($_) eq $base } @installed_units;
- if (defined($full)) {
- $name = $full;
- } else {
- warning(qq|Could not find "$name" in the /lib/systemd/system of $package.| .
- qq|This could be a typo, or using Also= with a service file from another package.| .
- qq|Please check carefully that this message is harmless.|);
- }
- }
-
- # Skip template service files like e.g. getty@.service.
- # Enabling, disabling, starting or stopping those services
- # without specifying the instance (e.g. getty@ttyS0.service) is
- # not useful.
- if ($name =~ /\@/) {
- next;
- }
-
- push @units, $name;
- }
-
- next if @units == 0;
-
- my $unitargs = join(" ", map { basename($_) } @units);
- if ($dh{DISABLE_IN_PRERM}) {
- autoscript($package, "prerm", "postrm-systemd", "s/#UNITFILES#/$unitargs/");
- }
- autoscript($package, "postrm", "postrm-systemd", "s/#UNITFILES#/$unitargs/");
-
- # init-system-helpers ships deb-systemd-helper which we use in our
- # autoscripts
- addsubstvar($package, "misc:Depends", "init-system-helpers");
-}
-
-=head1 SEE ALSO
-
-L<dh_systemd_enable(1)>, L<dh_systemd_start(1)>, L<debhelper(7)>
-
-=head1 AUTHORS
-
-pkg-systemd-maintainers@lists.alioth.debian.org
-
-=cut
diff --git a/script/dh_systemd_enable b/script/dh_systemd_enable
index 5865dc6..b4cb291 100755
--- a/script/dh_systemd_enable
+++ b/script/dh_systemd_enable
@@ -2,7 +2,7 @@
=head1 NAME
-dh_systemd_enable - enable systemd unit files
+dh_systemd_enable - enable/disable systemd unit files
=cut
@@ -148,6 +148,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
my $unitargs = join(" ", map { basename($_) } @units);
autoscript($package, "postinst", "postinst-systemd-enable", "s/#UNITFILES#/$unitargs/");
+ autoscript($package, "postrm", "postrm-systemd", "s/#UNITFILES#/$unitargs/");
# init-system-helpers ships deb-systemd-helper which we use in our
# autoscripts
@@ -156,7 +157,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
=head1 SEE ALSO
-L<dh_systemd_start(1)>, L<dh_systemd_disable(1)>, L<debhelper(7)>
+L<dh_systemd_start(1)>, L<debhelper(7)>
=head1 AUTHORS