Skip to content

Commit

Permalink
Refactor _add_grub_bootloader() configuration (#1962)
Browse files Browse the repository at this point in the history
  • Loading branch information
codefiles authored Jul 31, 2023
1 parent ada1ffe commit 7dd95f8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,19 +859,20 @@ def _add_grub_bootloader(
):
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}")

Expand Down

0 comments on commit 7dd95f8

Please sign in to comment.