From bdd1161a517a59bf76cd9626b760a51cfa849ed5 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Fri, 22 Nov 2024 16:53:01 -0600 Subject: [PATCH] [dracut] Add an options setting for additional Dracut parameters. --- debian/changelog | 1 + debian/patches/dracut-params.patch | 130 +++++++++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 132 insertions(+) create mode 100644 debian/patches/dracut-params.patch diff --git a/debian/changelog b/debian/changelog index dfed9e9..48eb5e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ calamares (3.3.12-0ubuntu1) UNRELEASED; urgency=medium * New upstream release. + * [dracut] Add an options setting for additional Dracut parameters. -- Simon Quigley Fri, 22 Nov 2024 16:48:30 -0600 diff --git a/debian/patches/dracut-params.patch b/debian/patches/dracut-params.patch new file mode 100644 index 0000000..0f11957 --- /dev/null +++ b/debian/patches/dracut-params.patch @@ -0,0 +1,130 @@ +From 119f3fb4bda07634aad9b6c6c3790cfb8253ebb0 Mon Sep 17 00:00:00 2001 +From: Simon Quigley +Date: Fri, 22 Nov 2024 16:36:22 -0600 +Subject: [PATCH 1/3] [dracut] Add an options setting for additional Dracut + parameters + +--- + src/modules/dracut/dracut.conf | 5 +++++ + src/modules/dracut/dracut.schema.yaml | 1 + + src/modules/dracut/main.py | 23 +++++++++++++++-------- + 3 files changed, 21 insertions(+), 8 deletions(-) + +diff --git a/src/modules/dracut/dracut.conf b/src/modules/dracut/dracut.conf +index ba1a7b08cb..c3f0c2469c 100644 +--- a/src/modules/dracut/dracut.conf ++++ b/src/modules/dracut/dracut.conf +@@ -8,3 +8,8 @@ + # set a custom name, including the path + # + initramfsName: /boot/initramfs-freebsd.img ++ ++# Optional: define a list of strings to be passed as arguments to Dracut ++# By default, -f is always included ++options: ++ - "-f" +diff --git a/src/modules/dracut/dracut.schema.yaml b/src/modules/dracut/dracut.schema.yaml +index d6008e1bf5..de1114ccc9 100644 +--- a/src/modules/dracut/dracut.schema.yaml ++++ b/src/modules/dracut/dracut.schema.yaml +@@ -7,3 +7,4 @@ additionalProperties: false + type: object + properties: + initramfsName: { type: string } ++ options: { type: array, items: { type: string } } +diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py +index 85e6f3e7ff..e987373879 100644 +--- a/src/modules/dracut/main.py ++++ b/src/modules/dracut/main.py +@@ -35,15 +35,22 @@ def run_dracut(): + + :return: + """ ++ # Fetch the job configuration ++ cli_options = ["-f"] ++ initramfs_name = libcalamares.job.configuration.get('initramfsName', None) ++ dracut_options = libcalamares.job.configuration.get('options', []) ++ ++ # Parse the custom options if there are any ++ for option in dracut_options: ++ # Deduplication check ++ if option not in cli_options: ++ cli_options.append(option) ++ ++ if initramfs_name: ++ cli_options.append(initramfs_name) ++ + 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 ++ target_env_process_output(['dracut'] + cli_options) + except subprocess.CalledProcessError as cpe: + libcalamares.utils.warning(f"Dracut failed with output: {cpe.output}") + return cpe.returncode + +From 8ea29c271f38a80290a0981b8f51eb5d9f2d25a8 Mon Sep 17 00:00:00 2001 +From: Simon Quigley +Date: Fri, 22 Nov 2024 19:46:32 -0600 +Subject: [PATCH 2/3] [dracut] Ensure the user can remove -f but it stays as + the default + +--- + src/modules/dracut/main.py | 13 +++---------- + 1 file changed, 3 insertions(+), 10 deletions(-) + +diff --git a/src/modules/dracut/main.py b/src/modules/dracut/main.py +index e987373879..9e2bc318f5 100644 +--- a/src/modules/dracut/main.py ++++ b/src/modules/dracut/main.py +@@ -36,21 +36,14 @@ def run_dracut(): + :return: + """ + # Fetch the job configuration +- cli_options = ["-f"] + initramfs_name = libcalamares.job.configuration.get('initramfsName', None) +- dracut_options = libcalamares.job.configuration.get('options', []) +- +- # Parse the custom options if there are any +- for option in dracut_options: +- # Deduplication check +- if option not in cli_options: +- cli_options.append(option) ++ dracut_options = libcalamares.job.configuration.get('options', ['-f']) + + if initramfs_name: +- cli_options.append(initramfs_name) ++ dracut_options.append(initramfs_name) + + try: +- target_env_process_output(['dracut'] + cli_options) ++ target_env_process_output(['dracut'] + dracut_options) + except subprocess.CalledProcessError as cpe: + libcalamares.utils.warning(f"Dracut failed with output: {cpe.output}") + return cpe.returncode + +From 3151eb7c8244020adc594635154c5bb714027dbb Mon Sep 17 00:00:00 2001 +From: Simon Quigley +Date: Fri, 22 Nov 2024 19:47:15 -0600 +Subject: [PATCH 3/3] [dracut] Stylistic update for conf file list + +--- + src/modules/dracut/dracut.conf | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/src/modules/dracut/dracut.conf b/src/modules/dracut/dracut.conf +index c3f0c2469c..190933bcdd 100644 +--- a/src/modules/dracut/dracut.conf ++++ b/src/modules/dracut/dracut.conf +@@ -11,5 +11,4 @@ initramfsName: /boot/initramfs-freebsd.img + + # Optional: define a list of strings to be passed as arguments to Dracut + # By default, -f is always included +-options: +- - "-f" ++options: [ "-f" ] diff --git a/debian/patches/series b/debian/patches/series index 07ddcd3..fde10cd 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,4 @@ apport-package-hook.patch enable-only-present-with-encryption-partitions.patch grub-debconf-config.patch +dracut-params.patch