summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd-systemctl
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2021-05-31 19:11:57 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-06-01 14:03:49 +0100
commit20026c7246c43da7f71eee3a930ac2f3a8a0884b (patch)
tree8c5fc39f709191c66768561f9f0a5632c2c02351 /meta/recipes-core/systemd/systemd-systemctl
parent13ed11d90995d60255fa4a7868a3f93d3c16f87a (diff)
downloadpoky-20026c7246c43da7f71eee3a930ac2f3a8a0884b.tar.gz
systemctl: Stop tracebacks use formated error messages
When systemctl fail it would throw an exception and dump a traceback. Lets use a more controlled workflow. [Yocto #14395] (From OE-Core rev: df510ae9a1494bc1be8d6673fbaa43d3f7cc8f40) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/systemd/systemd-systemctl')
-rwxr-xr-xmeta/recipes-core/systemd/systemd-systemctl/systemctl24
1 files changed, 19 insertions, 5 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index de733e255b..e8c3d2d1ee 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -160,7 +160,9 @@ def add_link(path, target):
160 160
161 161
162class SystemdUnitNotFoundError(Exception): 162class SystemdUnitNotFoundError(Exception):
163 pass 163 def __init__(self, path, unit):
164 self.path = path
165 self.unit = unit
164 166
165 167
166class SystemdUnit(): 168class SystemdUnit():
@@ -224,7 +226,10 @@ class SystemdUnit():
224 226
225 try: 227 try:
226 for also in config.get('Install', 'Also'): 228 for also in config.get('Install', 'Also'):
227 SystemdUnit(self.root, also).enable() 229 try:
230 SystemdUnit(self.root, also).enable()
231 except SystemdUnitNotFoundError as e:
232 sys.exit("Error: Systemctl also enable issue with %s (%s)" % (service, e.unit))
228 233
229 except KeyError: 234 except KeyError:
230 pass 235 pass
@@ -265,7 +270,10 @@ def preset_all(root):
265 state = presets.state(service) 270 state = presets.state(service)
266 271
267 if state == "enable" or state is None: 272 if state == "enable" or state is None:
268 SystemdUnit(root, service).enable() 273 try:
274 SystemdUnit(root, service).enable()
275 except SystemdUnitNotFoundError:
276 sys.exit("Error: Systemctl preset_all issue in %s" % service)
269 277
270 # If we populate the systemd links we also create /etc/machine-id, which 278 # If we populate the systemd links we also create /etc/machine-id, which
271 # allows systemd to boot with the filesystem read-only before generating 279 # allows systemd to boot with the filesystem read-only before generating
@@ -307,10 +315,16 @@ def main():
307 315
308 if command == "mask": 316 if command == "mask":
309 for service in args.service: 317 for service in args.service:
310 SystemdUnit(root, service).mask() 318 try:
319 SystemdUnit(root, service).mask()
320 except SystemdUnitNotFoundError as e:
321 sys.exit("Error: Systemctl main mask issue in %s (%s)" % (service, e.unit))
311 elif command == "enable": 322 elif command == "enable":
312 for service in args.service: 323 for service in args.service:
313 SystemdUnit(root, service).enable() 324 try:
325 SystemdUnit(root, service).enable()
326 except SystemdUnitNotFoundError as e:
327 sys.exit("Error: Systemctl main enable issue in %s (%s)" % (service, e.unit))
314 elif command == "preset-all": 328 elif command == "preset-all":
315 if len(args.service) != 0: 329 if len(args.service) != 0:
316 sys.exit("Too many arguments.") 330 sys.exit("Too many arguments.")