Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorcodefiles <11915375+codefiles@users.noreply.github.com>2023-07-16 18:17:21 -0400
committerGitHub <noreply@github.com>2023-07-17 00:17:21 +0200
commitc67bb0b549b35ce335941c9c1cbe22f99c28f7fe (patch)
tree9eed21196bb51ae654368f1965050c5979bc421b /archinstall
parentafaf42e6469206e181f6373c1ded209217539e71 (diff)
Refactor `_add_systemd_bootloader()` loader configuration (#1911)
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/installer.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py
index 9582df77..02d48768 100644
--- a/archinstall/lib/installer.py
+++ b/archinstall/lib/installer.py
@@ -733,24 +733,26 @@ class Installer:
# Modify or create a loader.conf
loader_conf = loader_dir / 'loader.conf'
+ default = f'default {self.init_time}_{self.kernels[0]}.conf\n'
+
try:
with loader_conf.open() as loader:
- loader_data = loader.read().split('\n')
+ loader_data = loader.readlines()
except FileNotFoundError:
loader_data = [
- f"default {self.init_time}",
- "timeout 15"
+ default,
+ 'timeout 15\n'
]
+ else:
+ for index, line in enumerate(loader_data):
+ if line.startswith('default'):
+ loader_data[index] = default
+ elif line.startswith('#timeout'):
+ # We add in the default timeout to support dual-boot
+ loader_data[index] = line.removeprefix('#')
with loader_conf.open('w') as loader:
- for line in loader_data:
- if line[:8] == 'default ':
- loader.write(f'default {self.init_time}_{self.kernels[0]}\n')
- elif line[:8] == '#timeout' and 'timeout 15' not in loader_data:
- # We add in the default timeout to support dual-boot
- loader.write(f"{line[1:]}\n")
- else:
- loader.write(f"{line}\n")
+ loader.writelines(loader_data)
# Ensure that the $BOOT/loader/entries/ directory exists before we try to create files in it
entries_dir = loader_dir / 'entries'