Files
gentoo/sys-libs/libblockdev/files/libblockdev-3.0.4-add-non-systemd-method-for-distro-info.patch
Alfred Wingate 17437f594c sys-libs/libblockdev: update test fix patch
>=Elogind-255.22 now has org.freedesktop.hostname1 but is still missing
OperatingSystemCPEName. Deal with this by having both inside the
try/except statement.

See-Also: 1d4d1949ad
Signed-off-by: Alfred Wingate <parona@protonmail.com>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/666
Merges: https://codeberg.org/gentoo/gentoo/pulls/666
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2026-04-19 17:52:56 +02:00

33 lines
1.3 KiB
Diff

From c05c95ac6d79544ef51b8049f6baa067060706d6 Mon Sep 17 00:00:00 2001
From: Alfred Wingate <parona@protonmail.com>
Date: Mon, 13 Nov 2023 16:21:44 +0200
Subject: [PATCH] Add non-systemd method to get distro name and version
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -597,11 +597,16 @@ def get_version():
""" Try to get distro and version
"""
- bus = dbus.SystemBus()
-
- # get information about the distribution from systemd (hostname1)
- sys_info = bus.get_object("org.freedesktop.hostname1", "/org/freedesktop/hostname1")
- cpe = str(sys_info.Get("org.freedesktop.hostname1", "OperatingSystemCPEName", dbus_interface=dbus.PROPERTIES_IFACE))
+ try:
+ bus = dbus.SystemBus()
+
+ # get information about the distribution from systemd (hostname1)
+ sys_info = bus.get_object("org.freedesktop.hostname1", "/org/freedesktop/hostname1")
+ cpe = str(sys_info.Get("org.freedesktop.hostname1", "OperatingSystemCPEName", dbus_interface=dbus.PROPERTIES_IFACE))
+ except dbus.exceptions.DBusException:
+ import platform
+ info = platform.freedesktop_os_release()
+ return (info["NAME"], info["VERSION_ID"])
if cpe:
# 2nd to 4th fields from e.g. "cpe:/o:fedoraproject:fedora:25" or "cpe:/o:redhat:enterprise_linux:7.3:GA:server"
--
2.53.0