mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
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>
This commit is contained in:
@@ -201,13 +201,8 @@ class SystemdUnit():
|
|||||||
target = ROOT / location.relative_to(self.root)
|
target = ROOT / location.relative_to(self.root)
|
||||||
try:
|
try:
|
||||||
for dependent in config.get('Install', prop):
|
for dependent in config.get('Install', prop):
|
||||||
# determine whether or not dependent is a template with an actual
|
# expand any %i to instance (ignoring escape sequence %%)
|
||||||
# instance (i.e. a '@%i')
|
dependent = re.sub("([^%](%%)*)%i", "\\1{}".format(instance), dependent)
|
||||||
dependent_is_template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", dependent)
|
|
||||||
if dependent_is_template:
|
|
||||||
# if so, replace with the actual instance to achieve
|
|
||||||
# svc-wants@a.service.wants/svc-wanted-by@a.service
|
|
||||||
dependent = re.sub(dependent_is_template.group('instance'), instance, dependent, 1)
|
|
||||||
wants = systemdir / "{}.{}".format(dependent, dirstem) / service
|
wants = systemdir / "{}.{}".format(dependent, dirstem) / service
|
||||||
add_link(wants, target)
|
add_link(wants, target)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user