From 438e0c6575235e7a5d795c34569b7df6cfca8283 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Thu, 17 Aug 2023 11:13:19 +0600 Subject: [PATCH 01/12] Updated the initcpiocfg module Added systemd (I took the code from CachyOS and modified it a bit) Fixed the error "setfont: KDFONTOP: Function not implemented" --- src/modules/initcpiocfg/main.py | 44 ++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 57dc5e432..b825ea7a3 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -36,6 +36,13 @@ def detect_plymouth(): # Used to only check existence of path /usr/bin/plymouth in target return target_env_call(["sh", "-c", "which plymouth"]) == 0 +def detect_systemd(): + """ + Checks existence (runnability) of systemd in the target system. + @return True if systemd exists in the target, False otherwise + """ + # Used to only check existence of path /usr/bin/systemd-cat in target + return target_env_call(["sh", "-c", "which systemd-cat"]) == 0 class cpuinfo(object): """ @@ -108,7 +115,7 @@ def get_host_initcpio(): return mklins -def write_mkinitcpio_lines(hooks, modules, files, root_mount_point): +def write_mkinitcpio_lines(hooks, modules, files, binaries, root_mount_point): """ Set up mkinitcpio.conf. @@ -122,10 +129,12 @@ def write_mkinitcpio_lines(hooks, modules, files, root_mount_point): target_path = os.path.join(root_mount_point, "etc/mkinitcpio.conf") with open(target_path, "w") as mkinitcpio_file: for line in mklins: - # Replace HOOKS, MODULES and FILES lines with what we + # Replace HOOKS, MODULES, BINARIES and FILES lines with what we # have found via find_initcpio_features() if line.startswith("HOOKS"): line = 'HOOKS="{!s}"'.format(' '.join(hooks)) + elif line.startswith("BINARIES"): + line = 'BINARIES="{!s}"'.format(' '.join(binaries)) elif line.startswith("MODULES"): line = 'MODULES="{!s}"'.format(' '.join(modules)) elif line.startswith("FILES"): @@ -145,18 +154,29 @@ def find_initcpio_features(partitions, root_mount_point): :return 3-tuple of lists """ hooks = [ - "base", - "udev", "autodetect", "kms", "modconf", "block", "keyboard", - "keymap", - "consolefont", ] + uses_systemd = detect_systemd() + + if uses_systemd: + hooks.insert(0, "systemd") + hooks.append("sd-vconsole") + else: + hooks.insert(0, "udev") + hooks.insert(0, "base") + hooks.append("keymap") + hooks.append("consolefont") + modules = [] files = [] + binaries = [] + + # Fixes "setfont: KDFONTOP: Function not implemented" error + binaries.append("setfont") swap_uuid = "" uses_btrfs = False @@ -201,9 +221,15 @@ def find_initcpio_features(partitions, root_mount_point): if encrypt_hook: if detect_plymouth() and unencrypted_separate_boot: - hooks.append("plymouth-encrypt") + if uses_systemd: + hooks.append("sd-encrypt") + else: + hooks.append("plymouth-encrypt") else: - hooks.append("encrypt") + if uses_systemd: + hooks.append("sd-encrypt") + else: + hooks.append("encrypt") crypto_file = "crypto_keyfile.bin" if not unencrypted_separate_boot and \ os.path.isfile( @@ -251,6 +277,6 @@ def run(): _("No root mount point for
initcpiocfg
.")) hooks, modules, files = find_initcpio_features(partitions, root_mount_point) - write_mkinitcpio_lines(hooks, modules, files, root_mount_point) + write_mkinitcpio_lines(hooks, modules, files, binaries, root_mount_point) return None From 5769c9c6da618aaac9c07672caf47b9aeed472f2 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Thu, 17 Aug 2023 12:44:13 +0600 Subject: [PATCH 02/12] Fixes https://github.com/calamares/calamares/issues/2182 --- src/modules/initcpiocfg/main.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index b825ea7a3..af3c56fdd 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -220,12 +220,7 @@ def find_initcpio_features(partitions, root_mount_point): hooks.append("usr") if encrypt_hook: - if detect_plymouth() and unencrypted_separate_boot: - if uses_systemd: - hooks.append("sd-encrypt") - else: - hooks.append("plymouth-encrypt") - else: + if unencrypted_separate_boot: if uses_systemd: hooks.append("sd-encrypt") else: From 543de65f33cc0a4174fc72b669d80126e4591079 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Thu, 17 Aug 2023 13:04:24 +0600 Subject: [PATCH 03/12] Added rd.luks.name to grubcfg --- src/modules/grubcfg/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index d325766f6..be057be7b 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -135,10 +135,13 @@ def modify_grub_default(partitions, root_mount_point, distributor): plymouth_bin = libcalamares.utils.target_env_call( ["sh", "-c", "which plymouth"] ) - + mkinitcpio_systemd = libcalamares.utils.target_env_call( + ["sh", "-c", "grep -q 'sd-encrypt' /etc/mkinitcpio.conf"] + ) # Shell exit value 0 means success have_plymouth = plymouth_bin == 0 have_dracut = dracut_bin == 0 + have_systemd = mkinitcpio_systemd == 0 use_splash = "" swap_uuid = "" @@ -214,6 +217,10 @@ def modify_grub_default(partitions, root_mount_point, distributor): kernel_params.append(f"rd.luks.uuid={swap_outer_uuid}") if swap_outer_mappername: kernel_params.append(f"resume=/dev/mapper/{swap_outer_mappername}") + + # When using rd.luks.name you can omit rd.luks.uuid + if have_systemd: + kernel_params.append(f"rd.luks.name={partition['luksUuid']}={partition['luksMapperName']}") overwrite = libcalamares.job.configuration.get("overwrite", False) From 7d6a04d3a8d185c9a3b5b2feb7b0a762ced61964 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Thu, 17 Aug 2023 21:14:47 +0600 Subject: [PATCH 04/12] Added the necessary edits --- src/modules/bootloader/main.py | 3 ++- src/modules/grubcfg/main.py | 8 ++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 4a5a93f60..74ccff239 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -137,6 +137,7 @@ def get_kernel_params(uuid): cryptdevice_params = [] have_dracut = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"]) == 0 + uses_sd-encrypt = libcalamares.utils.target_env_call(["sh", "-c", "grep -q 'sd-encrypt' /etc/mkinitcpio.conf"]) # Take over swap settings: # - unencrypted swap partition sets swap_uuid @@ -154,7 +155,7 @@ def get_kernel_params(uuid): swap_outer_uuid = partition["luksUuid"] if partition["mountPoint"] == "/" and has_luks: - if have_dracut: + if have_dracut or uses_sd-encrypt: cryptdevice_params = [f"rd.luks.uuid={partition['luksUuid']}"] else: cryptdevice_params = [f"cryptdevice=UUID={partition['luksUuid']}:{partition['luksMapperName']}"] diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index be057be7b..2c4fd59a6 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -141,7 +141,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): # Shell exit value 0 means success have_plymouth = plymouth_bin == 0 have_dracut = dracut_bin == 0 - have_systemd = mkinitcpio_systemd == 0 + uses_sd-encrypt = mkinitcpio_systemd == 0 use_splash = "" swap_uuid = "" @@ -162,7 +162,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): cryptdevice_params = [] - if have_dracut: + if have_dracut or used_sd-encrypt: for partition in partitions: if partition["fs"] == "linuxswap" and not partition.get("claimed", None): # Skip foreign swap @@ -217,10 +217,6 @@ def modify_grub_default(partitions, root_mount_point, distributor): kernel_params.append(f"rd.luks.uuid={swap_outer_uuid}") if swap_outer_mappername: kernel_params.append(f"resume=/dev/mapper/{swap_outer_mappername}") - - # When using rd.luks.name you can omit rd.luks.uuid - if have_systemd: - kernel_params.append(f"rd.luks.name={partition['luksUuid']}={partition['luksMapperName']}") overwrite = libcalamares.job.configuration.get("overwrite", False) From bf7f5c6032add0a5032d00bd4276103964b39b2b Mon Sep 17 00:00:00 2001 From: Boria138 Date: Sat, 19 Aug 2023 12:52:35 +0600 Subject: [PATCH 05/12] Fixed initcpiocfg --- src/modules/initcpiocfg/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index af3c56fdd..4aae5a33e 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -162,10 +162,10 @@ def find_initcpio_features(partitions, root_mount_point): ] uses_systemd = detect_systemd() - if uses_systemd: + if uses_systemd: hooks.insert(0, "systemd") hooks.append("sd-vconsole") - else: + else: hooks.insert(0, "udev") hooks.insert(0, "base") hooks.append("keymap") @@ -250,7 +250,7 @@ def find_initcpio_features(partitions, root_mount_point): else: hooks.append("fsck") - return (hooks, modules, files) + return (hooks, modules, files, binaries) def run(): @@ -271,7 +271,7 @@ def run(): return (_("Configuration Error"), _("No root mount point for
initcpiocfg
.")) - hooks, modules, files = find_initcpio_features(partitions, root_mount_point) + hooks, modules, files, binaries = find_initcpio_features(partitions, root_mount_point) write_mkinitcpio_lines(hooks, modules, files, binaries, root_mount_point) return None From c0396cf28bfa4413324b43d73e96d2058954d9fa Mon Sep 17 00:00:00 2001 From: Boria138 Date: Sat, 19 Aug 2023 14:26:36 +0600 Subject: [PATCH 06/12] Deleted quot --- src/modules/bootloader/main.py | 2 +- src/modules/grubcfg/main.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 74ccff239..f29ff839e 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -137,7 +137,7 @@ def get_kernel_params(uuid): cryptdevice_params = [] have_dracut = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"]) == 0 - uses_sd-encrypt = libcalamares.utils.target_env_call(["sh", "-c", "grep -q 'sd-encrypt' /etc/mkinitcpio.conf"]) + uses_sd-encrypt = libcalamares.utils.target_env_call(["sh", "-c", "grep -q sd-encrypt /etc/mkinitcpio.conf"]) # Take over swap settings: # - unencrypted swap partition sets swap_uuid diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index 2c4fd59a6..345c19663 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -136,7 +136,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): ["sh", "-c", "which plymouth"] ) mkinitcpio_systemd = libcalamares.utils.target_env_call( - ["sh", "-c", "grep -q 'sd-encrypt' /etc/mkinitcpio.conf"] + ["sh", "-c", "grep -q sd-encrypt /etc/mkinitcpio.conf"] ) # Shell exit value 0 means success have_plymouth = plymouth_bin == 0 From 9f8b848631faa02ab04c3c280b0e970c0172b049 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Sat, 19 Aug 2023 15:29:49 +0600 Subject: [PATCH 07/12] uses_sd-encrypt was changed to uses_sd_encrypt to make it a valid variable name --- src/modules/bootloader/main.py | 4 ++-- src/modules/grubcfg/main.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index f29ff839e..b128e4e62 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -137,7 +137,7 @@ def get_kernel_params(uuid): cryptdevice_params = [] have_dracut = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"]) == 0 - uses_sd-encrypt = libcalamares.utils.target_env_call(["sh", "-c", "grep -q sd-encrypt /etc/mkinitcpio.conf"]) + uses_sd_encrypt = libcalamares.utils.target_env_call(["sh", "-c", "grep -q sd-encrypt /etc/mkinitcpio.conf"]) # Take over swap settings: # - unencrypted swap partition sets swap_uuid @@ -155,7 +155,7 @@ def get_kernel_params(uuid): swap_outer_uuid = partition["luksUuid"] if partition["mountPoint"] == "/" and has_luks: - if have_dracut or uses_sd-encrypt: + if have_dracut or uses_sd_encrypt: cryptdevice_params = [f"rd.luks.uuid={partition['luksUuid']}"] else: cryptdevice_params = [f"cryptdevice=UUID={partition['luksUuid']}:{partition['luksMapperName']}"] diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index 345c19663..e63214eaf 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -141,7 +141,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): # Shell exit value 0 means success have_plymouth = plymouth_bin == 0 have_dracut = dracut_bin == 0 - uses_sd-encrypt = mkinitcpio_systemd == 0 + uses_sd_encrypt = mkinitcpio_systemd == 0 use_splash = "" swap_uuid = "" @@ -162,7 +162,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): cryptdevice_params = [] - if have_dracut or used_sd-encrypt: + if have_dracut or used_sd_encrypt: for partition in partitions: if partition["fs"] == "linuxswap" and not partition.get("claimed", None): # Skip foreign swap From 950e9d1d0a1f28b39c2241125f4a7c3066606ba0 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Sat, 19 Aug 2023 21:00:25 +0600 Subject: [PATCH 08/12] Added setfont check in mkinitcpiocfg --- src/modules/initcpiocfg/main.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 4aae5a33e..381029415 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -39,11 +39,22 @@ def detect_plymouth(): def detect_systemd(): """ Checks existence (runnability) of systemd in the target system. + @return True if systemd exists in the target, False otherwise """ # Used to only check existence of path /usr/bin/systemd-cat in target return target_env_call(["sh", "-c", "which systemd-cat"]) == 0 + +def detect_setfont(): + """ + Checks existence (runnability) of setfont in the target system. + + @return True if setfont exists in the target, False otherwise + """ + # Used to only check existence of path /usr/bin/setfont in target + return target_env_call(["sh", "-c", "which setfont"]) == 0 + class cpuinfo(object): """ Object describing the current CPU's characteristics. It may be @@ -161,6 +172,7 @@ def find_initcpio_features(partitions, root_mount_point): "keyboard", ] uses_systemd = detect_systemd() + have_setfont = detect_setfont() if uses_systemd: hooks.insert(0, "systemd") @@ -175,9 +187,10 @@ def find_initcpio_features(partitions, root_mount_point): files = [] binaries = [] - # Fixes "setfont: KDFONTOP: Function not implemented" error - binaries.append("setfont") - + if have_setfont: + # Fixes "setfont: KDFONTOP: Function not implemented" error + binaries.append("setfont") + swap_uuid = "" uses_btrfs = False uses_zfs = False From b97a5d535c65bfeaab13a24dca10cb963299f796 Mon Sep 17 00:00:00 2001 From: Boria138 Date: Sat, 19 Aug 2023 23:08:44 +0600 Subject: [PATCH 09/12] Fixed a stupid typo --- src/modules/grubcfg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index e63214eaf..0d574269c 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -162,7 +162,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): cryptdevice_params = [] - if have_dracut or used_sd_encrypt: + if have_dracut or uses_sd_encrypt: for partition in partitions: if partition["fs"] == "linuxswap" and not partition.get("claimed", None): # Skip foreign swap From a9547af8e2b503f7249dd2c5ac5194a0016e2627 Mon Sep 17 00:00:00 2001 From: dalto Date: Sun, 20 Aug 2023 10:39:36 -0500 Subject: [PATCH 10/12] [initcpiocfg,grubcfg,bootloader] Minor code improvements --- src/modules/bootloader/main.py | 11 +++++++---- src/modules/grubcfg/main.py | 11 +++++------ src/modules/initcpiocfg/main.py | 23 +++++++---------------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index b128e4e62..4cb66713c 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -136,8 +136,11 @@ def get_kernel_params(uuid): cryptdevice_params = [] - have_dracut = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"]) == 0 - uses_sd_encrypt = libcalamares.utils.target_env_call(["sh", "-c", "grep -q sd-encrypt /etc/mkinitcpio.conf"]) + has_dracut = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"]) == 0 + uses_systemd_hook = libcalamares.utils.target_env_call(["sh", "-c", + "grep -q \"^HOOKS.*systemd\" /etc/mkinitcpio.conf"]) == 0 + use_systemd_naming = has_dracut or uses_systemd_hook + # Take over swap settings: # - unencrypted swap partition sets swap_uuid @@ -155,7 +158,7 @@ def get_kernel_params(uuid): swap_outer_uuid = partition["luksUuid"] if partition["mountPoint"] == "/" and has_luks: - if have_dracut or uses_sd_encrypt: + if use_systemd_naming or uses_sd_encrypt: cryptdevice_params = [f"rd.luks.uuid={partition['luksUuid']}"] else: cryptdevice_params = [f"cryptdevice=UUID={partition['luksUuid']}:{partition['luksMapperName']}"] @@ -188,7 +191,7 @@ def get_kernel_params(uuid): if swap_uuid: kernel_params.append("resume=UUID={!s}".format(swap_uuid)) - if have_dracut and swap_outer_uuid: + if use_systemd_naming and swap_outer_uuid: kernel_params.append(f"rd.luks.uuid={swap_outer_uuid}") if swap_outer_mappername: diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index 0d574269c..1d7cb0077 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -135,13 +135,12 @@ def modify_grub_default(partitions, root_mount_point, distributor): plymouth_bin = libcalamares.utils.target_env_call( ["sh", "-c", "which plymouth"] ) - mkinitcpio_systemd = libcalamares.utils.target_env_call( - ["sh", "-c", "grep -q sd-encrypt /etc/mkinitcpio.conf"] + uses_systemd_hook = libcalamares.utils.target_env_call( + ["sh", "-c", "grep -q \"^HOOKS.*systemd\" /etc/mkinitcpio.conf"] ) # Shell exit value 0 means success have_plymouth = plymouth_bin == 0 - have_dracut = dracut_bin == 0 - uses_sd_encrypt = mkinitcpio_systemd == 0 + use_systemd_naming = dracut_bin == 0 or uses_systemd_hook == 0 use_splash = "" swap_uuid = "" @@ -162,7 +161,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): cryptdevice_params = [] - if have_dracut or uses_sd_encrypt: + if use_systemd_naming: for partition in partitions: if partition["fs"] == "linuxswap" and not partition.get("claimed", None): # Skip foreign swap @@ -213,7 +212,7 @@ def modify_grub_default(partitions, root_mount_point, distributor): if swap_uuid: kernel_params.append(f"resume=UUID={swap_uuid}") - if have_dracut and swap_outer_uuid: + if use_systemd_naming and swap_outer_uuid: kernel_params.append(f"rd.luks.uuid={swap_outer_uuid}") if swap_outer_mappername: kernel_params.append(f"resume=/dev/mapper/{swap_outer_mappername}") diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 381029415..5464a991a 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -36,25 +36,17 @@ def detect_plymouth(): # Used to only check existence of path /usr/bin/plymouth in target return target_env_call(["sh", "-c", "which plymouth"]) == 0 -def detect_systemd(): - """ - Checks existence (runnability) of systemd in the target system. - - @return True if systemd exists in the target, False otherwise - """ - # Used to only check existence of path /usr/bin/systemd-cat in target - return target_env_call(["sh", "-c", "which systemd-cat"]) == 0 - def detect_setfont(): """ Checks existence (runnability) of setfont in the target system. - + @return True if setfont exists in the target, False otherwise """ # Used to only check existence of path /usr/bin/setfont in target return target_env_call(["sh", "-c", "which setfont"]) == 0 + class cpuinfo(object): """ Object describing the current CPU's characteristics. It may be @@ -171,8 +163,7 @@ def find_initcpio_features(partitions, root_mount_point): "block", "keyboard", ] - uses_systemd = detect_systemd() - have_setfont = detect_setfont() + uses_systemd = target_env_call(["sh", "-c", "which systemd-cat"]) == 0 if uses_systemd: hooks.insert(0, "systemd") @@ -182,15 +173,15 @@ def find_initcpio_features(partitions, root_mount_point): hooks.insert(0, "base") hooks.append("keymap") hooks.append("consolefont") - + modules = [] files = [] binaries = [] - if have_setfont: + if detect_setfont(): # Fixes "setfont: KDFONTOP: Function not implemented" error binaries.append("setfont") - + swap_uuid = "" uses_btrfs = False uses_zfs = False @@ -226,7 +217,7 @@ def find_initcpio_features(partitions, root_mount_point): if partition["mountPoint"] == "/" and "luksMapperName" in partition: encrypt_hook = True - if (partition["mountPoint"] == "/boot" and "luksMapperName" not in partition): + if partition["mountPoint"] == "/boot" and "luksMapperName" not in partition: unencrypted_separate_boot = True if partition["mountPoint"] == "/usr": From d12e40bc341ee40cd88a60e658ab3c70726e6563 Mon Sep 17 00:00:00 2001 From: dalto Date: Sat, 26 Aug 2023 09:55:45 -0500 Subject: [PATCH 11/12] [initcpiocfg] Fix encryption hook not being added with encrypted /boot --- src/modules/initcpiocfg/main.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 5464a991a..821d6e5ee 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -224,16 +224,12 @@ def find_initcpio_features(partitions, root_mount_point): hooks.append("usr") if encrypt_hook: - if unencrypted_separate_boot: - if uses_systemd: - hooks.append("sd-encrypt") - else: - hooks.append("encrypt") + if uses_systemd: + hooks.append("sd-encrypt") + else: + hooks.append("encrypt") crypto_file = "crypto_keyfile.bin" - if not unencrypted_separate_boot and \ - os.path.isfile( - os.path.join(root_mount_point, crypto_file) - ): + if not unencrypted_separate_boot and os.path.isfile(os.path.join(root_mount_point, crypto_file)): files.append(f"/{crypto_file}") if uses_lvm2: From 3552691e57eed06b7ef939c6e5bd5d72d972919e Mon Sep 17 00:00:00 2001 From: dalto Date: Sat, 26 Aug 2023 11:22:41 -0500 Subject: [PATCH 12/12] [grubcfg] Add rd.luks.key for systemd-encrypt hook --- src/modules/grubcfg/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index 1d7cb0077..82b1837f8 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -137,10 +137,10 @@ def modify_grub_default(partitions, root_mount_point, distributor): ) uses_systemd_hook = libcalamares.utils.target_env_call( ["sh", "-c", "grep -q \"^HOOKS.*systemd\" /etc/mkinitcpio.conf"] - ) + ) == 0 # Shell exit value 0 means success have_plymouth = plymouth_bin == 0 - use_systemd_naming = dracut_bin == 0 or uses_systemd_hook == 0 + use_systemd_naming = dracut_bin == 0 or uses_systemd_hook use_splash = "" swap_uuid = "" @@ -176,6 +176,8 @@ def modify_grub_default(partitions, root_mount_point, distributor): if partition["mountPoint"] == "/" and has_luks: cryptdevice_params = [f"rd.luks.uuid={partition['luksUuid']}"] + if not unencrypted_separate_boot and uses_systemd_hook: + cryptdevice_params.append("rd.luks.key=/crypto_keyfile.bin") else: for partition in partitions: if partition["fs"] == "linuxswap" and not partition.get("claimed", None):