[initcpiocfg] Make using systemd hook optional

This commit is contained in:
dalto 2023-09-02 10:01:05 -05:00
parent 741c7b75d8
commit 7fa8fa680c
3 changed files with 28 additions and 3 deletions

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
# The initcpiocfg module is responsible for the configuration of mkinitcpio.conf. Typically this
# module is used in conjunction with the initcpio module to generate the boot image when using mkinitcpio
---
#
# Determines if the systemd versions of the hooks should be used. This is false by default.mkinitcpio
#
# Please note that using the systemd hooks result in no access to the emergency recovery shell
# useSystemdHook: false

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2023 Evan James <dalto@fastmail.com>
# SPDX-License-Identifier: GPL-3.0-or-later
---
$schema: https://json-schema.org/schema#
$id: https://calamares.io/schemas/initcpiocfg
additionalProperties: false
type: object
properties:
useSystemdHook: { type: boolean }

View File

@ -163,9 +163,12 @@ def find_initcpio_features(partitions, root_mount_point):
"block", "block",
"keyboard", "keyboard",
] ]
uses_systemd = target_env_call(["sh", "-c", "which systemd-cat"]) == 0
if uses_systemd: systemd_hook_allowed = libcalamares.job.configuration.get("useSystemdHook", False)
use_systemd = systemd_hook_allowed and target_env_call(["sh", "-c", "which systemd-cat"]) == 0
if use_systemd:
hooks.insert(0, "systemd") hooks.insert(0, "systemd")
hooks.append("sd-vconsole") hooks.append("sd-vconsole")
else: else:
@ -224,7 +227,7 @@ def find_initcpio_features(partitions, root_mount_point):
hooks.append("usr") hooks.append("usr")
if encrypt_hook: if encrypt_hook:
if uses_systemd: if use_systemd:
hooks.append("sd-encrypt") hooks.append("sd-encrypt")
else: else:
hooks.append("encrypt") hooks.append("encrypt")