From f60d9a30e210ad75a7225f85a8cdc4e7bc95713f Mon Sep 17 00:00:00 2001 From: Eric Desrochers Date: Thu, 7 May 2026 09:50:15 -0400 Subject: [PATCH] fix(sos): add dnf5 support in dnf plugin Handling DNF5 changes where legacy dnf commands produce Missing command or Unknown argument errors, while preserving existing dnf support unchanged. Signed-off-by: Eric Desrochers --- ...f-initial-dnf5-support-in-dnf-plugin.patch | 85 +++++++++++++++++++ base/comps/sos/sos.comp.toml | 6 ++ locks/sos.lock | 2 +- ...f-initial-dnf5-support-in-dnf-plugin.patch | 85 +++++++++++++++++++ specs/s/sos/sos.spec | 4 + 5 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 base/comps/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch create mode 100644 specs/s/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch diff --git a/base/comps/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch b/base/comps/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch new file mode 100644 index 00000000000..59215999ce6 --- /dev/null +++ b/base/comps/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch @@ -0,0 +1,85 @@ +From b8ba38e844c085abefca44b1b11b9522a18b8fa2 Mon Sep 17 00:00:00 2001 +From: Eric Desrochers +Date: Fri, 24 Apr 2026 14:55:28 +0000 +Subject: [PATCH] [dnf] initial dnf5 support in dnf plugin + +Handling DNF5 changes where legacy dnf commands produce +Missing command or Unknown argument errors, while +preserving existing dnf support unchanged. + +https://dnf5.readthedocs.io/en/latest/changes_from_dnf4.7.html + +Closes: #4308 + +Signed-off-by: Eric Desrochers +--- + sos/report/plugins/dnf.py | 23 ++++++++++++++--------- + 1 file changed, 14 insertions(+), 9 deletions(-) + +diff --git a/sos/report/plugins/dnf.py b/sos/report/plugins/dnf.py +index d79d58c3..eebaabd9 100644 +--- a/sos/report/plugins/dnf.py ++++ b/sos/report/plugins/dnf.py +@@ -30,7 +30,7 @@ class DNFPlugin(Plugin, RedHatPlugin): + profiles = ('system', 'packagemanager', 'sysmgmt') + + files = ('/etc/dnf/dnf.conf',) +- packages = ('dnf',) ++ packages = ('dnf', 'dnf5') + + option_list = [ + PluginOpt('history-info', default=False, +@@ -51,6 +51,7 @@ class DNFPlugin(Plugin, RedHatPlugin): + tags='dnf_module_info') + + def setup(self): ++ has_dnf5 = self.is_installed('dnf5') + + self.add_file_tags({ + '/etc/dnf/modules.d/.*.module': 'dnf_modules' +@@ -90,7 +91,10 @@ class DNFPlugin(Plugin, RedHatPlugin): + self.add_cmd_output('dnf -C repolist', + tags=['yum_repolist', 'dnf_repolist']) + +- self.add_cmd_output('dnf -C repolist --verbose') ++ if has_dnf5: ++ self.add_cmd_output('dnf repo info') ++ else: ++ self.add_cmd_output('dnf -C repolist --verbose') + + self.add_forbidden_path([ + "/etc/pki/entitlement/key.pem", +@@ -103,11 +107,11 @@ class DNFPlugin(Plugin, RedHatPlugin): + "/etc/pki/entitlement/*.pem" + ]) + ++ cmd = f"dnf history {'list' if self.is_installed('dnf5') else ''}" + if not self.get_option("history-info"): +- self.add_cmd_output("dnf history", tags='dnf_history') ++ self.add_cmd_output(cmd, tags='dnf_history') + else: +- history = self.collect_cmd_output("dnf history", +- tags='dnf_history') ++ history = self.collect_cmd_output(cmd, tags='dnf_history') + transactions = -1 + if history['output']: + for line in history['output'].splitlines(): +@@ -122,10 +126,11 @@ class DNFPlugin(Plugin, RedHatPlugin): + subdir="history-info", + tags='dnf_history_info') + +- # Get list of dnf installed modules and their details. +- module_cmd = "dnf module list --installed" +- modules = self.collect_cmd_output(module_cmd) +- self.get_modules_info(modules['output']) ++ if not has_dnf5: ++ # Get list of dnf installed modules and their details. ++ module_cmd = "dnf module list --installed" ++ modules = self.collect_cmd_output(module_cmd) ++ self.get_modules_info(modules['output']) + + def postproc(self): + # Scrub passwords in repositories and yum/dnf variables +-- +2.45.2 + diff --git a/base/comps/sos/sos.comp.toml b/base/comps/sos/sos.comp.toml index 190de3b9040..affa4c57cf8 100644 --- a/base/comps/sos/sos.comp.toml +++ b/base/comps/sos/sos.comp.toml @@ -17,3 +17,9 @@ description = "Add cloud-init-main and cloud-init-network service names for clou type = "patch-add" file = "cloud_init-add-cloud-init-main-and-network-services.patch" source = "cloud_init-add-cloud-init-main-and-network-services.patch" + +[[components.sos.overlays]] +description = "Add dnf5 support in dnf plugin" +type = "patch-add" +file = "dnf-initial-dnf5-support-in-dnf-plugin.patch" +source = "dnf-initial-dnf5-support-in-dnf-plugin.patch" diff --git a/locks/sos.lock b/locks/sos.lock index 1e332c63e80..297535e36da 100644 --- a/locks/sos.lock +++ b/locks/sos.lock @@ -2,5 +2,5 @@ version = 1 import-commit = 'f3ecbda85d52c61c5c80ee3fe5c2a31886f040c6' upstream-commit = 'f3ecbda85d52c61c5c80ee3fe5c2a31886f040c6' -input-fingerprint = 'sha256:11e4c1681e46aa62e8259318dadcbf5495db32919fef80bc128ce99cd9f138c3' +input-fingerprint = 'sha256:06764892178a4c5ee197282f535a7e9472bc1c4029e82b89f95525f566d5f69b' resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e' diff --git a/specs/s/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch b/specs/s/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch new file mode 100644 index 00000000000..59215999ce6 --- /dev/null +++ b/specs/s/sos/dnf-initial-dnf5-support-in-dnf-plugin.patch @@ -0,0 +1,85 @@ +From b8ba38e844c085abefca44b1b11b9522a18b8fa2 Mon Sep 17 00:00:00 2001 +From: Eric Desrochers +Date: Fri, 24 Apr 2026 14:55:28 +0000 +Subject: [PATCH] [dnf] initial dnf5 support in dnf plugin + +Handling DNF5 changes where legacy dnf commands produce +Missing command or Unknown argument errors, while +preserving existing dnf support unchanged. + +https://dnf5.readthedocs.io/en/latest/changes_from_dnf4.7.html + +Closes: #4308 + +Signed-off-by: Eric Desrochers +--- + sos/report/plugins/dnf.py | 23 ++++++++++++++--------- + 1 file changed, 14 insertions(+), 9 deletions(-) + +diff --git a/sos/report/plugins/dnf.py b/sos/report/plugins/dnf.py +index d79d58c3..eebaabd9 100644 +--- a/sos/report/plugins/dnf.py ++++ b/sos/report/plugins/dnf.py +@@ -30,7 +30,7 @@ class DNFPlugin(Plugin, RedHatPlugin): + profiles = ('system', 'packagemanager', 'sysmgmt') + + files = ('/etc/dnf/dnf.conf',) +- packages = ('dnf',) ++ packages = ('dnf', 'dnf5') + + option_list = [ + PluginOpt('history-info', default=False, +@@ -51,6 +51,7 @@ class DNFPlugin(Plugin, RedHatPlugin): + tags='dnf_module_info') + + def setup(self): ++ has_dnf5 = self.is_installed('dnf5') + + self.add_file_tags({ + '/etc/dnf/modules.d/.*.module': 'dnf_modules' +@@ -90,7 +91,10 @@ class DNFPlugin(Plugin, RedHatPlugin): + self.add_cmd_output('dnf -C repolist', + tags=['yum_repolist', 'dnf_repolist']) + +- self.add_cmd_output('dnf -C repolist --verbose') ++ if has_dnf5: ++ self.add_cmd_output('dnf repo info') ++ else: ++ self.add_cmd_output('dnf -C repolist --verbose') + + self.add_forbidden_path([ + "/etc/pki/entitlement/key.pem", +@@ -103,11 +107,11 @@ class DNFPlugin(Plugin, RedHatPlugin): + "/etc/pki/entitlement/*.pem" + ]) + ++ cmd = f"dnf history {'list' if self.is_installed('dnf5') else ''}" + if not self.get_option("history-info"): +- self.add_cmd_output("dnf history", tags='dnf_history') ++ self.add_cmd_output(cmd, tags='dnf_history') + else: +- history = self.collect_cmd_output("dnf history", +- tags='dnf_history') ++ history = self.collect_cmd_output(cmd, tags='dnf_history') + transactions = -1 + if history['output']: + for line in history['output'].splitlines(): +@@ -122,10 +126,11 @@ class DNFPlugin(Plugin, RedHatPlugin): + subdir="history-info", + tags='dnf_history_info') + +- # Get list of dnf installed modules and their details. +- module_cmd = "dnf module list --installed" +- modules = self.collect_cmd_output(module_cmd) +- self.get_modules_info(modules['output']) ++ if not has_dnf5: ++ # Get list of dnf installed modules and their details. ++ module_cmd = "dnf module list --installed" ++ modules = self.collect_cmd_output(module_cmd) ++ self.get_modules_info(modules['output']) + + def postproc(self): + # Scrub passwords in repositories and yum/dnf variables +-- +2.45.2 + diff --git a/specs/s/sos/sos.spec b/specs/s/sos/sos.spec index a0c9082fa01..8f445e5d49a 100644 --- a/specs/s/sos/sos.spec +++ b/specs/s/sos/sos.spec @@ -45,6 +45,7 @@ BuildRequires: fdupes Patch0: Policy-Fix-os_release_name-value.patch Patch1: Policy-Add-os_release_id-check.patch Patch2: cloud_init-add-cloud-init-main-and-network-services.patch +Patch3: dnf-initial-dnf5-support-in-dnf-plugin.patch %description Sos is a set of tools that gathers information about system hardware and configuration. The information can then be used for @@ -119,6 +120,9 @@ rm -rf %{buildroot}/usr/config/ %changelog ## START: Generated by rpmautospec +* Thu May 07 2026 Eric Desrochers - 4.11.0-4 +- fix(sos): add dnf5 support in dnf plugin + * Mon May 04 2026 Jonathan Brenes - 4.11.0-3 - fix(sos): add cloud-init-main and cloud-init-network service names