summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd-systemctl
diff options
context:
space:
mode:
authorIan Ray <ian.ray@ge.com>2023-06-11 21:17:47 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-06-15 09:53:38 +0100
commitf457f358dfc05dea8e3a7e5add56e22a2cea2a73 (patch)
tree79a6615288d0063deb2230273d1215e6876ef85c /meta/recipes-core/systemd/systemd-systemctl
parentdc03dac76911975b486769185b482a07b60613c8 (diff)
downloadpoky-f457f358dfc05dea8e3a7e5add56e22a2cea2a73.tar.gz
systemd-systemctl: support instance expansion in WantedBy
Refactor _process_deps to expand systemd instance specifier "%i" to the template instance. This change expands on prior commit e510222b57 ("systemd-systemctl: fix instance template WantedBy symlink construction") by substituting every "%i" pattern-match with the instance name. The regexp handles the following cases: * svc-wants@%i.service * sys-subsystem-net-devices-%i.device (From OE-Core rev: 9356276137267a29ae2289d796a2940918375308) Signed-off-by: Ian Ray <ian.ray@ge.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/systemctl9
1 files changed, 2 insertions, 7 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index b45a2dc2f7..514f747fe6 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -201,13 +201,8 @@ class SystemdUnit():
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 204 # expand any %i to instance (ignoring escape sequence %%)
205 # instance (i.e. a '@%i') 205 dependent = re.sub("([^%](%%)*)%i", "\\1{}".format(instance), dependent)
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)
211 wants = systemdir / "{}.{}".format(dependent, dirstem) / service 206 wants = systemdir / "{}.{}".format(dependent, dirstem) / service
212 add_link(wants, target) 207 add_link(wants, target)
213 208