From 9ba5d72432b09cd70193440a3ddc4dd690244f37 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Fri, 12 Apr 2024 17:51:16 +0200 Subject: [PATCH] 2.17: dnf5: replace removed API calls and add fallbacks (#83025) * dnf5: replace removed API calls (#83020) * dnf5: replace removed API calls https://github.com/rpm-software-management/dnf5/commit/bfb6f32e15c359011e078c81b78d160ef10708dd https://github.com/rpm-software-management/dnf5/commit/96c9188f9c5b5a78aa550b9a15ed748e6f306e8d * call set_group_with_name instead of setting group_with_name https://github.com/rpm-software-management/dnf5/commit/c7b88428f314bebb4cfbb733c7c7bc6a42c2b666 --------- Co-authored-by: Matt Martz (cherry picked from commit 4e57249d594dd93f5278da16113cbadace5a51e1) * Fallbacks for brand new APIs that don't exist in released dnf5 (#83022) (cherry picked from commit 57750e2cf769aa80a1db31de9e5a1dd985f64554) --------- Co-authored-by: Matt Martz --- changelogs/fragments/dnf5-api-breaks.yml | 2 ++ lib/ansible/modules/dnf5.py | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/dnf5-api-breaks.yml diff --git a/changelogs/fragments/dnf5-api-breaks.yml b/changelogs/fragments/dnf5-api-breaks.yml new file mode 100644 index 00000000000..99c9ecd6cfc --- /dev/null +++ b/changelogs/fragments/dnf5-api-breaks.yml @@ -0,0 +1,2 @@ +bugfixes: + - dnf5 - replace removed API calls diff --git a/lib/ansible/modules/dnf5.py b/lib/ansible/modules/dnf5.py index 2fa09b2b8df..7af1f4a2be4 100644 --- a/lib/ansible/modules/dnf5.py +++ b/lib/ansible/modules/dnf5.py @@ -504,7 +504,7 @@ class Dnf5Module(YumDnf): conf.config_file_path = self.conf_file try: - base.load_config_from_file() + base.load_config() except RuntimeError as e: self.module.fail_json( msg=str(e), @@ -544,7 +544,8 @@ class Dnf5Module(YumDnf): log_router = base.get_logger() global_logger = libdnf5.logger.GlobalLogger() global_logger.set(log_router.get(), libdnf5.logger.Logger.Level_DEBUG) - logger = libdnf5.logger.create_file_logger(base) + # FIXME hardcoding the filename does not seem right, should libdnf5 expose the default file name? + logger = libdnf5.logger.create_file_logger(base, "dnf5.log") log_router.add_logger(logger) if self.update_cache: @@ -569,7 +570,11 @@ class Dnf5Module(YumDnf): for repo in repo_query: repo.enable() - sack.update_and_load_enabled_repos(True) + try: + sack.load_repos() + except AttributeError: + # dnf5 < 5.2.0.0 + sack.update_and_load_enabled_repos(True) if self.update_cache and not self.names and not self.list: self.module.exit_json( @@ -601,7 +606,11 @@ class Dnf5Module(YumDnf): self.module.exit_json(msg="", results=results, rc=0) settings = libdnf5.base.GoalJobSettings() - settings.group_with_name = True + try: + settings.set_group_with_name(True) + except AttributeError: + # dnf5 < 5.2.0.0 + settings.group_with_name = True if self.bugfix or self.security: advisory_query = libdnf5.advisory.AdvisoryQuery(base) types = []