1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-08 05:09:24 +00:00

systemd-systemctl: Fix WantedBy processing

An empty string assignment to WantedBy should clear all prior WantedBy
settings. This matches behavior of the current systemd implementation.

(From OE-Core rev: 8ede0083c28fadf1e83c9256618190b931edd306)

Signed-off-by: Bob Henz <robert_henz@jabil.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Bob Henz
2022-09-19 22:02:58 -04:00
committed by Richard Purdie
parent 931cc979a0
commit c653bfc68b
@@ -26,6 +26,9 @@ locations = list()
class SystemdFile():
"""Class representing a single systemd configuration file"""
_clearable_keys = ['WantedBy']
def __init__(self, root, path, instance_unit_name):
self.sections = dict()
self._parse(root, path)
@@ -80,6 +83,14 @@ class SystemdFile():
v = m.group('value')
if k not in section:
section[k] = list()
# If we come across a "key=" line for a "clearable key", then
# forget all preceding assignments. This works because we are
# processing files in correct parse order.
if k in self._clearable_keys and not v:
del section[k]
continue
section[k].extend(v.split())
def get(self, section, prop):