summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Ray <ian.ray@ge.com>2023-06-11 21:17:47 +0300
committerSteve Sakoman <steve@sakoman.com>2023-06-21 04:00:58 -1000
commit7f8a4aa6cf240a5cdda012837f3f3f7a0f9bbf1c (patch)
treea759ce1d677f4037edd5c7915f4d6b7c64f8bfef
parent7412714f7d8af571cc066ed22f200e4009032480 (diff)
downloadpoky-7f8a4aa6cf240a5cdda012837f3f3f7a0f9bbf1c.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: 11d3f1c8252592c377ea6b92bba77ef6d9c75464) Signed-off-by: Ian Ray <ian.ray@ge.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> (cherry picked from commit 9356276137267a29ae2289d796a2940918375308) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-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 1c87beadad..c8b5c9efe3 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -190,13 +190,8 @@ class SystemdUnit():
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 193 # expand any %i to instance (ignoring escape sequence %%)
194 # instance (i.e. a '@%i') 194 dependent = re.sub("([^%](%%)*)%i", "\\1{}".format(instance), dependent)
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)
200 wants = systemdir / "{}.{}".format(dependent, dirstem) / service 195 wants = systemdir / "{}.{}".format(dependent, dirstem) / service
201 add_link(wants, target) 196 add_link(wants, target)
202 197