From 7d94210cd3fd4d39a1888fa2ec76d8766827976f Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Wed, 27 Aug 2025 18:23:03 +1000 Subject: [PATCH] Fix parsing of systemd package version (#3732) --- archinstall/lib/installer.py | 17 ++++++++++------- archinstall/lib/models/packages.py | 15 --------------- archinstall/lib/packages/packages.py | 5 ++++- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index b13ec55a..f24abe39 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -30,6 +30,7 @@ from archinstall.lib.models.device import ( Unit, ) from archinstall.lib.models.packages import Repository +from archinstall.lib.packages import installed_package from archinstall.lib.translationhandler import tr from archinstall.tui.curses_menu import Tui @@ -1197,22 +1198,24 @@ class Installer: # 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 + systemd_pkg = installed_package('systemd') + + # keep the version as a str as it can be something like 257.8-2 + if systemd_pkg is not None: + systemd_version = systemd_pkg.version + 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 - if systemd_version >= 258: + 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: - if systemd_version >= 258: + 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: diff --git a/archinstall/lib/models/packages.py b/archinstall/lib/models/packages.py index 2fbac55c..557f0f42 100644 --- a/archinstall/lib/models/packages.py +++ b/archinstall/lib/models/packages.py @@ -103,27 +103,12 @@ class PackageSearch: class LocalPackage(BaseModel): name: str - repository: str version: str description: str architecture: str url: str licenses: str groups: str - depends_on: str - optional_deps: str - required_by: str - optional_for: str - conflicts_with: str - replaces: str - installed_size: str - packager: str - build_date: str - install_date: str - install_reason: str - install_script: str - validated_by: str - provides: str @override def __eq__(self, other: object) -> bool: diff --git a/archinstall/lib/packages/packages.py b/archinstall/lib/packages/packages.py index 07dbb9ba..1aa3d85a 100644 --- a/archinstall/lib/packages/packages.py +++ b/archinstall/lib/packages/packages.py @@ -106,7 +106,10 @@ def validate_package_list(packages: list[str]) -> tuple[list[str], list[str]]: def installed_package(package: str) -> LocalPackage | None: try: - package_info = Pacman.run(f'-Q --info {package}').decode().split('\n') + package_info = [] + for line in Pacman.run(f'-Q --info {package}'): + package_info.append(line.decode().strip()) + return _parse_package_output(package_info, LocalPackage) except SysCallError: pass