From 1957478618257944e1a67244b1448c562c3127ed Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 27 Jun 2018 11:25:11 -0400 Subject: [PATCH] [services-systemd] Follow the flexible example of openrc - Make *mandatory* optional (and default to false); this allows shorter lists of entries - Allow degenerate entries which are just a name (which have *mandatory* set to false as well). SEE #992 --- src/modules/services-systemd/main.py | 15 +++++++++++---- .../services-systemd/services-systemd.conf | 11 +++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/modules/services-systemd/main.py b/src/modules/services-systemd/main.py index 54a731cf8..09263b9f0 100644 --- a/src/modules/services-systemd/main.py +++ b/src/modules/services-systemd/main.py @@ -35,18 +35,25 @@ def systemctl(targets, command, suffix): silently. """ for svc in targets: + if isinstance(svc, str): + name = svc + mandatory = False + else: + name = svc["name"] + mandatory = svc.get("mandatory", False) + ec = libcalamares.utils.target_env_call( - ['systemctl', command, "{}{}".format(svc['name'], suffix)] + ['systemctl', command, "{}{}".format(name, suffix)] ) if ec != 0: - if svc['mandatory']: - return ("Cannot {} systemd {} {}".format(command, suffix, svc['name']), + if mandatory: + return ("Cannot {} systemd {} {}".format(command, suffix, name), "systemctl {} call in chroot returned error code {}".format(command, ec) ) else: libcalamares.utils.warning( - "Cannot {} systemd {} {}".format(command, suffix, svc['name']) + "Cannot {} systemd {} {}".format(command, suffix, name) ) libcalamares.utils.warning( "systemctl {} call in chroot returned error code {}".format(command, ec) diff --git a/src/modules/services-systemd/services-systemd.conf b/src/modules/services-systemd/services-systemd.conf index 082d63657..6ff1409bf 100644 --- a/src/modules/services-systemd/services-systemd.conf +++ b/src/modules/services-systemd/services-systemd.conf @@ -17,7 +17,12 @@ # - *mandatory* is a boolean option, which states whether the change # must be done successfully. If systemd reports an error while changing # a mandatory entry, the installation will fail. When mandatory is false, -# errors for that entry (service or target) are ignored. +# errors for that entry (service or target) are ignored. If mandatory +# is not specified, the default is false. +# +# An entry may also be given as a single string, which is then +# interpreted as the name of the service. In this case, mandatory +# is also set to the default of false. # # Use [] to express an empty list. @@ -44,7 +49,9 @@ # mandatory: false # # # Disables .target -# disable-targets: [] +# # .. this shows how to use just the name +# disable-targets: +# - graphical # # # Masks (stronger version of disable). This section # # is unusual because you **must** include the suffix