[initcpiocfg] Allow alternate source file

This is possibly only interesting for testing purposes.
This commit is contained in:
Adriaan de Groot 2024-06-10 22:33:29 +02:00
parent 19b0f28f16
commit f651fc9bff
3 changed files with 10 additions and 1 deletions

View File

@ -28,3 +28,11 @@ hooks:
prepend: [ bogus ]
append: [ bogus ]
remove: [ bogus ]
#
# In some cases, you may want to use a different source
# file than /etc/mkinitcpio.conf , e.g. because the live system
# does not match the target in a useful way. If unset or
# empty, defaults to /etc/mkinitcpio.conf
#
source: "/etc/mkinitcpio.conf"

View File

@ -14,3 +14,4 @@ properties:
prepend: { type: array, items: string }
append: { type: array, items: string }
remove: { type: array, items: string }
source: { type: string }

View File

@ -97,7 +97,7 @@ def get_host_initcpio():
the lines from that file, or an empty list if it does
not exist.
"""
hostfile = "/etc/mkinitcpio.conf"
hostfile = libcalamares.job.configuration.get("source", None) or "/etc/mkinitcpio.conf"
try:
with open(hostfile, "r") as mkinitcpio_file:
mklins = [x.strip() for x in mkinitcpio_file.readlines()]