Package: dh-systemd Version: 1.21 Severity: wishlist Dear Maintainer,
I've looked at how to make a package where upstream installs systemd service and timer units to not start the service during package postinst. I could do this with override_dh_systemd_start: dh_systemd_start --no-start myunit.service but that didn't really accomplish what I wanted and there where no "dh_systemd_start --remaining" like other debhelpers offer. (If I have to manually list each and every unit explicitly that will likely lead to me missing to update it when a new one gets added upstream.) I'm now wondering if it possible to always make the assumption that if something ships a timer unit, then it never wants the matching service unit started (other then by the timer) ?.... I've made a patch for that, please see attachment and excuse my lack of perl knowledge. (It would also be useful to me if similar would be possible for services that has a socket unit, and I'd only like them to be socket activated. c.f. uuid-runtime's uuidd.socket / uuidd.service which always gets started on package upgrade.) Regards, Andreas Henriksson PS. dh_systemd_start contains a comment talking about dh_installsystemd which I assume is an old leftover which needs updating. Also the --no-also option seems to be undocumented. PPS. Thanks for the readable perl-code! Even someone with lack of proper perl skills could understand it. -- System Information: Debian Release: jessie/sid APT prefers testing-updates APT policy: (500, 'testing-updates'), (500, 'testing'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.16-3-amd64 (SMP w/4 CPU cores) Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages dh-systemd depends on: ii debhelper 9.20141003 ii perl 5.20.1-1 dh-systemd recommends no packages. Versions of packages dh-systemd suggests: ii augeas-tools 1.2.0-0.2 -- no debconf information
>From d1e8450e4c53a24189384b7bb72f91e25df2c4ab Mon Sep 17 00:00:00 2001 From: Andreas Henriksson <andr...@fatal.se> Date: Thu, 30 Oct 2014 22:47:31 +0100 Subject: [PATCH] Do not start services with a matching timer unit --- script/dh_systemd_start | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/script/dh_systemd_start b/script/dh_systemd_start index 297f9c5..7586dc8 100755 --- a/script/dh_systemd_start +++ b/script/dh_systemd_start @@ -52,6 +52,11 @@ Do not stop service on upgrade. Do not start the unit file after upgrades and after initial installation (the latter is only relevant for services without a corresponding init script). +=item B<--no-omit-timer-services> + +By default, dh_systemd_start will omit services that has a matching timer unit. +Using this flag means the service file will not be skipped. + =back =head1 NOTES @@ -74,6 +79,7 @@ init(options => { "no-start" => \$dh{NO_START}, "R|restart-after-upgrade" => \$dh{RESTART_AFTER_UPGRADE}, "no-also" => \$dh{NO_ALSO}, + "no-omit-timer-services" => \$dh{NO_OMIT_TIMER_SERVICES}, }); # Extracts the Also= or Alias= line(s) from a unit file. @@ -139,6 +145,17 @@ foreach my $package (@{$dh{DOPACKAGES}}) { # loop. my %seen; + # Remove all service units that has a matching timer unit. + # The assumption is that service units only wants to be started by their timer. + if (!$dh{NO_OMIT_TIMER_SERVICES}) { + foreach my $omitservice (@_ = grep(/\.timer$/i, @args)) { + $omitservice =~ s/\.timer$/\.service/; + for (reverse(grep { $args[$_] eq $omitservice } 0..$#args)) { + splice(@args, $_, 1); + } + }; + } + # We use while/shift because we push to the list in the body. while (@args) { my $name = shift @args; -- 2.1.1