[elbe-devel] [PATCH v2 3/4] virtapt/lookup_uri: handle 'provides'
Manuel Traut
manut at linutronix.de
Mon Aug 13 09:51:04 CEST 2018
If going through the dependencies of a package 'provides' might
be used instead of a real package name. If get_uri is used with
incl_deps=True lookup_uri can be called with a 'provides'
instead of a package name.
Extend lookup_uri with a loop that iterates over all packages
in the cache and check their 'provides' if the package name
can't be found in the cache. If a 'provides' matches use the
according package to return its uri.
Signed-off-by: Manuel Traut <manut at linutronix.de>
---
elbepack/virtapt.py | 48 +++++++++++++++++++++++++++++++++------------
1 file changed, 35 insertions(+), 13 deletions(-)
diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index ded50586..e486c5e5 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -30,10 +30,19 @@ def getdeps(pkg):
def lookup_uri(v, d, target_pkg):
-
- pkg = v.cache[target_pkg]
-
- c = d.get_candidate_ver(pkg)
+ try:
+ pkg = v.cache[target_pkg]
+ c = d.get_candidate_ver(pkg)
+ except KeyError:
+ pkg = None
+ c = None
+
+ if not c:
+ for pkg in v.cache.packages:
+ for x in pkg.provides_list:
+ if target_pkg == x[0]:
+ return lookup_uri(v, d, x[2].parent_pkg.name)
+ return "", "", ""
x = v.source.find_index(c.file_list[0][0])
@@ -226,15 +235,28 @@ class VirtApt:
togo = [target_pkg]
while len(togo):
pp = togo.pop()
- pkg= self.cache[pp]
- c = d.get_candidate_ver(pkg)
- for p in getdeps(c):
- if len([y for y in deps if y[0] == p]):
- continue
- if p != target_pkg and p == pp:
- continue
- deps.append(lookup_uri(self, d, p))
- togo.append(p)
+ try:
+ pkg= self.cache[pp]
+ c = d.get_candidate_ver(pkg)
+ except KeyError:
+ pkg = None
+ c = None
+ if not c:
+ for p in self.cache.packages:
+ for x in p.provides_list:
+ if pp == x[0]:
+ pkg = self.cache[x[2].parent_pkg.name]
+ c = d.get_candidate_ver(pkg)
+ if not c:
+ print("couldnt get candidate: %s" % pkg)
+ else:
+ for p in getdeps(c):
+ if len([y for y in deps if y[0] == p]):
+ continue
+ if p != target_pkg and p == pp:
+ continue
+ deps.append(lookup_uri(self, d, p))
+ togo.append(p)
return deps
--
2.18.0
More information about the elbe-devel
mailing list