From 7dd95f8c690b2aa03d36589e33f9a117d1a62d0f Mon Sep 17 00:00:00 2001 From: codefiles <11915375+codefiles@users.noreply.github.com> Date: Mon, 31 Jul 2023 03:38:29 -0400 Subject: Refactor `_add_grub_bootloader()` configuration (#1962) --- archinstall/lib/installer.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'archinstall/lib/installer.py') diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 94bdff7d..ba57a001 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -859,19 +859,20 @@ class Installer: ): self.pacman.strap('grub') # no need? - _file = "/etc/default/grub" + grub_default = self.target / 'etc/default/grub' + config = grub_default.read_text() + + cmdline_linux = [] if root_partition in self._disk_encryption.partitions: debug(f"Using UUID {root_partition.uuid} as encrypted root identifier") - cmd_line_linux = f"sed -i 's/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=UUID={root_partition.uuid}:cryptlvm rootfstype={root_partition.safe_fs_type.value}\"/'" - enable_cryptdisk = "sed -i 's/#GRUB_ENABLE_CRYPTODISK=y/GRUB_ENABLE_CRYPTODISK=y/'" - - SysCommand(f"/usr/bin/arch-chroot {self.target} {enable_cryptdisk} {_file}") - else: - cmd_line_linux = f"sed -i 's/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"rootfstype={root_partition.safe_fs_type.value}\"/'" + cmdline_linux.append(f'cryptdevice=UUID={root_partition.uuid}:cryptlvm') + config = re.sub(r'#(GRUB_ENABLE_CRYPTODISK=y\n)', r'\1', config, 1) - SysCommand(f"/usr/bin/arch-chroot {self.target} {cmd_line_linux} {_file}") + cmdline_linux.append(f'rootfstype={root_partition.safe_fs_type.value}') + config = re.sub(r'(GRUB_CMDLINE_LINUX=")("\n)', rf'\1{" ".join(cmdline_linux)}\2', config, 1) + grub_default.write_text(config) info(f"GRUB boot partition: {boot_partition.dev_path}") -- cgit v1.2.3-70-g09d2