Skip to content

Commit

Permalink
fixup! python: setup: arch: Switch to systemd-boot if necessary
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Dec 2, 2024
1 parent 1b92018 commit d3da358
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions python/setup/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,19 +502,18 @@ def switch_to_systemd_boot(dryrun=False):
if lib.setup.using_systemd_boot():
return

# Install systemd-boot to ESP
# Install systemd-boot to ESP, which will create /boot/loader and
# /boot/loader/entries.
if dryrun:
print('$ bootctl install')
print('$ bootctl install\n')
else:
subprocess.run(['bootctl', 'install'], check=True)

# Create initial loader.conf
loader_conf_txt = 'default linux.conf\ntimeout 3\n'
if dryrun:
print('$ mkdir /boot/loader')
print(f"$ echo '{loader_conf_txt}' > /boot/loader/loader.conf")
print(f"$ echo '{loader_conf_txt}' > /boot/loader/loader.conf\n")
else:
Path('/boot/loader').mkdir(exist_ok=True)
Path('/boot/loader/loader.conf').write_text(loader_conf_txt, encoding='utf-8')

# Get partition UUID and filesystem type of /
Expand Down Expand Up @@ -546,18 +545,19 @@ def switch_to_systemd_boot(dryrun=False):
cmdline_options.update(CmdlineOptions(match.groups()[0]))

# Create initial linux.conf
linux_conf_txt = (
'title Arch Linux (linux)\n'
'linux /vmlinuz-linux\n'
f"initrd /{UCODE_VENDOR}-ucode.img\n" if UCODE_VENDOR else '',
'initrd /initramfs-linux.img\n'
f"options {' '.join(sorted(cmdline_options))}\n",
)
initrds = ['initramfs-linux']
if not lib.setup.is_virtual_machine() and UCODE_VENDOR:
initrds.insert(0, f"{UCODE_VENDOR}-ucode")
linux_conf_parts = [
'title Arch Linux (linux)',
'linux /vmlinuz-linux',
*[f"initrd /{initrd}.img" for initrd in initrds],
f"options {cmdline_options}",
]
linux_conf_txt = f"{'\n'.join(linux_conf_parts)}\n"
if dryrun:
print('$ mkdir /boot/loader/entries')
print(f"$ echo '{linux_conf_txt}' > /boot/loader/entries/linux.conf")
print(f"$ echo '{linux_conf_txt}' > /boot/loader/entries/linux.conf\n")
else:
Path('/boot/loader/entries').mkdir(exist_ok=True)
Path('/boot/loader/entries/linux.conf').write_text(linux_conf_txt, encoding='utf-8')

# Remove grub
Expand Down

0 comments on commit d3da358

Please sign in to comment.