Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcodefiles <11915375+codefiles@users.noreply.github.com>2023-07-31 03:38:29 -0400
committerGitHub <noreply@github.com>2023-07-31 09:38:29 +0200
commit7dd95f8c690b2aa03d36589e33f9a117d1a62d0f (patch)
tree7fcd4aad4e0b9b9c7e90e3d36609c53c4606d657
parentada1ffeaad43eee4c7022606d3037d92fae0ad7a (diff)
Refactor `_add_grub_bootloader()` configuration (#1962)
-rw-r--r--archinstall/lib/installer.py17
1 files changed, 9 insertions, 8 deletions
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}")