Article View: linux.debian.bugs.dist
Article #5643Bug#889635: Patch: Bug#889635: debhelper: dh_installsystemd - please support templated unit files
From: наб
Date: Sun, 22 Nov 2026 23:30
Date: Sun, 22 Nov 2026 23:30
249 lines
10874 bytes
10874 bytes
--hfbel7rf2a2j2flr
Content-Type: multipart/mixed; boundary="7yojxkcosxyo5jee"
Content-Disposition: inline
--7yojxkcosxyo5jee
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Control: tags -1 + patch
The following MR (and patches) restarts and stops template units
in postinst and prerm respectively
https://salsa.debian.org/debian/debhelper/-/merge_requests/172
--7yojxkcosxyo5jee
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
=46rom 30e6a16d7bc6c7e459291fd7c96c1903195a1c7a Mon Sep 17 00:00:00 2001
=46rom: =3D?UTF-8?q?=3DD0=3DBD=3DD0=3DB0=3DD0=3DB1?=3D <nabijaczleweli@nabi=
jaczleweli.xyz>
Date: Sun, 22 Nov 2026 23:34:12 +0100
Subject: [PATCH 1/3] dh_installsystemd: postinst: systemctl try-reload
template-unit@*.service...
X-Mutt-PGP: OS
Sponsored-by: https://beaverlabs.net
Ref: #889635
---
dh_installsystemd | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git dh_installsystemd dh_installsystemd
index 1bf10d8..a6cd984 100755
--- dh_installsystemd
+++ dh_installsystemd
@@ -335,7 +335,7 @@ if (compat(12)) {
# installed, upgraded or removed.
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmpdir =3D tmpdir($package);
- my (@args, @start_units, @enable_units, %aliases);
+ my (@args, @start_units, @restart_units, @enable_units, %aliases);
=20
my @installed_units =3D list_installed_units($tmpdir, \%aliases);
=20
@@ -375,10 +375,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
error("Package '$package' does not install unit '$unit'.") unless (-f $=
path);
}
=20
- # Skip template service files. Enabling, disabling, starting
+ # Only restart template service files. Enabling, disabling, starting
# or stopping those services without specifying the instance
# is not useful.
- next if ($unit =3D~ /\@/);
+ if ($unit =3D~ s/@[^.]*\./@*./) {
+ push @restart_units, $unit;
+ next;
+ }
=20
# Handle all unit files specified via Also=3D explicitly. This
# is not necessary for enabling, but for disabling, as we
@@ -411,6 +414,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
=20
@enable_units =3D map { quote($_) } uniq sort @enable_units;
@start_units =3D map { quote($_) } uniq sort @start_units;
+ @restart_units =3D map { quote($_) } uniq sort @restart_units;
=20
my %options =3D ('snippet-order' =3D> 'service');
=20
@@ -422,6 +426,11 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
autoscript($package, 'postrm', 'postrm-systemd', {'UNITFILES' =3D> join(=
' ', @enable_units) });
}
=20
+ if (not $dh{NOSCRIPTS} and $dh{RESTART_AFTER_UPGRADE} and @restart_units)=
{
+ my $replace =3D { 'UNITFILES' =3D> join(' ', @restart_units), 'RESTART_A=
CTION' =3D> 'try-restart' };
+ autoscript($package, 'postinst', 'postinst-systemd-restartnostart', $rep=
lace, \%options);
+ }
+
if (not $dh{NOSCRIPTS} and @start_units) {
my $replace =3D { 'UNITFILES' =3D> join(' ', @start_units) };
=20
--=20
2.39.5
--7yojxkcosxyo5jee
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
=46rom 02a1b6ded9aa57bba1db6daa4255871e07763df3 Mon Sep 17 00:00:00 2001
=46rom: =3D?UTF-8?q?=3DD0=3DBD=3DD0=3DB0=3DD0=3DB1?=3D <nabijaczleweli@nabi=
jaczleweli.xyz>
Date: Sun, 22 Nov 2026 23:37:56 +0100
Subject: [PATCH 2/3] autoscripts/postinst-systemd-*start: systemctl
daemon-reload at most once
X-Mutt-PGP: OS
We can now insert p-s-restartnostart before any of the others,
reloading multiple times doesn't give us anything and is slow
Sponsored-by: https://beaverlabs.net
---
autoscripts/postinst-systemd-restart | 5 ++++-
autoscripts/postinst-systemd-restartnostart | 5 ++++-
autoscripts/postinst-systemd-start | 5 ++++-
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git autoscripts/postinst-systemd-restart autoscripts/postinst-system=
d-restart
index 9a8fa43..f9e21bf 100644
--- autoscripts/postinst-systemd-restart
+++ autoscripts/postinst-systemd-restart
@@ -1,6 +1,9 @@
if [ "$1" =3D "configure" ] || [ "$1" =3D "abort-upgrade" ] || [ "$1" =3D =
"abort-deconfigure" ] || [ "$1" =3D "abort-remove" ] ; then
if [ -z "$DPKG_ROOT" ] && [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
+ if [ -z "$_dh_systemd_daemon_reloaded" ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ _dh_systemd_daemon_reloaded=3Dy
+ fi
if [ -n "$2" ]; then
_dh_action=3D#RESTART_ACTION#
else
diff --git autoscripts/postinst-systemd-restartnostart autoscripts/postinst=
-systemd-restartnostart
index 261606b..d0dec58 100644
--- autoscripts/postinst-systemd-restartnostart
+++ autoscripts/postinst-systemd-restartnostart
@@ -1,6 +1,9 @@
if [ "$1" =3D "configure" ] || [ "$1" =3D "abort-upgrade" ] || [ "$1" =3D =
"abort-deconfigure" ] || [ "$1" =3D "abort-remove" ] ; then
if [ -z "$DPKG_ROOT" ] && [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
+ if [ -z "$_dh_systemd_daemon_reloaded" ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ _dh_systemd_daemon_reloaded=3Dy
+ fi
if [ -n "$2" ]; then
deb-systemd-invoke #RESTART_ACTION# #UNITFILES# >/dev/null || true
fi
diff --git autoscripts/postinst-systemd-start autoscripts/postinst-systemd-=
start
index 951e47a..8de4f87 100644
--- autoscripts/postinst-systemd-start
+++ autoscripts/postinst-systemd-start
@@ -1,6 +1,9 @@
if [ "$1" =3D "configure" ] || [ "$1" =3D "abort-upgrade" ] || [ "$1" =3D =
"abort-deconfigure" ] || [ "$1" =3D "abort-remove" ] ; then
if [ -z "$DPKG_ROOT" ] && [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
+ if [ -z "$_dh_systemd_daemon_reloaded" ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ _dh_systemd_daemon_reloaded=3Dy
+ fi
deb-systemd-invoke start #UNITFILES# >/dev/null || true
fi
fi
--=20
2.39.5
--7yojxkcosxyo5jee
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
=46rom 1bc85b14eaa7e318d338286af221358aad05c451 Mon Sep 17 00:00:00 2001
=46rom: =3D?UTF-8?q?=3DD0=3DBD=3DD0=3DB0=3DD0=3DB1?=3D <nabijaczleweli@nabi=
jaczleweli.xyz>
Date: Mon, 23 Nov 2026 00:01:43 +0100
Subject: [PATCH 3/3] dh_installsystemd: prerm: also stop template units
X-Mutt-PGP: OS
Sponsored-by: https://beaverlabs.net
Closes: #889635
---
dh_installsystemd | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git dh_installsystemd dh_installsystemd
index a6cd984..b3bc700 100755
--- dh_installsystemd
+++ dh_installsystemd
@@ -431,6 +431,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
autoscript($package, 'postinst', 'postinst-systemd-restartnostart', $rep=
lace, \%options);
}
=20
+ if (not $dh{NOSCRIPTS} and (@start_units or @restart_units)) {
+ my $replace =3D { 'UNITFILES' =3D> join(' ', (@start_units, @restart_uni=
ts)) };
+
+ # stop service only on remove
+ autoscript($package, 'prerm', 'prerm-systemd-restart', $replace, \%optio=
ns);
+ }
+
if (not $dh{NOSCRIPTS} and @start_units) {
my $replace =3D { 'UNITFILES' =3D> join(' ', @start_units) };
=20
@@ -453,9 +460,6 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
autoscript($package, 'preinst', 'preinst-systemd-stop', $replace, \%opti=
ons)
unless ($dh{R_FLAG} || $dh{RESTART_AFTER_UPGRADE});
=20
- # stop service only on remove
- autoscript($package, 'prerm', 'prerm-systemd-restart', $replace, \%optio=
ns);
-
# Run this with "default" order so it is always after other
# service related autosnippets.
autoscript($package, 'postrm', 'postrm-systemd-reload-only', $replace);
--=20
2.39.5
--7yojxkcosxyo5jee--
--hfbel7rf2a2j2flr
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmsDeAoACgkQvP0LAY0m
WPGiPg//QMxteI+FqlRpfX5dnIl0ysyWgeww/UygnG7bYlR5cG7FTT4+6TqgnQnt
OCaRrKUTUeFDnv1WgA+n+QgilQsx0i2J7TQS2TlW9xfcTqUMA6M+e8DkhmAuV3lt
YJg9ykZOk2Lkxzid+Ni0oXPPF8keDSEgpXqGj8dkJlsga9S9RCkV9N1PG+Xq+Ide
iuoNsVdeks7AqtO3YQLHrrElkSGcC6m75tvhwXI3LrzrROb9v4/Ciy3W21CNUj3h
+7YmHURWVPE5eMCprqpD5HMLrtlodRVduT/ieoLqg4BnVOuBg1jag8sZGh0JWHT7
8/Qj5cXMrVYP5ag7GG3EG5eXdI9qI9eomE9aCrsgOmRsmLwyqVppubqlP+AZJtgX
Gho2c2goQjDMj4wbHWkuS7fRBJzk4Zkgkj5L+38aeX2rxFiDQx2Ps1/2X4xKpYvr
Yo17VujkqCqmsny2onpP1STwvHbDIlOvgB+ph/crLdy70IESsmmK/1+IQ0pzd12V
OfWNKM252Daihvl+1QeZo7UKbvr1htxohXOjdv1UgC145TMKLH1+4hZcZxo6FI83
tPLFKP9g0fgGdOym7fDp5Grx7mZMi99wUQ/Zp9rnmmJl2R9x63zb7Qobi8v/kYcK
m+V/BojhYV4M/A0rzNDqaS13grFLO9NoBMgFHIq0V3CsHH0NZko=
=hVyD
-----END PGP SIGNATURE-----
--hfbel7rf2a2j2flr--
Technical Details
Message-ID:
<O2pap-dyGm-1@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!bofh.it!news.nic.it!robomodReferences:
<vfKk1-6ho-5@gated-at.bofh.it> <vfKk1-6ho-5@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!bofh.it!news.nic.it!robomod From: наб <nabijaczleweli@nabijaczleweli.xyz> Newsgroups: linux.debian.bugs.dist Subject: Bug#889635: Patch: Bug#889635: debhelper: dh_installsystemd - please support templated unit files Date: Mon, 23 Nov 2026 00:30:01 +0100 Message-ID: <O2pap-dyGm-1@gated-at.bofh.it> References: <vfKk1-6ho-5@gated-at.bofh.it> <vfKk1-6ho-5@gated-at.bofh.it> X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Sun Nov 22 23:25:13 2026 Old-Return-Path: <debbugs@buxtehude.debian.org> X-Spam-Flag: NO X-Spam-Score: -0.942 Reply-To: наб <nabijaczleweli@nabijaczleweli.xyz>, 889635@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: debhelper@packages.debian.org X-Debian-Pr-Message: followup 889635 X-Debian-Pr-Package: debhelper X-Debian-Pr-Source: debhelper MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hfbel7rf2a2j2flr" Content-Disposition: inline User-Agent: NeoMutt/20231221-2-4202cf-dirty X-Greylist: delayed 316 seconds by postgrey-1.37 at buxtehude; Sun, 22 Nov 2026 23:22:54 UTC X-Debian-Message: from BTS X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2004284 List-ID: <debian-bugs-dist.lists.debian.org> List-URL: <https://lists.debian.org/debian-bugs-dist/> Approved: robomod@news.nic.it Lines: 249 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Mon, 23 Nov 2026 00:17:36 +0100 X-Original-Message-ID: <jdhnojzv37qnhljv2hwuic2qylt4yrx7tdbzwspeaqkbws3mze@tarta.nabijaczleweli.xyz> X-Original-References: <151781897764.13330.6925730084731145890.reportbug@alice.fifthhorseman.net> <151781897764.13330.6925730084731145890.reportbug@alice.fifthhorseman.net>