From 4e0b45961d0731228949f804b8932570729c34f2 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Mon, 21 Apr 2025 14:14:10 -0600 Subject: [PATCH 01/13] Better support for dnf5 in Fedora 41/42 'grouplist' and 'groupinfo' are each now two words. 'group' and 'group-id' have been replaced with 'name' and 'id', so check for those too. --- salt/modules/yumpkg.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index bfdf1da84071..34fa8a875027 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2513,7 +2513,7 @@ def group_list(): } out = __salt__["cmd.run_stdout"]( - [_yum(), "grouplist", "hidden"], output_loglevel="trace", python_shell=False + [_yum(), "group", "list", "hidden"], output_loglevel="trace", python_shell=False ) key = None for line in salt.utils.itertools.split(out, "\n"): @@ -2615,7 +2615,7 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): } ) - cmd = [_yum(), "--quiet"] + options + ["groupinfo", name] + cmd = [_yum(), "--quiet"] + options + ["group", "info", name] out = __salt__["cmd.run_stdout"](cmd, output_loglevel="trace", python_shell=False) g_info = {} @@ -2631,8 +2631,8 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): elif "group" in g_info: ret["type"] = "package group" - ret["group"] = g_info.get("environment group") or g_info.get("group") - ret["id"] = g_info.get("environment-id") or g_info.get("group-id") + ret["group"] = g_info.get("environment group") or g_info.get("group") or g_info.get("name") + ret["id"] = g_info.get("environment-id") or g_info.get("group-id") or g_info.get("id") if not ret["group"] and not ret["id"]: raise CommandExecutionError(f"Group '{name}' not found") From b8cb109d3148a9e580f080c312e1ffc85c6e82e1 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Wed, 30 Jul 2025 11:04:32 -0600 Subject: [PATCH 02/13] Add a changelog entry for 67975. --- changelog/67975.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/67975.fixed.md diff --git a/changelog/67975.fixed.md b/changelog/67975.fixed.md new file mode 100644 index 000000000000..8f386a340fed --- /dev/null +++ b/changelog/67975.fixed.md @@ -0,0 +1 @@ +Improve support for installing via groups with dnf5 on Fedora 41/42 From d8ef622f34d214e31de7d8186d2bc76e010ce2ee Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Tue, 5 Aug 2025 13:29:29 -0600 Subject: [PATCH 03/13] Correctly parse the dnf5 group info format. The dnf5 'group info' output differs from the dnf 'groupinfo' output. In particular, a package name is now also listed on the first line of each section. Need to also strip leading spaces from lines. --- salt/modules/yumpkg.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 34fa8a875027..f87f8c1351ce 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2643,7 +2643,8 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): for pkgtype in pkgtypes: target_found = False for line in salt.utils.itertools.split(out, "\n"): - line = line.strip().lstrip(string.punctuation) + line = line.strip().lstrip(string.punctuation).lstrip() + # dnf match = re.match( pkgtypes_capturegroup + r" (?:groups|packages):\s*$", line.lower() ) @@ -2656,6 +2657,24 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): # We've reached the targeted section target_found = True continue + # dnf5 + match_dnf5 = re.match( + pkgtypes_capturegroup + r" (?:groups|packages)\s*:\s*(.*?)$", line.lower() + ) + if match_dnf5: + if target_found: + # We've reached a new section, break from loop + break + else: + if match_dnf5.group(1) == pkgtype: + # We've reached the targeted section + target_found = True + # The difference here from dnf (above) is that this line + # also contains the first package of this section. + # Let line be the match we found, and then simply + # continue on, where we'll add this to the appropriate group + line = match_dnf5.group(2) + if target_found: if expand and ret["type"] == "environment group": if not line or line in completed_groups: From e2ce8b7af038a9bc8a0cd55f53ce33b067f76e3f Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Tue, 5 Aug 2025 13:37:05 -0600 Subject: [PATCH 04/13] Write a test for dnf5 'group info' parsing for PR 67975. --- tests/pytests/unit/modules/test_yumpkg.py | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index cfc2af7e5bcc..e6df26f4b928 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -3256,3 +3256,51 @@ def test_normalize_name_with_arch_x86_64_v2(): assert yumpkg.normalize_name("chrony.x86_64") == "chrony.x86_64" with patch("salt.utils.pkg.rpm.get_osarch", MagicMock(return_value="x86_64")): assert yumpkg.normalize_name("rootfiles.noarch") == "rootfiles" + + +def test_67975_dnf5_group_info(): + """ + Test yumpkg.group_info parsing for dnf5 format + """ + expected = { + 'mandatory': [ + "libreoffice-calc", + "libreoffice-emailmerge", + "libreoffice-graphicfilter", + "libreoffice-impress", + "libreoffice-writer", + ], + 'optional': [ + "libreoffice-base", + "libreoffice-draw", + "libreoffice-math", + "libreoffice-pyuno", + ], + 'default': [], + 'conditional': [], + 'group': 'LibreOffice', + 'id': 'libreoffice', + 'description': 'LibreOffice Productivity Suite' + } + cmd_out = """Id : libreoffice + Name : LibreOffice + Description : LibreOffice Productivity Suite + Installed : yes + Order : + Langonly : + Uservisible : yes + Repositories : @System + Mandatory packages : libreoffice-calc + : libreoffice-emailmerge + : libreoffice-graphicfilter + : libreoffice-impress + : libreoffice-writer + Optional packages : libreoffice-base + : libreoffice-draw + : libreoffice-math + : libreoffice-pyuno""" + with patch.dict( + yumpkg.__salt__, {"cmd.run_stdout": MagicMock(return_value=cmd_out)} + ): + info = yumpkg.group_info("libreoffice") + assert info == expected From e6199c9947bcdaf41086ac7364489055d1534078 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Tue, 5 Aug 2025 13:52:22 -0600 Subject: [PATCH 05/13] The 'hidden' option requires two leading dashes for dnf5. --- salt/modules/yumpkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index f87f8c1351ce..d870c6c997b0 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2513,7 +2513,7 @@ def group_list(): } out = __salt__["cmd.run_stdout"]( - [_yum(), "group", "list", "hidden"], output_loglevel="trace", python_shell=False + [_yum(), "group", "list", "--hidden"], output_loglevel="trace", python_shell=False ) key = None for line in salt.utils.itertools.split(out, "\n"): From 18673d754031ecf031ea4b81054397b479527057 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Tue, 5 Aug 2025 16:57:25 -0600 Subject: [PATCH 06/13] Add dnf5 group_list test, and limit 67975 tests to dnf5. dnf5 group_list-specific test was missing, but these tests should only be run against dnf5, as yum/dnf provide different output for 'grouplist' and 'groupinfo'. --- tests/pytests/unit/modules/test_yumpkg.py | 47 ++++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index e6df26f4b928..a50420b3b570 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -3262,6 +3262,7 @@ def test_67975_dnf5_group_info(): """ Test yumpkg.group_info parsing for dnf5 format """ + patch_yum = patch("salt.modules.yumpkg._yum", Mock(return_value="dnf5")) expected = { 'mandatory': [ "libreoffice-calc", @@ -3275,11 +3276,11 @@ def test_67975_dnf5_group_info(): "libreoffice-draw", "libreoffice-math", "libreoffice-pyuno", - ], - 'default': [], - 'conditional': [], - 'group': 'LibreOffice', - 'id': 'libreoffice', + ], + 'default': [], + 'conditional': [], + 'group': 'LibreOffice', + 'id': 'libreoffice', 'description': 'LibreOffice Productivity Suite' } cmd_out = """Id : libreoffice @@ -3299,8 +3300,34 @@ def test_67975_dnf5_group_info(): : libreoffice-draw : libreoffice-math : libreoffice-pyuno""" - with patch.dict( - yumpkg.__salt__, {"cmd.run_stdout": MagicMock(return_value=cmd_out)} - ): - info = yumpkg.group_info("libreoffice") - assert info == expected + with patch_yum: + with patch.dict( + yumpkg.__salt__, {"cmd.run_stdout": MagicMock(return_value=cmd_out)} + ): + info = yumpkg.group_info("libreoffice") + assert info == expected + +def test_67975_dnf5_group_list(): + patch_yum = patch("salt.modules.yumpkg._yum", Mock(return_value="dnf5")) + mock_out = MagicMock( + return_value="""\ +ID Name Installed +foo Foo package no +bar Bar package no +brackets Just (testing) yes yes +cleaners Mop and bucket yes +last But not least no\ + """) + patch_grplist = patch.dict(yumpkg.__salt__, {"cmd.run_stdout": mock_out}) + with patch_yum: + with patch_grplist: + result = yumpkg.group_list() + expected = { + "installed": ["brackets","cleaners"], + "available": ["foo","bar"], + "installed environments": [], + "available environments": [], + "available languages": {}, + } + assert result == expected + From b1f130a87ec4a5dde5aa8977ad3adf7afba51d8a Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Tue, 5 Aug 2025 17:02:24 -0600 Subject: [PATCH 07/13] Make group_list() parse dnf5 'group list' output. dnf5 'group list' output needs to be handed differently than yum/dnf 'grouplist' output. Also condition on _yum() so we don't break 'grouplist' and 'groupinfo' on systems using yum/dnf. --- salt/modules/yumpkg.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index d870c6c997b0..d60e9e223f4f 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2512,8 +2512,28 @@ def group_list(): "available language groups:": "available languages", } + if _yum() in ("dnf5"): + out = __salt__["cmd.run_stdout"]( + [_yum(), "group","list", "--hidden"], output_loglevel="trace", python_shell=False + ) + + for line in salt.utils.itertools.split(out, "\n"): + line_lc = line.lower() + # split line into 3 parts: ID (no spaces), Name (contains spaces), and + # Installed (one of 'yes' or 'no') + match = re.match(r"^(\S+?)\s+(.+?)\s*(yes|no)$" ,line_lc) + if match: + pkg_id, pkg_name, pkg_installed = match.groups() + if pkg_id not in ("id"): + if pkg_installed in ("yes"): + ret["installed"].append(pkg_id) + else: + ret["available"].append(pkg_id) + return ret + + # else: not dnf5 out = __salt__["cmd.run_stdout"]( - [_yum(), "group", "list", "--hidden"], output_loglevel="trace", python_shell=False + [_yum(), "grouplist", "hidden"], output_loglevel="trace", python_shell=False ) key = None for line in salt.utils.itertools.split(out, "\n"): @@ -2615,7 +2635,10 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): } ) - cmd = [_yum(), "--quiet"] + options + ["group", "info", name] + if _yum() in ("dnf5"): + cmd = [_yum(), "--quiet"] + options + ["group", "info", name] + else: + cmd = [_yum(), "--quiet"] + options + ["groupinfo", name] out = __salt__["cmd.run_stdout"](cmd, output_loglevel="trace", python_shell=False) g_info = {} From d93d5b6daca92b898eabd91a2a52147a3208be5c Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Wed, 6 Aug 2025 13:29:30 -0600 Subject: [PATCH 08/13] Fix minor comma formatting. --- salt/modules/yumpkg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index d60e9e223f4f..4d8b8e251240 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2514,14 +2514,14 @@ def group_list(): if _yum() in ("dnf5"): out = __salt__["cmd.run_stdout"]( - [_yum(), "group","list", "--hidden"], output_loglevel="trace", python_shell=False + [_yum(), "group", "list", "--hidden"], output_loglevel="trace", python_shell=False ) for line in salt.utils.itertools.split(out, "\n"): line_lc = line.lower() # split line into 3 parts: ID (no spaces), Name (contains spaces), and # Installed (one of 'yes' or 'no') - match = re.match(r"^(\S+?)\s+(.+?)\s*(yes|no)$" ,line_lc) + match = re.match(r"^(\S+?)\s+(.+?)\s*(yes|no)$", line_lc) if match: pkg_id, pkg_name, pkg_installed = match.groups() if pkg_id not in ("id"): From 43f3057e4154073b99e4b1e966146c14759102d0 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Wed, 6 Aug 2025 14:10:58 -0600 Subject: [PATCH 09/13] Whitespace/formatting police. --- tests/pytests/unit/modules/test_yumpkg.py | 47 ++++++++++++----------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index a50420b3b570..e9c1e251a268 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -3264,25 +3264,25 @@ def test_67975_dnf5_group_info(): """ patch_yum = patch("salt.modules.yumpkg._yum", Mock(return_value="dnf5")) expected = { - 'mandatory': [ - "libreoffice-calc", - "libreoffice-emailmerge", - "libreoffice-graphicfilter", - "libreoffice-impress", - "libreoffice-writer", - ], - 'optional': [ - "libreoffice-base", - "libreoffice-draw", - "libreoffice-math", - "libreoffice-pyuno", - ], - 'default': [], - 'conditional': [], - 'group': 'LibreOffice', - 'id': 'libreoffice', - 'description': 'LibreOffice Productivity Suite' - } + 'mandatory': [ + "libreoffice-calc", + "libreoffice-emailmerge", + "libreoffice-graphicfilter", + "libreoffice-impress", + "libreoffice-writer", + ], + 'optional': [ + "libreoffice-base", + "libreoffice-draw", + "libreoffice-math", + "libreoffice-pyuno", + ], + 'default': [], + 'conditional': [], + 'group': 'LibreOffice', + 'id': 'libreoffice', + 'description': 'LibreOffice Productivity Suite' + } cmd_out = """Id : libreoffice Name : LibreOffice Description : LibreOffice Productivity Suite @@ -3302,11 +3302,12 @@ def test_67975_dnf5_group_info(): : libreoffice-pyuno""" with patch_yum: with patch.dict( - yumpkg.__salt__, {"cmd.run_stdout": MagicMock(return_value=cmd_out)} - ): + yumpkg.__salt__, {"cmd.run_stdout": MagicMock(return_value=cmd_out)} + ): info = yumpkg.group_info("libreoffice") assert info == expected + def test_67975_dnf5_group_list(): patch_yum = patch("salt.modules.yumpkg._yum", Mock(return_value="dnf5")) mock_out = MagicMock( @@ -3317,7 +3318,8 @@ def test_67975_dnf5_group_list(): brackets Just (testing) yes yes cleaners Mop and bucket yes last But not least no\ - """) + """ + ) patch_grplist = patch.dict(yumpkg.__salt__, {"cmd.run_stdout": mock_out}) with patch_yum: with patch_grplist: @@ -3330,4 +3332,3 @@ def test_67975_dnf5_group_list(): "available languages": {}, } assert result == expected - From a3de110bd3efc2d6b65e33c100b48f537e4a2737 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Wed, 6 Aug 2025 14:34:42 -0600 Subject: [PATCH 10/13] More formatting/whitespace police. --- salt/modules/yumpkg.py | 15 +++++++++++---- tests/pytests/unit/modules/test_yumpkg.py | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 4d8b8e251240..de5d2bef96cd 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2514,7 +2514,9 @@ def group_list(): if _yum() in ("dnf5"): out = __salt__["cmd.run_stdout"]( - [_yum(), "group", "list", "--hidden"], output_loglevel="trace", python_shell=False + [_yum(), "group", "list", "--hidden"], + output_loglevel="trace", + python_shell=False, ) for line in salt.utils.itertools.split(out, "\n"): @@ -2654,8 +2656,12 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): elif "group" in g_info: ret["type"] = "package group" - ret["group"] = g_info.get("environment group") or g_info.get("group") or g_info.get("name") - ret["id"] = g_info.get("environment-id") or g_info.get("group-id") or g_info.get("id") + ret["group"] = ( + g_info.get("environment group") or g_info.get("group") or g_info.get("name") + ) + ret["id"] = ( + g_info.get("environment-id") or g_info.get("group-id") or g_info.get("id") + ) if not ret["group"] and not ret["id"]: raise CommandExecutionError(f"Group '{name}' not found") @@ -2682,7 +2688,8 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): continue # dnf5 match_dnf5 = re.match( - pkgtypes_capturegroup + r" (?:groups|packages)\s*:\s*(.*?)$", line.lower() + pkgtypes_capturegroup + r" (?:groups|packages)\s*:\s*(.*?)$", + line.lower(), ) if match_dnf5: if target_found: diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index e9c1e251a268..9e2ec4fae4dc 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -3264,24 +3264,24 @@ def test_67975_dnf5_group_info(): """ patch_yum = patch("salt.modules.yumpkg._yum", Mock(return_value="dnf5")) expected = { - 'mandatory': [ + "mandatory": [ "libreoffice-calc", "libreoffice-emailmerge", "libreoffice-graphicfilter", "libreoffice-impress", "libreoffice-writer", ], - 'optional': [ + "optional": [ "libreoffice-base", "libreoffice-draw", "libreoffice-math", "libreoffice-pyuno", ], - 'default': [], - 'conditional': [], - 'group': 'LibreOffice', - 'id': 'libreoffice', - 'description': 'LibreOffice Productivity Suite' + "default": [], + "conditional": [], + "group": "LibreOffice", + "id": "libreoffice", + "description": "LibreOffice Productivity Suite" } cmd_out = """Id : libreoffice Name : LibreOffice @@ -3325,10 +3325,10 @@ def test_67975_dnf5_group_list(): with patch_grplist: result = yumpkg.group_list() expected = { - "installed": ["brackets","cleaners"], - "available": ["foo","bar"], + "installed": ["brackets", "cleaners"], + "available": ["foo", "bar"], "installed environments": [], "available environments": [], - "available languages": {}, + "available languages": {}, } assert result == expected From 755923f7b6e91a30e8e7be22502dc3bb4cd65323 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Wed, 6 Aug 2025 15:45:17 -0600 Subject: [PATCH 11/13] Hopefully last whitespace/formatting fix. --- tests/pytests/unit/modules/test_yumpkg.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index 9e2ec4fae4dc..1b062a0119dd 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -3270,18 +3270,18 @@ def test_67975_dnf5_group_info(): "libreoffice-graphicfilter", "libreoffice-impress", "libreoffice-writer", - ], + ], "optional": [ "libreoffice-base", "libreoffice-draw", "libreoffice-math", "libreoffice-pyuno", - ], + ], "default": [], "conditional": [], "group": "LibreOffice", "id": "libreoffice", - "description": "LibreOffice Productivity Suite" + "description": "LibreOffice Productivity Suite", } cmd_out = """Id : libreoffice Name : LibreOffice From 549eb99ffc977fcbffac1998059a82851741a859 Mon Sep 17 00:00:00 2001 From: Greg Oster Date: Thu, 6 Nov 2025 10:06:01 -0600 Subject: [PATCH 12/13] If "name" is in the group info, then it's a package group. Preserve the case of the package name when adding it to the list. --- salt/modules/yumpkg.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index de5d2bef96cd..967213661093 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2655,6 +2655,8 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): ret["type"] = "environment group" elif "group" in g_info: ret["type"] = "package group" + elif "name" in g_info: + ret["type"] = "package group" ret["group"] = ( g_info.get("environment group") or g_info.get("group") or g_info.get("name") @@ -2701,9 +2703,13 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): target_found = True # The difference here from dnf (above) is that this line # also contains the first package of this section. + # Have to pull out the package name, but not changing the case + rematch_dnf5 = re.match( r"^.*:\s*(.*?)$", line) # Let line be the match we found, and then simply # continue on, where we'll add this to the appropriate group - line = match_dnf5.group(2) + # Can't fail... + if rematch_dnf5: + line = rematch_dnf5.group(1) if target_found: if expand and ret["type"] == "environment group": From 42b229bde715ac1d05486de61537dbc27c06436e Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Mon, 8 Jun 2026 22:01:30 -0700 Subject: [PATCH 13/13] Fix dnf5 group_info test and clean up string-membership checks - test_67975_dnf5_group_info: add missing "type": "package group" key to the expected dict (the new elif "name" in g_info branch populates it). - yumpkg group_list/group_info: replace `_yum() in ("dnf5")`, `pkg_id not in ("id")`, and `pkg_installed in ("yes")` with `==`/`!=` comparisons. These were substring-in-string checks (no trailing comma on a single-string tuple); they worked for exact equality but would have accepted any single character in those strings as a match. - yumpkg group_info: drop stray space inside `re.match( r"..." )` so black is happy. Co-authored-by: Greg Oster --- salt/modules/yumpkg.py | 10 +++++----- tests/pytests/unit/modules/test_yumpkg.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 967213661093..4ea47c426dcd 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -2512,7 +2512,7 @@ def group_list(): "available language groups:": "available languages", } - if _yum() in ("dnf5"): + if _yum() == "dnf5": out = __salt__["cmd.run_stdout"]( [_yum(), "group", "list", "--hidden"], output_loglevel="trace", @@ -2526,8 +2526,8 @@ def group_list(): match = re.match(r"^(\S+?)\s+(.+?)\s*(yes|no)$", line_lc) if match: pkg_id, pkg_name, pkg_installed = match.groups() - if pkg_id not in ("id"): - if pkg_installed in ("yes"): + if pkg_id != "id": + if pkg_installed == "yes": ret["installed"].append(pkg_id) else: ret["available"].append(pkg_id) @@ -2637,7 +2637,7 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): } ) - if _yum() in ("dnf5"): + if _yum() == "dnf5": cmd = [_yum(), "--quiet"] + options + ["group", "info", name] else: cmd = [_yum(), "--quiet"] + options + ["groupinfo", name] @@ -2704,7 +2704,7 @@ def group_info(name, expand=False, ignore_groups=None, **kwargs): # The difference here from dnf (above) is that this line # also contains the first package of this section. # Have to pull out the package name, but not changing the case - rematch_dnf5 = re.match( r"^.*:\s*(.*?)$", line) + rematch_dnf5 = re.match(r"^.*:\s*(.*?)$", line) # Let line be the match we found, and then simply # continue on, where we'll add this to the appropriate group # Can't fail... diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py index 1b062a0119dd..8b08353481de 100644 --- a/tests/pytests/unit/modules/test_yumpkg.py +++ b/tests/pytests/unit/modules/test_yumpkg.py @@ -3279,6 +3279,7 @@ def test_67975_dnf5_group_info(): ], "default": [], "conditional": [], + "type": "package group", "group": "LibreOffice", "id": "libreoffice", "description": "LibreOffice Productivity Suite",