diff options
author | Nick Potenski <nick.potenski@garmin.com> | 2022-06-15 14:32:19 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-24 23:57:46 +0100 |
commit | 0b84202a2b6d63ae65e7718bfbd4ae67ec062cd9 (patch) | |
tree | cfbecb911d6213bb6c9f8a93b76566b84f1ad1d1 /meta/recipes-core/systemd/systemd-systemctl | |
parent | ae90fa778a41dedfbf55f3f89dc8c3968b17eaaf (diff) | |
download | poky-0b84202a2b6d63ae65e7718bfbd4ae67ec062cd9.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.
(From OE-Core rev: f2d59bf2240eaf4c483edc4feb6e5d66b8dc387f)
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>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/systemd/systemd-systemctl')
-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 | |||
11 | import sys | 11 | import sys |
12 | 12 | ||
13 | from collections import namedtuple | 13 | from collections import namedtuple |
14 | from itertools import chain | ||
14 | from pathlib import Path | 15 | from pathlib import Path |
15 | 16 | ||
16 | version = 1.0 | 17 | version = 1.0 |
@@ -25,12 +26,16 @@ locations = list() | |||
25 | 26 | ||
26 | class SystemdFile(): | 27 | class SystemdFile(): |
27 | """Class representing a single systemd configuration file""" | 28 | """Class representing a single systemd configuration file""" |
28 | def __init__(self, root, path): | 29 | def __init__(self, root, path, instance_unit_name): |
29 | self.sections = dict() | 30 | self.sections = dict() |
30 | self._parse(root, path) | 31 | self._parse(root, path) |
31 | dirname = os.path.basename(path.name) + ".d" | 32 | dirname = os.path.basename(path.name) + ".d" |
32 | for location in locations: | 33 | for location in locations: |
33 | for path2 in sorted((root / location / "system" / dirname).glob("*.conf")): | 34 | files = (root / location / "system" / dirname).glob("*.conf") |
35 | if instance_unit_name: | ||
36 | inst_dirname = instance_unit_name + ".d" | ||
37 | files = chain(files, (root / location / "system" / inst_dirname).glob("*.conf")) | ||
38 | for path2 in sorted(files): | ||
34 | self._parse(root, path2) | 39 | self._parse(root, path2) |
35 | 40 | ||
36 | def _parse(self, root, path): | 41 | def _parse(self, root, path): |
@@ -193,8 +198,11 @@ class SystemdUnit(): | |||
193 | # if we're enabling an instance, first extract the actual instance | 198 | # if we're enabling an instance, first extract the actual instance |
194 | # then figure out what the template unit is | 199 | # then figure out what the template unit is |
195 | template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit) | 200 | template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit) |
201 | instance_unit_name = None | ||
196 | if template: | 202 | if template: |
197 | instance = template.group('instance') | 203 | instance = template.group('instance') |
204 | if instance != "": | ||
205 | instance_unit_name = self.unit | ||
198 | unit = re.sub(r"@[^\.]*\.", "@.", self.unit, 1) | 206 | unit = re.sub(r"@[^\.]*\.", "@.", self.unit, 1) |
199 | else: | 207 | else: |
200 | instance = None | 208 | instance = None |
@@ -206,7 +214,7 @@ class SystemdUnit(): | |||
206 | # ignore aliases | 214 | # ignore aliases |
207 | return | 215 | return |
208 | 216 | ||
209 | config = SystemdFile(self.root, path) | 217 | config = SystemdFile(self.root, path, instance_unit_name) |
210 | if instance == "": | 218 | if instance == "": |
211 | try: | 219 | try: |
212 | default_instance = config.get('Install', 'DefaultInstance')[0] | 220 | default_instance = config.get('Install', 'DefaultInstance')[0] |