Skip to content

Commit 7d94210

Browse files
authored
Fix parsing of systemd package version (#3732)
1 parent a4324ec commit 7d94210

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

archinstall/lib/installer.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
Unit,
3131
)
3232
from archinstall.lib.models.packages import Repository
33+
from archinstall.lib.packages import installed_package
3334
from archinstall.lib.translationhandler import tr
3435
from archinstall.tui.curses_menu import Tui
3536

@@ -1197,22 +1198,24 @@ def _add_systemd_bootloader(
11971198

11981199
# TODO: This is a temporary workaround to deal with https://github.com/archlinux/archinstall/pull/3396#issuecomment-2996862019
11991200
# the systemd_version check can be removed once `--variables=BOOL` is merged into systemd.
1200-
if pacman_q_systemd := self.pacman.run('-Q systemd').trace_log:
1201-
systemd_version = int(pacman_q_systemd.split(b' ')[1][:3].decode())
1201+
systemd_pkg = installed_package('systemd')
1202+
1203+
# keep the version as a str as it can be something like 257.8-2
1204+
if systemd_pkg is not None:
1205+
systemd_version = systemd_pkg.version
12021206
else:
1203-
systemd_version = 257 # This works as a safety workaround for this hot-fix
1207+
systemd_version = '257' # This works as a safety workaround for this hot-fix
12041208

1205-
# Install the boot loader
12061209
try:
12071210
# Force EFI variables since bootctl detects arch-chroot
12081211
# as a container environemnt since v257 and skips them silently.
12091212
# https://github.com/systemd/systemd/issues/36174
1210-
if systemd_version >= 258:
1213+
if systemd_version >= '258':
12111214
SysCommand(f'arch-chroot {self.target} bootctl --variables=yes {" ".join(bootctl_options)} install')
12121215
else:
12131216
SysCommand(f'arch-chroot {self.target} bootctl {" ".join(bootctl_options)} install')
12141217
except SysCallError:
1215-
if systemd_version >= 258:
1218+
if systemd_version >= '258':
12161219
# Fallback, try creating the boot loader without touching the EFI variables
12171220
SysCommand(f'arch-chroot {self.target} bootctl --variables=no {" ".join(bootctl_options)} install')
12181221
else:

archinstall/lib/models/packages.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,27 +103,12 @@ def from_json(data: dict[str, Any]) -> 'PackageSearch':
103103

104104
class LocalPackage(BaseModel):
105105
name: str
106-
repository: str
107106
version: str
108107
description: str
109108
architecture: str
110109
url: str
111110
licenses: str
112111
groups: str
113-
depends_on: str
114-
optional_deps: str
115-
required_by: str
116-
optional_for: str
117-
conflicts_with: str
118-
replaces: str
119-
installed_size: str
120-
packager: str
121-
build_date: str
122-
install_date: str
123-
install_reason: str
124-
install_script: str
125-
validated_by: str
126-
provides: str
127112

128113
@override
129114
def __eq__(self, other: object) -> bool:

archinstall/lib/packages/packages.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ def validate_package_list(packages: list[str]) -> tuple[list[str], list[str]]:
106106

107107
def installed_package(package: str) -> LocalPackage | None:
108108
try:
109-
package_info = Pacman.run(f'-Q --info {package}').decode().split('\n')
109+
package_info = []
110+
for line in Pacman.run(f'-Q --info {package}'):
111+
package_info.append(line.decode().strip())
112+
110113
return _parse_package_output(package_info, LocalPackage)
111114
except SysCallError:
112115
pass

0 commit comments

Comments
 (0)