From f16da0fde7b20b363a3bf360da53e219e396acee Mon Sep 17 00:00:00 2001
From: demmm <anke62@gmail.com>
Date: Fri, 2 Sep 2022 21:53:42 +0200
Subject: [PATCH] [dracut] add option to make the kernel name configurable

---
 src/modules/dracut/dracut.conf | 10 ++++++++++
 src/modules/dracut/main.py     | 14 ++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 src/modules/dracut/dracut.conf

diff --git a/src/modules/dracut/dracut.conf b/src/modules/dracut/dracut.conf
new file mode 100644
index 0000000000..98d847d9e2
--- /dev/null
+++ b/src/modules/dracut/dracut.conf
@@ -0,0 +1,10 @@
+# SPDX-FileCopyrightText: no
+# SPDX-License-Identifier: CC0-1.0
+#
+# Run dracut(8) with an optional kernel name
+---
+# Dracut defaults to setting initramfs-<kernel-version>.img
+# If you want to specify another filename for the resulting image,
+# set a custom kernel name, including the path
+#
+# kernelName: /boot/initramfs-linux.img
diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py
index 392dd8a519..32f9a842ea 100644
--- a/src/modules/dracut/main.py
+++ b/src/modules/dracut/main.py
@@ -7,13 +7,14 @@
 #   SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
 #   SPDX-FileCopyrightText: 2017 Alf Gaida <agaid@siduction.org>
 #   SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
+#   SPDX-FileCopyrightText: 2022 Anke Boersma <demm@kaosx.us>
 #   SPDX-License-Identifier: GPL-3.0-or-later
 #
 #   Calamares is Free Software: see the License-Identifier above.
 #
 
 import libcalamares
-from libcalamares.utils import target_env_call
+from libcalamares.utils import check_target_env_call
 
 
 import gettext
@@ -33,7 +34,12 @@ def run_dracut():
 
     :return:
     """
-    return target_env_call(['dracut', '-f'])
+    kernelName = libcalamares.job.configuration['kernelName']
+
+    if kernelName != 0:
+        return check_target_env_call(['dracut', '-f', '{}'.format(kernelName)])
+    else:
+        return check_target_env_call(['dracut', '-f'])
 
 
 def run():
@@ -46,5 +52,5 @@ def run():
     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 on the target"),
+                _("The exit code was {}").format(return_code))
-- 
GitLab