diff options
author | Martin Siegumfeldt <mns@gomspace.com> | 2023-05-10 09:35:56 +0200 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-06-27 05:24:36 -1000 |
commit | 822d364542d986f79b13475c62d9b08da433f273 (patch) | |
tree | 93589f354f5ddb109134b162bb095d10cbbb9d59 /meta/recipes-core | |
parent | b01dd27a8d7d4ced9d761eff2bc6d639108f132f (diff) | |
download | poky-822d364542d986f79b13475c62d9b08da433f273.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: 2751472807edc6d2ccc93b6339e6dc57d4abb2da)
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>
Diffstat (limited to 'meta/recipes-core')
-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 6aa2e20465..577c373181 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
@@ -182,12 +182,19 @@ class SystemdUnit(): | |||
182 | 182 | ||
183 | raise SystemdUnitNotFoundError(self.root, unit) | 183 | raise SystemdUnitNotFoundError(self.root, unit) |
184 | 184 | ||
185 | def _process_deps(self, config, service, location, prop, dirstem): | 185 | def _process_deps(self, config, service, location, prop, dirstem, instance): |
186 | systemdir = self.root / SYSCONFDIR / "systemd" / "system" | 186 | systemdir = self.root / SYSCONFDIR / "systemd" / "system" |
187 | 187 | ||
188 | target = ROOT / location.relative_to(self.root) | 188 | target = ROOT / location.relative_to(self.root) |
189 | try: | 189 | try: |
190 | for dependent in config.get('Install', prop): | 190 | for dependent in config.get('Install', prop): |
191 | # determine whether or not dependent is a template with an actual | ||
192 | # instance (i.e. a '@%i') | ||
193 | dependent_is_template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", dependent) | ||
194 | if dependent_is_template: | ||
195 | # if so, replace with the actual instance to achieve | ||
196 | # svc-wants@a.service.wants/svc-wanted-by@a.service | ||
197 | dependent = re.sub(dependent_is_template.group('instance'), instance, dependent, 1) | ||
191 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service | 198 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service |
192 | add_link(wants, target) | 199 | add_link(wants, target) |
193 | 200 | ||
@@ -227,8 +234,8 @@ class SystemdUnit(): | |||
227 | else: | 234 | else: |
228 | service = self.unit | 235 | service = self.unit |
229 | 236 | ||
230 | self._process_deps(config, service, path, 'WantedBy', 'wants') | 237 | self._process_deps(config, service, path, 'WantedBy', 'wants', instance) |
231 | self._process_deps(config, service, path, 'RequiredBy', 'requires') | 238 | self._process_deps(config, service, path, 'RequiredBy', 'requires', instance) |
232 | 239 | ||
233 | try: | 240 | try: |
234 | for also in config.get('Install', 'Also'): | 241 | for also in config.get('Install', 'Also'): |