[initcpiocfg] Support additional hooks-munging

FIXES #2200
This commit is contained in:
Adriaan de Groot 2024-06-10 22:16:56 +02:00
parent 48554cf310
commit 19b0f28f16
4 changed files with 43 additions and 2 deletions

View File

@ -9,3 +9,22 @@
#
# Please note that using the systemd hooks result in no access to the emergency recovery shell
useSystemdHook: false
#
# Modifications to the standard list of hooks.
#
# There are three subkeys:
# - prepend, which puts hooks at the beginning of the
# list of hooks, in the order specified here,
# - append, which adds hooks at the end of the list of
# hooks, in the order specified here,
# - remove, which removes hooks from the list of hooks,
# wherever they may be.
#
# The example configuration here yields bogus, <stuff>, bogus
# initially, and then removes that hook again.
#
hooks:
prepend: [ bogus ]
append: [ bogus ]
remove: [ bogus ]

View File

@ -7,5 +7,10 @@ additionalProperties: false
type: object
properties:
useSystemdHook: { type: boolean }
hooks:
type: object
additionalProperties: false
properties:
prepend: { type: array, items: string }
append: { type: array, items: string }
remove: { type: array, items: string }

View File

@ -168,6 +168,13 @@ def find_initcpio_features(partitions, root_mount_point):
hooks.append("keymap")
hooks.append("consolefont")
hooks_map = libcalamares.job.configuration.get("hooks", None)
if not hooks_map:
hooks_map = dict()
hooks_prepend = hooks_map.get("prepend", None) or []
hooks_append = hooks_map.get("append", None) or []
hooks_remove = hooks_map.get("remove", None) or []
modules = []
files = []
binaries = []
@ -240,6 +247,9 @@ def find_initcpio_features(partitions, root_mount_point):
else:
hooks.append("fsck")
# Modify according to the keys in the configuration
hooks = [h for h in (hooks_prepend + hooks + hooks_append) if h not in hooks_remove]
return hooks, modules, files, binaries

View File

@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
rootMountPoint: /tmp/mount
partitions:
- fs: ext4
mountPoint: "/"