diff --git a/src/modules/dracut/dracut.conf b/src/modules/dracut/dracut.conf index 98d847d9e..ae5d85022 100644 --- a/src/modules/dracut/dracut.conf +++ b/src/modules/dracut/dracut.conf @@ -5,6 +5,6 @@ --- # Dracut defaults to setting initramfs-.img # If you want to specify another filename for the resulting image, -# set a custom kernel name, including the path +# set a custom name, including the path # -# kernelName: /boot/initramfs-linux.img +# initramfsName: /boot/initramfs-linux.img diff --git a/src/modules/dracut/dracut.schema.yaml b/src/modules/dracut/dracut.schema.yaml index 503b1a4f0..d6008e1bf 100644 --- a/src/modules/dracut/dracut.schema.yaml +++ b/src/modules/dracut/dracut.schema.yaml @@ -6,4 +6,4 @@ $id: https://calamares.io/schemas/dracut additionalProperties: false type: object properties: - kernelName: { type: string } + initramfsName: { type: string } diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py index 071406580..85e6f3e7f 100644 --- a/src/modules/dracut/main.py +++ b/src/modules/dracut/main.py @@ -12,9 +12,10 @@ # # Calamares is Free Software: see the License-Identifier above. # +import subprocess import libcalamares -from libcalamares.utils import check_target_env_call +from libcalamares.utils import target_env_process_output import gettext @@ -34,12 +35,20 @@ def run_dracut(): :return: """ - kernelName = libcalamares.job.configuration['kernelName'] + try: + initramfs_name = libcalamares.job.configuration['initramfsName'] + target_env_process_output(['dracut', '-f', initramfs_name]) + except KeyError: + try: + target_env_process_output(['dracut', '-f']) + except subprocess.CalledProcessError as cpe: + libcalamares.utils.warning(f"Dracut failed with output: {cpe.output}") + return cpe.returncode + except subprocess.CalledProcessError as cpe: + libcalamares.utils.warning(f"Dracut failed with output: {cpe.output}") + return cpe.returncode - if not kernelName: - return check_target_env_call(['dracut', '-f']) - else: - return check_target_env_call(['dracut', '-f', '{}'.format(kernelName)]) + return 0 def run(): @@ -50,7 +59,6 @@ def run(): :return: """ return_code = run_dracut() - if return_code != 0: - return (_("Failed to run dracut on the target"), - _("The exit code was {}").format(return_code)) + return (_("Failed to run dracut"), + _(f"Dracut failed to run on the target with return code: {return_code}"))