summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd-systemctl
diff options
context:
space:
mode:
authorMartin Siegumfeldt <mns@gomspace.com>2023-04-28 08:59:33 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-05-05 11:07:26 +0100
commite510222b5789b1450395fbf740e932b7faef0433 (patch)
tree3fb8165b3b13acaa9e1dcfaf469b1253e266c33e /meta/recipes-core/systemd/systemd-systemctl
parent9ed46595f8bf16bbf59389240dfc25074122d78b (diff)
downloadpoky-e510222b5789b1450395fbf740e932b7faef0433.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) 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>
Diffstat (limited to 'meta/recipes-core/systemd/systemd-systemctl')
-rwxr-xr-xmeta/recipes-core/systemd/systemd-systemctl/systemctl13
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'):