diff options
| author | Martin Siegumfeldt <mns@gomspace.com> | 2023-05-10 09:35:56 +0200 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-05-30 04:11:15 -1000 |
| commit | d81118899de01bd4d15b823a8627eeead8309726 (patch) | |
| tree | 37f64df8c607b0eed8a1923fe197144ad6c9369b | |
| parent | 9a514e19fa2ba17d80858e8d797ad2e58696409c (diff) | |
| download | poky-d81118899de01bd4d15b823a8627eeead8309726.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: e572d096e81bb7dba8a07ee9dba93d0944857212)
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>
(cherry picked from commit 372b29c8ad270d4d430c26a4e614976c7029afaf)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -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 6d19666d82..1c87beadad 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
| @@ -184,12 +184,19 @@ class SystemdUnit(): | |||
| 184 | 184 | ||
| 185 | raise SystemdUnitNotFoundError(self.root, unit) | 185 | raise SystemdUnitNotFoundError(self.root, unit) |
| 186 | 186 | ||
| 187 | def _process_deps(self, config, service, location, prop, dirstem): | 187 | def _process_deps(self, config, service, location, prop, dirstem, instance): |
| 188 | systemdir = self.root / SYSCONFDIR / "systemd" / "system" | 188 | systemdir = self.root / SYSCONFDIR / "systemd" / "system" |
| 189 | 189 | ||
| 190 | target = ROOT / location.relative_to(self.root) | 190 | target = ROOT / location.relative_to(self.root) |
| 191 | try: | 191 | try: |
| 192 | for dependent in config.get('Install', prop): | 192 | for dependent in config.get('Install', prop): |
| 193 | # determine whether or not dependent is a template with an actual | ||
| 194 | # instance (i.e. a '@%i') | ||
| 195 | dependent_is_template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", dependent) | ||
| 196 | if dependent_is_template: | ||
| 197 | # if so, replace with the actual instance to achieve | ||
| 198 | # svc-wants@a.service.wants/svc-wanted-by@a.service | ||
| 199 | dependent = re.sub(dependent_is_template.group('instance'), instance, dependent, 1) | ||
| 193 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service | 200 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service |
| 194 | add_link(wants, target) | 201 | add_link(wants, target) |
| 195 | 202 | ||
| @@ -229,8 +236,8 @@ class SystemdUnit(): | |||
| 229 | else: | 236 | else: |
| 230 | service = self.unit | 237 | service = self.unit |
| 231 | 238 | ||
| 232 | self._process_deps(config, service, path, 'WantedBy', 'wants') | 239 | self._process_deps(config, service, path, 'WantedBy', 'wants', instance) |
| 233 | self._process_deps(config, service, path, 'RequiredBy', 'requires') | 240 | self._process_deps(config, service, path, 'RequiredBy', 'requires', instance) |
| 234 | 241 | ||
| 235 | try: | 242 | try: |
| 236 | for also in config.get('Install', 'Also'): | 243 | for also in config.get('Install', 'Also'): |
