diff options
author | Ian Ray <ian.ray@ge.com> | 2023-06-11 21:17:47 +0300 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-06-27 05:24:36 -1000 |
commit | c8f5ff0ffe6b11e3b50656438136ee08c9616ab2 (patch) | |
tree | 79a3b7ec91356acff4ae3446977031cfcc87e672 /meta/recipes-core | |
parent | 822d364542d986f79b13475c62d9b08da433f273 (diff) | |
download | poky-c8f5ff0ffe6b11e3b50656438136ee08c9616ab2.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: 2aa82324d43467e7c8bfbbb59570ee3306264b75)
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>
Diffstat (limited to 'meta/recipes-core')
-rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 9 |
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 577c373181..b890bdd6f0 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl | |||
@@ -188,13 +188,8 @@ class SystemdUnit(): | |||
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 | 191 | # expand any %i to instance (ignoring escape sequence %%) |
192 | # instance (i.e. a '@%i') | 192 | dependent = re.sub("([^%](%%)*)%i", "\\1{}".format(instance), dependent) |
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) | ||
198 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service | 193 | wants = systemdir / "{}.{}".format(dependent, dirstem) / service |
199 | add_link(wants, target) | 194 | add_link(wants, target) |
200 | 195 | ||