#1105915 debhelper: dh_installsystemd should follow dh_installcron logic instead of dh_installinit

Package:
debhelper
Source:
debhelper
Submitter:
Martin-Éric Racine
Date:
2025-05-19 11:27:02 UTC
Severity:
normal
Tags:
#1105915#5
Date:
2025-05-17 08:42:21 UTC
From:
To:
In its current form, dh_installsystemd installs debian/package.unit which essentially follows dh_installinit logic.

This doesn't work for packages that ship multiple units, especially timers. For instance, src:apt ships the following units via bin:apt:

apt-daily.service
apt-daily.timer
apt-daily-upgrade.service
apt-daily-upgrade.timer

They have to be manually installed via debian/apt.install because dh_installsystemd cannot deal with filenames that deviate from the package.unit format.

A better logic would be something similar to dh_installcron:

apt.apt-daily.service
apt.apt-daily.timer
apt.apt-daily-upgrade.service
apt.apt-daily-upgrade.timer

This would enable specifying which of the binary targets should ship the files.

Basically, if there are package.unit files, ship them with package. If there are package.*.unit files, ship them with the binary target specified before the first period.

Martin-Éric

#1105915#10
Date:
2025-05-19 05:25:49 UTC
From:
To:
Martin-Éric Racine:

Hi Martin-Éric,

I understand were you are coming from, but I do not understand the
reference to `dh_installcron` in this. As far as I can tell,
`dh_installcron` finds the files with the same limitations as
`dh_installsystemd`.

For what it is worth, I believe you can use `--name` with both scripts
to use `<package>.<name>.<stem>`. I think the hardest part of this for
`dh_installsystemd` is that is generate snippets as well, where
`dh_installcron` does not. This is why `dh_installsystemd` cannot just
glob all the units because you might deliberately want to call
`dh_installsystemd` to have different rules for each unit.


Note it is one of the things I am trying to solve better with `debputy`,
but I am not convinced the changes can be ported to `debhelper` since
the snippet generation (and similar) rely on relevant tool being called
multiple times.

Best regards,
Niels

#1105915#17
Date:
2025-05-19 09:57:14 UTC
From:
To:
Hi Niels,
ma 19.5.2025 klo 8.26 Niels Thykier (niels@thykier.net) kirjoitti:

Using --name is a kludge. It requires separately naming the target
package via an override in debian/rules and successive runs for each
target.  Meanwhile, the syntax 'target.foo.helper' is supported by
most other helpers but, for some reason, not this one. This is what's
needed.

Martin-Éric

#1105915#22
Date:
2025-05-19 10:30:41 UTC
From:
To:
Martin-Éric Racine:

I agree. I do not like `--name` either.

Correct. I have this as one of my reasons for why I do not like it as well.

However, given the design of `debhelper` there is no good way to avoid
this pattern when the file name also triggers maintscript code to be
added where the maintainer has choices to make for said maintscripts,
which is the case for `dh_installsystemd`.

You and I might not like this particular aspect of the design, but it is
the design choice of `debhelper` + its commands at this point. It has
non-trivial consequences to change at this point.

This statement I disagree with. I am aware of 0 helpers provided by
`debhelper` that automatically respond to that file-naming convention
without the use of `--name` for installing d/pkg.$NAME.foo.
   The closest we have it  `dh_installdocs` that uses
`debian/pkg.doc-base.$SUFFIX` rather than `debian/pkg.$NAME.doc-base`
for some historical reason (that is it uses a custom naming convention).
But very importantly there are no maintscripts are needed for `doc-base`
files and the code has specialized custom logic for `doc-base` files
that cannot be generalized to other cases. In that sense,
`dh_installdocs` is the odd one out.

As for `dh_installcron`, which you used as an example in your opening
mail, then it does *not* support this either. What is "special" about
`dh_installcron` is that it has a list of ~5 different stems containing
"." in them. There is no smart globbing or logic for finding
"foo.name.cron.hourly" and installing it into "foo" as
"/etc/cron.hourly/name"... This only works when people use `--name`,
which is meh.

Best regards,
Niels

#1105915#27
Date:
2025-05-19 10:54:18 UTC
From:
To:
ma 19.5.2025 klo 13.30 Niels Thykier (niels@thykier.net) kirjoitti:

$ ls -1 debian/
[...]
dhcpcd-base.examples
dhcpcd-base.install
dhcpcd-base.postinst
dhcpcd-base.postrm
dhcpcd.dhcpcd.init
dhcpcd.dhcpcd.service
dhcpcd.dhcpcd@.service
dhcpcd.lintian-overrides
dhcpcd.preinst
[...]

See these, for instance. debhelper applies them according to their
prefix to targets dhcpcd-base and dhcpcd, respectively.

Martin-Éric

#1105915#32
Date:
2025-05-19 11:09:41 UTC
From:
To:
Martin-Éric Racine:


You have completely lost me. Can you please spell out what exactly is
the behavior you see and what would you like to have seen instead.
Preferably without using other helpers as a baseline, since that is
apparently not helping me understand the problem.

Best regards,
Niels