Added temporary hold on bootctl's --variables=BOOL usage, as it's notin systemd main yet (#3625)

* Added temporary hold on bootctl's --variables=BOOL usage, as it's not in systemd main yet

* Fixed ruff format check

* Fixed mypy type check issue

* Spelling error

* Fixed flake8 complaint
This commit is contained in:
Anton Hvornum 2025-06-27 12:29:35 +02:00 committed by GitHub
parent 9d0e1e5576
commit 9dd92321a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 3 deletions

View File

@ -1172,15 +1172,28 @@ class Installer:
bootctl_options.append(f'--esp-path={efi_partition.mountpoint}')
bootctl_options.append(f'--boot-path={boot_partition.mountpoint}')
# TODO: This is a temporary workaround to deal with https://github.com/archlinux/archinstall/pull/3396#issuecomment-2996862019
# the systemd_version check can be removed once `--variables=BOOL` is merged into systemd.
if pacman_q_systemd := self.pacman.run('-Q systemd').trace_log:
systemd_version = int(pacman_q_systemd.split(b' ')[1][:3].decode())
else:
systemd_version = 257 # This works as a safety workaround for this hot-fix
# Install the boot loader
try:
# Force EFI variables since bootctl detects arch-chroot
# as a container environemnt since v257 and skips them silently.
# https://github.com/systemd/systemd/issues/36174
SysCommand(f'arch-chroot {self.target} bootctl --variables=yes {" ".join(bootctl_options)} install')
if systemd_version >= 258:
SysCommand(f'arch-chroot {self.target} bootctl --variables=yes {" ".join(bootctl_options)} install')
else:
SysCommand(f'arch-chroot {self.target} bootctl {" ".join(bootctl_options)} install')
except SysCallError:
# Fallback, try creating the boot loader without touching the EFI variables
SysCommand(f'arch-chroot {self.target} bootctl --variables=no {" ".join(bootctl_options)} install')
if systemd_version >= 258:
# Fallback, try creating the boot loader without touching the EFI variables
SysCommand(f'arch-chroot {self.target} bootctl --variables=no {" ".join(bootctl_options)} install')
else:
SysCommand(f'arch-chroot {self.target} bootctl --no-variables {" ".join(bootctl_options)} install')
# Loader configuration is stored in ESP/loader:
# https://man.archlinux.org/man/loader.conf.5