🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.debian.bugs.dist
1 messages
1 total messages Started by наб Sun, 22 Nov 2026 23:30
Bug#889635: Patch: Bug#889635: debhelper: dh_installsystemd - please support templated unit files
#5643
Author: наб
Date: Sun, 22 Nov 2026 23:30
249 lines
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--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads