[oe-commits] Paul Eggleton : scripts/oe-pkgdata-util: add ability to find a recipe from a target package

git at git.openembedded.org git at git.openembedded.org
Tue Oct 29 10:27:08 UTC 2013


Module: openembedded-core.git
Branch: master
Commit: 4ab561ac3df105b4b6487271b6ccc29445518d52
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=4ab561ac3df105b4b6487271b6ccc29445518d52

Author: Paul Eggleton <paul.eggleton at linux.intel.com>
Date:   Fri Oct 18 14:52:10 2013 +0100

scripts/oe-pkgdata-util: add ability to find a recipe from a target package

Add a "lookup-recipe" command to show which recipe produced a particular
package.

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>

---

 scripts/oe-pkgdata-util |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index 08773e9..80cacc5 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -219,6 +219,38 @@ def lookup_pkg(args, usage):
         items.extend(mappings.get(pkg, []))
     print '\n'.join(items)
 
+def lookup_recipe(args, usage):
+    if len(args) < 2:
+        usage()
+        sys.exit(1)
+
+    pkgdata_dir = args[0]
+    pkgs = args[1].split()
+
+    if not os.path.exists(pkgdata_dir):
+        print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir)
+        sys.exit(1)
+
+    mappings = defaultdict(list)
+    for pkg in pkgs:
+        pkgfile = os.path.join(pkgdata_dir, 'runtime-reverse', pkg)
+        if os.path.exists(pkgfile):
+            with open(pkgfile, 'r') as f:
+                for line in f:
+                    fields = line.rstrip().split(': ')
+                    if fields[0] == 'PN':
+                        mappings[pkg].append(fields[1])
+                        break
+    if len(mappings) < len(pkgs):
+        missing = list(set(pkgs) - set(mappings.keys()))
+        sys.stderr.write("ERROR: the following packages could not be found: %s\n" % ', '.join(missing))
+        sys.exit(1)
+
+    items = []
+    for pkg in pkgs:
+        items.extend(mappings.get(pkg, []))
+    print '\n'.join(items)
+
 def find_path(args, usage):
     if len(args) < 2:
         usage()
@@ -263,6 +295,9 @@ Available commands:
     lookup-pkg <pkgdatadir> "<recipe-pkgs>"
         look up the specified recipe-space package name(s) to see what the
         final runtime package name is (e.g. eglibc becomes libc6)
+    lookup-recipe <pkgdatadir> "<pkgs>"
+        look up the specified package(s) to see which recipe they were
+        produced by
     find-path <pkgdatadir> <path>
         find the package providing the specified path (wildcards * ? allowed)
     read-value <pkgdatadir> <value-name> "<pkgs>"
@@ -284,6 +319,8 @@ Available commands:
         glob(args[1:], parser.print_help)
     elif args[0] == "lookup-pkg":
         lookup_pkg(args[1:], parser.print_help)
+    elif args[0] == "lookup-recipe":
+        lookup_recipe(args[1:], parser.print_help)
     elif args[0] == "find-path":
         find_path(args[1:], parser.print_help)
     elif args[0] == "read-value":



More information about the Openembedded-commits mailing list