Your message dated Mon, 24 Oct 2016 11:07:38 -0300
with message-id 
<CAAfdZj9WvPBpA7ok=8xtwhmmk3u3nussx4n5bmpssrujlgs...@mail.gmail.com>
and subject line Re: Bug#767429: dh-systemd: Please improve timer unit handling
has caused the Debian Bug report #767429,
regarding dh-systemd: Please improve timer unit handling
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
767429: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=767429
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
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 <[email protected]>
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


--- End Message ---
--- Begin Message ---
On Mon, 25 Jan 2016 23:26:27 +0100 Martin Pitt <[email protected]> wrote:
> Control: tag -1 -patch
>
> Andreas Henriksson [2014-10-30 23:59 +0100]:
> > 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.

>
> To clarify, this *only* applies to dh_systemd_start, not _enable,
> right? As such .service units should never have an [Install] section,
> only their *.timer units should have.
>
> So I wonder, does it actually make sense for dh_systemd_start to start
> units which we don't enable? This is highly inconsistent between
> "right after package install" vs. "behaviour after boot".
>
> Thus, would it not make sense to teach dh_systemd_start to ignore
> units without [Install] by default?

So, this has been implemented in i-s-h 1.23 [1]

[1] 
https://anonscm.debian.org/cgit/collab-maint/init-system-helpers.git/commit/?id=a4e43fcdabf7962d2a765b6b0e11a51734afb5f0

It may make sense to emit different maintscripts for non-installable
units (d-s-i will emit a warning on these units). However, I think
that this (new) issue is mostly cosmetic, and thus I am closing this
bug. If anyone disagrees, feel free to reopen or open a new issue.


Saludos

--- End Message ---

Reply via email to