diff --git a/src/modules/initcpiocfg/initcpiocfg.conf b/src/modules/initcpiocfg/initcpiocfg.conf index fc226ec84..281767026 100644 --- a/src/modules/initcpiocfg/initcpiocfg.conf +++ b/src/modules/initcpiocfg/initcpiocfg.conf @@ -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, , bogus +# initially, and then removes that hook again. +# +hooks: + prepend: [ bogus ] + append: [ bogus ] + remove: [ bogus ] diff --git a/src/modules/initcpiocfg/initcpiocfg.schema.yaml b/src/modules/initcpiocfg/initcpiocfg.schema.yaml index f071e79aa..487da529f 100644 --- a/src/modules/initcpiocfg/initcpiocfg.schema.yaml +++ b/src/modules/initcpiocfg/initcpiocfg.schema.yaml @@ -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 } diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 13a281bb3..bbc403a9c 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -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 diff --git a/src/modules/initcpiocfg/test.yaml b/src/modules/initcpiocfg/test.yaml new file mode 100644 index 000000000..f832bec91 --- /dev/null +++ b/src/modules/initcpiocfg/test.yaml @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +rootMountPoint: /tmp/mount +partitions: + - fs: ext4 + mountPoint: "/" +