[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
This commit is contained in:
parent
73ecd7320c
commit
1957478618
@ -35,18 +35,25 @@ def systemctl(targets, command, suffix):
|
|||||||
silently.
|
silently.
|
||||||
"""
|
"""
|
||||||
for svc in targets:
|
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(
|
ec = libcalamares.utils.target_env_call(
|
||||||
['systemctl', command, "{}{}".format(svc['name'], suffix)]
|
['systemctl', command, "{}{}".format(name, suffix)]
|
||||||
)
|
)
|
||||||
|
|
||||||
if ec != 0:
|
if ec != 0:
|
||||||
if svc['mandatory']:
|
if mandatory:
|
||||||
return ("Cannot {} systemd {} {}".format(command, suffix, svc['name']),
|
return ("Cannot {} systemd {} {}".format(command, suffix, name),
|
||||||
"systemctl {} call in chroot returned error code {}".format(command, ec)
|
"systemctl {} call in chroot returned error code {}".format(command, ec)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.warning(
|
libcalamares.utils.warning(
|
||||||
"Cannot {} systemd {} {}".format(command, suffix, svc['name'])
|
"Cannot {} systemd {} {}".format(command, suffix, name)
|
||||||
)
|
)
|
||||||
libcalamares.utils.warning(
|
libcalamares.utils.warning(
|
||||||
"systemctl {} call in chroot returned error code {}".format(command, ec)
|
"systemctl {} call in chroot returned error code {}".format(command, ec)
|
||||||
|
@ -17,7 +17,12 @@
|
|||||||
# - *mandatory* is a boolean option, which states whether the change
|
# - *mandatory* is a boolean option, which states whether the change
|
||||||
# must be done successfully. If systemd reports an error while changing
|
# must be done successfully. If systemd reports an error while changing
|
||||||
# a mandatory entry, the installation will fail. When mandatory is false,
|
# 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.
|
# Use [] to express an empty list.
|
||||||
|
|
||||||
@ -44,7 +49,9 @@
|
|||||||
# mandatory: false
|
# mandatory: false
|
||||||
#
|
#
|
||||||
# # Disables <name>.target
|
# # Disables <name>.target
|
||||||
# disable-targets: []
|
# # .. this shows how to use just the name
|
||||||
|
# disable-targets:
|
||||||
|
# - graphical
|
||||||
#
|
#
|
||||||
# # Masks (stronger version of disable). This section
|
# # Masks (stronger version of disable). This section
|
||||||
# # is unusual because you **must** include the suffix
|
# # is unusual because you **must** include the suffix
|
||||||
|
Loading…
Reference in New Issue
Block a user