diff options
author | Martin Siegumfeldt <mns@gomspace.com> | 2023-05-10 09:35:56 +0200 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-05-17 04:07:13 -1000 |
commit | 2c49e1c152da0e2d632d61b35e03d87ac9627b0e (patch) | |
tree | c470946f4312d116415e6a8902386cbbae6c9ff2 /meta/recipes-core/systemd | |
parent | 5d50cbf525476caab190d005ac130bb5fff2ade7 (diff) | |
download | poky-2c49e1c152da0e2d632d61b35e03d87ac9627b0e.tar.gz |
systemd-systemctl: fix instance template WantedBy symlink construction
Fix issue of the below instance template systemd service dependency
[Install]
WantedBy=svc-wants@%i.service
creating the symlink (instance "a" example)
/etc/systemd/system/svc-wants@%i.service.wants/svc-wanted-by@a.service
which should be
/etc/systemd/system/svc-wants@a.service.wants/svc-wanted-by@a.service
as implemented by this change.
The functionality appears regressed just after "thud" baseline when the
logic was refactored from shell script into python (commit
925e30cb104ece7bfa48b78144e758a46dc9ec3f)
(From OE-Core rev: 308397f0bb3d6f3d4e9ec2c6a10823184049c9b5)
(From OE-Core rev: 372b29c8ad270d4d430c26a4e614976c7029afaf)
Signed-off-by: Martin Siegumfeldt <mns@gomspace.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-core/systemd')
-rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl index cddae75a06..b45a2dc2f7 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
@@ -195,12 +195,19 @@ class SystemdUnit(): | |||
195 | 195 | ||
196 | raise SystemdUnitNotFoundError(self.root, unit) | 196 | raise SystemdUnitNotFoundError(self.root, unit) |
197 | 197 | ||
198 | def _process_deps(self, config, service, location, prop, dirstem): | 198 | def _process_deps(self, config, service, location, prop, dirstem, instance): |
199 | systemdir = self.root / SYSCONFDIR / "systemd" / "system" | 199 | systemdir = self.root / SYSCONFDIR / "systemd" / "system" |
200 | 200 | ||
201 | target = ROOT / location.relative_to(self.root) | 201 | target = ROOT / location.relative_to(self.root) |
202 | try: | 202 | try: |
203 | for dependent in config.get('Install', prop): | 203 | for dependent in config.get('Install', prop): |
204 | # determine whether or not dependent is a template with an actual | ||
205 | # instance (i.e. a '@%i') | ||
206 | dependent_is_template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", dependent) | ||
207 | if dependent_is_template: | ||
208 | # if so, replace with the actual instance to achieve | ||
209 | # svc-wants@a.service.wants/svc-wanted-by@a.service | ||
210 | dependent = re.sub(dependent_is_template.group('instance'), instance, dependent, 1) | ||
204 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service | 211 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service |
205 | add_link(wants, target) | 212 | add_link(wants, target) |
206 | 213 | ||
@@ -240,8 +247,8 @@ class SystemdUnit(): | |||
240 | else: | 247 | else: |
241 | service = self.unit | 248 | service = self.unit |
242 | 249 | ||
243 | self._process_deps(config, service, path, 'WantedBy', 'wants') | 250 | self._process_deps(config, service, path, 'WantedBy', 'wants', instance) |
244 | self._process_deps(config, service, path, 'RequiredBy', 'requires') | 251 | self._process_deps(config, service, path, 'RequiredBy', 'requires', instance) |
245 | 252 | ||
246 | try: | 253 | try: |
247 | for also in config.get('Install', 'Also'): | 254 | for also in config.get('Install', 'Also'): |