Skip to content

Commit b637a46

Browse files
committed
Fix WantedBy processing
An empty string assignment to WantedBy should clear all prior WantedBy settings. This matches behavior of the current systemd implementation. Signed-off-by: Bob Henz <[email protected]>
1 parent 68b07bb commit b637a46

File tree

1 file changed

+11
-0
lines changed
  • meta/recipes-core/systemd/systemd-systemctl

1 file changed

+11
-0
lines changed

meta/recipes-core/systemd/systemd-systemctl/systemctl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ locations = list()
2626

2727
class SystemdFile():
2828
"""Class representing a single systemd configuration file"""
29+
30+
_clearable_keys = ['WantedBy']
31+
2932
def __init__(self, root, path, instance_unit_name):
3033
self.sections = dict()
3134
self._parse(root, path)
@@ -80,6 +83,14 @@ class SystemdFile():
8083
v = m.group('value')
8184
if k not in section:
8285
section[k] = list()
86+
87+
# If we come across a "key=" line for a "clearable key", then
88+
# forget all preceding assignments. This works because we are
89+
# processing files in correct parse order.
90+
if k in self._clearable_keys and not v:
91+
del section[k]
92+
continue
93+
8394
section[k].extend(v.split())
8495

8596
def get(self, section, prop):

0 commit comments

Comments
 (0)