Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
salt.21871
zypperpkg-filter-patterns-that-start-with-dot-2...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File zypperpkg-filter-patterns-that-start-with-dot-244.patch of Package salt.21871
From c9543da431aab06c39911c2217e9cb449b63f8e3 Mon Sep 17 00:00:00 2001 From: Alberto Planas <aplanas@suse.com> Date: Thu, 21 May 2020 10:19:15 +0200 Subject: [PATCH] zypperpkg: filter patterns that start with dot (#244) For versions <=SLE12SP4 some patterns can contain alias, and can appear duplicated. The alias start with ".", so they can be filtered. If the module try to search by the alias name (pattern:.basename, for example), zypper will not be able to find it and the operation will fail. This patch detect and filter the alias, and remove duplicates. Fix bsc#1171906 (cherry picked from commit d043db63000df2892b2e7259f580ede81e33724d) --- salt/modules/zypperpkg.py | 9 ++++++--- tests/unit/modules/test_zypperpkg.py | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py index b75572f4ff..ffcd1dfa4f 100644 --- a/salt/modules/zypperpkg.py +++ b/salt/modules/zypperpkg.py @@ -2422,11 +2422,14 @@ def _get_installed_patterns(root=None): # a real error. output = __salt__["cmd.run"](cmd, ignore_retcode=True) - installed_patterns = [ + # On <= SLE12SP4 we have patterns that have multiple names (alias) + # and that are duplicated. The alias start with ".", so we filter + # them. + installed_patterns = { _pattern_name(line) for line in output.splitlines() - if line.startswith("pattern() = ") - ] + if line.startswith("pattern() = ") and not _pattern_name(line).startswith(".") + } patterns = { k: v for k, v in _get_visible_patterns(root=root).items() if v["installed"] diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py index 1b62122e0e..b346ef9ebd 100644 --- a/tests/unit/modules/test_zypperpkg.py +++ b/tests/unit/modules/test_zypperpkg.py @@ -1978,6 +1978,28 @@ pattern() = package-c""" "package-c": {"installed": True, "summary": "Non-visible pattern",}, } + @patch("salt.modules.zypperpkg._get_visible_patterns") + def test__get_installed_patterns_with_alias(self, get_visible_patterns): + """Test installed patterns in the system if they have alias""" + get_visible_patterns.return_value = { + "package-a": {"installed": True, "summary": "description a"}, + "package-b": {"installed": False, "summary": "description b"}, + } + + salt_mock = { + "cmd.run": MagicMock( + return_value="""pattern() = .package-a-alias +pattern() = package-a +pattern-visible() +pattern() = package-c""" + ), + } + with patch.dict("salt.modules.zypperpkg.__salt__", salt_mock): + assert zypper._get_installed_patterns() == { + "package-a": {"installed": True, "summary": "description a"}, + "package-c": {"installed": True, "summary": "Non-visible pattern"}, + } + @patch("salt.modules.zypperpkg._get_visible_patterns") def test_list_patterns(self, get_visible_patterns): """Test available patterns in the repo""" -- 2.29.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor