diff options
author | Nick Potenski <nick.potenski@garmin.com> | 2022-06-15 14:32:19 -0500 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2022-06-20 05:12:46 -1000 |
commit | f2d59bf2240eaf4c483edc4feb6e5d66b8dc387f (patch) | |
tree | 512fff0bd0f1f1d96a37f97a7d2b6272faa7bc05 | |
parent | 12169c1104adbfd9f5196fdbdab16536e98fd43f (diff) | |
download | openembedded-core-f2d59bf2240eaf4c483edc4feb6e5d66b8dc387f.tar.gz |
systemd: systemd-systemctl: Support instance conf files during enable
Add ability to parse instance-specific conf files when
enabling an instance of a templated unit during postinstall.
Signed-off-by: Nick Potenski <nick.potenski@garmin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit baa0ecf3271008cf60cd830c54a71f191aebb81c)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rwxr-xr-x | meta/recipes-core/systemd/systemd-systemctl/systemctl | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl index 990de1ab39..6aa2e20465 100755 --- a/meta/recipes-core/systemd/systemd-systemctl/systemctl +++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl @@ -11,6 +11,7 @@ import re import sys from collections import namedtuple +from itertools import chain from pathlib import Path version = 1.0 @@ -25,12 +26,16 @@ locations = list() class SystemdFile(): """Class representing a single systemd configuration file""" - def __init__(self, root, path): + def __init__(self, root, path, instance_unit_name): self.sections = dict() self._parse(root, path) dirname = os.path.basename(path.name) + ".d" for location in locations: - for path2 in sorted((root / location / "system" / dirname).glob("*.conf")): + files = (root / location / "system" / dirname).glob("*.conf") + if instance_unit_name: + inst_dirname = instance_unit_name + ".d" + files = chain(files, (root / location / "system" / inst_dirname).glob("*.conf")) + for path2 in sorted(files): self._parse(root, path2) def _parse(self, root, path): @@ -193,8 +198,11 @@ class SystemdUnit(): # if we're enabling an instance, first extract the actual instance # then figure out what the template unit is template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit) + instance_unit_name = None if template: instance = template.group('instance') + if instance != "": + instance_unit_name = self.unit unit = re.sub(r"@[^\.]*\.", "@.", self.unit, 1) else: instance = None @@ -206,7 +214,7 @@ class SystemdUnit(): # ignore aliases return - config = SystemdFile(self.root, path) + config = SystemdFile(self.root, path, instance_unit_name) if instance == "": try: default_instance = config.get('Install', 'DefaultInstance')[0] |