Bug#801822: deb-systemd-helper does not support template units (e.g. foo@.service)
Control: tags -1 - patch On Thu, 03 Feb 2022 16:44:28 +0100 Victor Westerhuis wrote: I've opened a merge request on Salsa with another possible fix. It works for me locally, but I would like any feedback if I made a mistake somewhere. I've attached the patch as an attachment and the MR is at https://salsa.debian.org/debian/init-system-helpers/-/merge_requests/20. The MR was merged, but I realise now that the original bug is about manipulating instances of template units, which is not what my patch addressed. I've removed the patch tag from this bug report. -- Victor Westerhuis OpenPGP_signature Description: OpenPGP digital signature
Bug#801822: deb-systemd-helper does not support template units (e.g. foo@.service)
Package: init-system-helpers Version: 1.61 Followup-For: Bug #801822 Control: tags -1 patch I've opened a merge request on Salsa with another possible fix. It works for me locally, but I would like any feedback if I made a mistake somewhere. I've attached the patch as an attachment and the MR is at https://salsa.debian.org/debian/init-system-helpers/-/merge_requests/20. -- System Information: Debian Release: bookworm/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (100, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.15.0-3-amd64 (SMP w/4 CPU threads) Locale: LANG=en_NL.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en_US:en:nl_NL:nl Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) Versions of packages init-system-helpers depends on: ii perl-base 5.32.1-6 init-system-helpers recommends no packages. init-system-helpers suggests no packages. Versions of packages init-system-helpers is related to: pn insserv -- no debconf information -- debsums errors found: debsums: changed file /usr/sbin/update-rc.d (from init-system-helpers package) diff --git a/script/deb-systemd-helper b/script/deb-systemd-helper index 7e929ed..c27e5da 100755 --- a/script/deb-systemd-helper +++ b/script/deb-systemd-helper @@ -192,8 +192,11 @@ sub get_link_closure { my ($scriptname, $service_path) = @_; my @links; +my @wants_dirs; my $unit_name = basename($service_path); +my $template = $unit_name =~ /\@\.\w+$/; +my $default_instance = $unit_name unless $template; # The keys parsed from the unit file below can only have unit names # as values. Since unit names can't have whitespace in systemd, @@ -210,7 +213,7 @@ sub get_link_closure { my $wants_dir = "/etc/systemd/$instance/$value"; $wants_dir .= '.wants' if $1 eq 'WantedBy'; $wants_dir .= '.requires' if $1 eq 'RequiredBy'; -push @links, { dest => $service_path, src => "$wants_dir/$scriptname" }; +push @wants_dirs, "$wants_dir/"; } } @@ -231,9 +234,20 @@ sub get_link_closure { } } } + +if ($template && $line =~ /^\s*DefaultInstance=\s*(["']?+)(.+)\g1\s*$/i) { +$default_instance = $2; +$default_instance = $unit_name =~ s/^(.*\@)(\.\w+)$/$1$default_instance$2/r; +} } close($fh); +if ($default_instance) { +for my $wants_dir (@wants_dirs) { +push @links, { dest => $service_path, src => $wants_dir . $default_instance }; +} +} + return @links; }
Bug#801822: deb-systemd-helper does not support template units (e.g. foo@.service)
Control: tags -1 confirmed On Wed, 14 Oct 2015 19:28:25 -0300 Antonio Terceirowrote: > Package: init-system-helpers > Version: 1.24 > Severity: normal > > `deb-systemd-helper enable foo@1.service` will not work even if the > corresponding foo@.service is correctly in place. > > Use case: in the new version of debci, you will be able to run multiple > worker instances on each system, but by default I want to enable and > start the first one in postinst. > > I hope I understand how all of this is supposed to work, so I am > currently doing it like this: > > http://anonscm.debian.org/cgit/collab-maint/debci.git/commit/?id=cef32ff04680607a4e41a9673649e8320f649c95 > > Are we supposed to have packages managing instanciated template units > like this? I can confirm deb-systemd-* do not support instanced templated units, and this is a pretty big hole. Patches to make it work welcome. Saludos
Bug#801822: deb-systemd-helper does not support template units (e.g. foo@.service)
Package: init-system-helpers Version: 1.24 Severity: normal `deb-systemd-helper enable foo@1.service` will not work even if the corresponding foo@.service is correctly in place. Use case: in the new version of debci, you will be able to run multiple worker instances on each system, but by default I want to enable and start the first one in postinst. I hope I understand how all of this is supposed to work, so I am currently doing it like this: http://anonscm.debian.org/cgit/collab-maint/debci.git/commit/?id=cef32ff04680607a4e41a9673649e8320f649c95 Are we supposed to have packages managing instanciated template units like this? -- System Information: Debian Release: stretch/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 4.2.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=pt_BR.UTF-8, LC_CTYPE=pt_BR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages init-system-helpers depends on: ii perl-base 5.20.2-6 init-system-helpers recommends no packages. init-system-helpers suggests no packages. -- no debconf information -- Antonio Terceirosignature.asc Description: PGP signature