[elbe-devel] [PATCH] virtapt/lookup_uri: handle 'provides'

Manuel Traut manut at linutronix.de
Fri Aug 10 16:09:53 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 | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index 96efd7e3..6335bd8c 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -30,12 +30,18 @@ def getdeps(pkg):
 
 
 def lookup_uri(v, d, target_pkg):
+    try:
+        pkg = v.cache[target_pkg]
+        c = d.get_candidate_ver(pkg)
+    except KeyError:
+        pkg = None
+        c = None
 
-    pkg = v.cache[target_pkg]
-
-    c = d.get_candidate_ver(pkg)
     if not c:
-        print("%s not found" % target_pkg)
+        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])
@@ -242,8 +248,18 @@ class VirtApt:
         togo = [target_pkg]
         while len(togo):
             pp = togo.pop()
-            pkg= self.cache[pp]
-            c = d.get_candidate_ver(pkg)
+            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:
-- 
2.18.0




More information about the elbe-devel mailing list