[OE-core] [PATCH 1/4] scripts/oe-pkgdata-util: support rprovides for lookup-recipe

Hongxu Jia hongxu.jia at windriver.com
Wed Jan 7 07:06:49 UTC 2015


If failed to invoke lookup-recipe while pkg not generated but provided
by others, such as python3, it is provided by python3-core
...
$ bitbake python3
$ oe-pkgdata-util -d lookup-recipe tmp/sysroots/qemux86/pkgdata/ "python3"
ERROR: the following packages could not be found: python3
...

In this situation, we search the pkg's rprovides (if available) to replace.

[YOCTO #5264]

Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
---
 scripts/oe-pkgdata-util | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index bf87547..e43f773 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -27,6 +27,7 @@ import fnmatch
 import re
 import optparse
 from collections import defaultdict
+import codecs
 
 def glob(args, usage, debug=False):
     if len(args) < 3:
@@ -234,6 +235,19 @@ def lookup_recipe(args, usage, debug=False):
         print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir)
         sys.exit(1)
 
+    # If the pkg not generated, search the rprovides to replace
+    rprovides = collect_rprovides(pkgdata_dir)
+    for pkg in pkgs[:]:
+        pkgfile = os.path.join(pkgdata_dir, 'runtime', pkg)
+        if not os.path.exists(pkgfile):
+            for newpkg, oldpkg in rprovides.items():
+                if oldpkg == pkg:
+                    if debug:
+                        print('%s rprovides %s' % (newpkg, pkg))
+                    pkgs.remove(pkg)
+                    pkgs.append(newpkg)
+                    break
+
     mappings = defaultdict(list)
     for pkg in pkgs:
         pkgfile = os.path.join(pkgdata_dir, 'runtime-reverse', pkg)
@@ -254,6 +268,46 @@ def lookup_recipe(args, usage, debug=False):
         items.extend(mappings.get(pkg, []))
     print '\n'.join(items)
 
+def collect_rprovides(pkgdata_dir):
+    def read_pkgdatafile(fn):
+        pkgdata = {}
+        def decode(str):
+            c = codecs.getdecoder("string_escape")
+            return c(str)[0]
+
+        if os.access(fn, os.R_OK):
+            import re
+            f = open(fn, 'r')
+            lines = f.readlines()
+            f.close()
+            r = re.compile("([^:]+):\s*(.*)")
+            for l in lines:
+                m = r.match(l)
+                if m:
+                    pkgdata[m.group(1)] = decode(m.group(2))
+        return pkgdata
+
+    rprovides_dict = dict()
+    if os.path.exists(pkgdata_dir):
+        for root, dirs, files in os.walk("%s/runtime" % pkgdata_dir):
+            for pkgname in files:
+                pkgdatafile = "%s/%s" % (root, pkgname)
+                if not os.access("%s.packaged" % pkgdatafile, os.R_OK):
+                    continue
+
+                try:
+                    sdata = read_pkgdatafile(pkgdatafile)
+                    rprovides = sdata.get('RPROVIDES_%s' % pkgname)
+                    if rprovides:
+                        rprovides_dict[pkgname] = rprovides
+
+                except Exception as e:
+                    print("ERROR:%s: Failed to read pkgdata file %s: %s: %s" %
+                          (pkgname, pkgdatafile, e.__class__, str(e)))
+                    sys.exit(1)
+
+    return rprovides_dict
+
 def find_path(args, usage, debug=False):
     if len(args) < 2:
         usage()
-- 
1.9.1




More information about the Openembedded-core mailing list