From 4f29dd3254363a6bb919955abbc3a2268ac71381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Mon, 6 May 2024 16:56:54 +0200 Subject: [PATCH] Remove deprecated pkg-resources, replace with packaging references QubesOS/qubes-issues#9195 --- rpm_spec/core-dom0-linux.spec.in | 1 + vmupdate/agent/source/plugins/manage_rpm_macro.py | 4 ++-- vmupdate/agent/source/plugins/updatesproxy_fix.py | 1 - vmupdate/agent/source/utils.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rpm_spec/core-dom0-linux.spec.in b/rpm_spec/core-dom0-linux.spec.in index ab0a7499..805c5781 100644 --- a/rpm_spec/core-dom0-linux.spec.in +++ b/rpm_spec/core-dom0-linux.spec.in @@ -48,6 +48,7 @@ Requires: qubes-core-admin-client Requires: qubes-utils >= 3.1.3 Requires: qubes-utils-libs >= 4.0.16 Requires: qubes-rpm-oxide +Requires: python3-packaging Conflicts: qubes-core-dom0 < 4.0.23 Requires: %{name}-kernel-install Requires: xdotool diff --git a/vmupdate/agent/source/plugins/manage_rpm_macro.py b/vmupdate/agent/source/plugins/manage_rpm_macro.py index a0806693..d7848391 100644 --- a/vmupdate/agent/source/plugins/manage_rpm_macro.py +++ b/vmupdate/agent/source/plugins/manage_rpm_macro.py @@ -21,7 +21,7 @@ import os -import pkg_resources +import packaging def manage_rpm_macro(os_data, log, **kwargs): @@ -31,7 +31,7 @@ def manage_rpm_macro(os_data, log, **kwargs): if os_data["os_family"] == "RedHat": rpm_macro = "/usr/lib/rpm/macros.d/macros.qubes" if (os_data["id"] == "fedora" - and os_data["release"] < pkg_resources.parse_version("33")): + and os_data["release"] < packaging.version.parse("33")): log.info("Old fedora version detected.") with open(rpm_macro, "w") as file: file.write("# CVE-2021-20271 mitigation\n" diff --git a/vmupdate/agent/source/plugins/updatesproxy_fix.py b/vmupdate/agent/source/plugins/updatesproxy_fix.py index 6a4f2b8e..74f387a6 100644 --- a/vmupdate/agent/source/plugins/updatesproxy_fix.py +++ b/vmupdate/agent/source/plugins/updatesproxy_fix.py @@ -22,7 +22,6 @@ import os import pathlib -import pkg_resources def updatesproxy_fix(os_data, log, **kwargs): diff --git a/vmupdate/agent/source/utils.py b/vmupdate/agent/source/utils.py index d267b450..9778babe 100644 --- a/vmupdate/agent/source/utils.py +++ b/vmupdate/agent/source/utils.py @@ -23,7 +23,7 @@ import ast from typing import Optional, Dict, Any -import pkg_resources +import packaging def get_os_data(logger: Optional = None) -> Dict[str, Any]: @@ -49,7 +49,7 @@ def get_os_data(logger: Optional = None) -> Dict[str, Any]: data["name"] = os_release.get("NAME", "Linux").strip() if "VERSION_ID" in os_release: release = os_release["VERSION_ID"] - data["release"] = pkg_resources.parse_version(release) + data["release"] = packaging.version.parse(release) if "VERSION_CODENAME" in os_release: data["codename"] = os_release["VERSION_CODENAME"]