summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-01-30 11:27:00 +0000
committerGerrit Code Review <review@openstack.org>2017-01-30 11:27:00 +0000
commitc3c2069e2ec46b35eb342386efbf366bb6340027 (patch)
treef3160b1564aeb0dff186be66c5504a06783c2455
parentce756a309a9b42dd5ce45fb08260a40b9cfcba72 (diff)
parent25b8673f84946b1072605137a4a1f60c89586489 (diff)
Merge "packages_tree: exact match trumps other providers"HEADnewton-eolstable/ocatamaster
-rw-r--r--packetary/objects/packages_tree.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/packetary/objects/packages_tree.py b/packetary/objects/packages_tree.py
index f02df59..0f6f045 100644
--- a/packetary/objects/packages_tree.py
+++ b/packetary/objects/packages_tree.py
@@ -68,25 +68,31 @@ class PackagesTree(object):
68 :param version_range: the range of versions. 68 :param version_range: the range of versions.
69 :return: the list of suitable packages 69 :return: the list of suitable packages
70 """ 70 """
71 candidates = set() 71 candidates = []
72 # find package by name
73 if name in self.packages:
74 candidates.update(self.packages.find_all(name, version_range))
75 72
76 # find package by provides 73 # find package by provides
77 # in case of rpm: 74 # in case of rpm:
78 # set(candidates) >= set(provides) 75 # set(candidates) >= set(provides)
79 if name in self.provides: 76 if name in self.provides:
80 candidates.update(self._resolve_relation( 77 candidates.extend(sorted(
81 self.provides[name], version_range) 78 self._resolve_relation(self.provides[name], version_range),
82 ) 79 key=lambda x: x.version
80 ))
81
82 # find package by name
83 if name in self.packages:
84 candidates.extend(sorted(
85 self.packages.find_all(name, version_range),
86 key=lambda x: x.version
87 ))
83 88
84 if name in self.obsoletes: 89 if name in self.obsoletes:
85 candidates.update(self._resolve_relation( 90 candidates.extend(sorted(
86 self.obsoletes[name], version_range) 91 self._resolve_relation(self.obsoletes[name], version_range),
87 ) 92 key=lambda x: x.version
93 ))
88 94
89 return sorted(candidates, key=lambda x: x.version) 95 return candidates
90 96
91 def get_unresolved_dependencies(self): 97 def get_unresolved_dependencies(self):
92 """Gets the set of unresolved dependencies. 98 """Gets the set of unresolved dependencies.