[OE-core] [PATCH 4/5] oe-pkgdata-util: add list-pkgs subcommand
Paul Eggleton
paul.eggleton at linux.intel.com
Fri Feb 6 15:44:34 UTC 2015
Add a subcommand to list packages, with options to list packages
matching a specification, and packages produced by a particular recipe.
Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
scripts/oe-pkgdata-util | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index e1ec610..bec64ff 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -253,6 +253,79 @@ def lookup_recipe(args):
items.extend(mappings.get(pkg, []))
print('\n'.join(items))
+def list_pkgs(args):
+ found = False
+
+ def matchpkg(pkg):
+ if args.pkgspec:
+ matched = False
+ for pkgspec in args.pkgspec:
+ if fnmatch.fnmatchcase(pkg, pkgspec):
+ matched = True
+ break
+ if not matched:
+ return False
+ if not args.unpackaged:
+ if args.runtime:
+ revlink = os.path.join(args.pkgdata_dir, "runtime-reverse", pkg)
+ if os.path.exists(revlink):
+ # We're unlikely to get here if the package was not packaged, but just in case
+ # we add the symlinks for unpackaged files in the future
+ mappedpkg = os.path.basename(os.readlink(revlink))
+ if not os.path.exists(os.path.join(args.pkgdata_dir, 'runtime', '%s.packaged' % mappedpkg)):
+ return False
+ else:
+ return False
+ else:
+ if not os.path.exists(os.path.join(args.pkgdata_dir, 'runtime', '%s.packaged' % pkg)):
+ return False
+ return True
+
+ if args.recipe:
+ recipedatafile = os.path.join(args.pkgdata_dir, args.recipe)
+ if not os.path.exists(recipedatafile):
+ logger.error("Unable to find packaged recipe with name %s" % args.recipe)
+ sys.exit(1)
+ packages = []
+ with open(recipedatafile, 'r') as f:
+ for line in f:
+ fields = line.rstrip().split(': ')
+ if fields[0] == 'PACKAGES':
+ packages = fields[1].split()
+ break
+
+ if args.runtime:
+ pkglist = []
+ runtime_pkgs = lookup_pkglist(packages, args.pkgdata_dir, False)
+ for rtpkgs in runtime_pkgs.values():
+ pkglist.extend(rtpkgs)
+ else:
+ pkglist = packages
+
+ for pkg in pkglist:
+ if matchpkg(pkg):
+ found = True
+ print("%s" % pkg)
+ else:
+ if args.runtime:
+ searchdir = 'runtime-reverse'
+ else:
+ searchdir = 'runtime'
+
+ for root, dirs, files in os.walk(os.path.join(args.pkgdata_dir, searchdir)):
+ for fn in files:
+ if fn.endswith('.packaged'):
+ continue
+ if matchpkg(fn):
+ found = True
+ print("%s" % fn)
+ if not found:
+ if args.pkgspec:
+ logger.error("Unable to find any package matching %s" % args.pkgspec)
+ else:
+ logger.error("No packages found")
+ sys.exit(1)
+
def find_path(args):
import json
@@ -288,6 +361,15 @@ def main():
parser_lookup_pkg.add_argument('-r', '--reverse', help='Switch to looking up recipe-space package names from runtime package names', action='store_true')
parser_lookup_pkg.set_defaults(func=lookup_pkg)
+ parser_list_pkgs = subparsers.add_parser('list-pkgs',
+ help='List packages',
+ description='Lists packages that have been built')
+ parser_list_pkgs.add_argument('pkgspec', nargs='*', help='Package name to search for (wildcards * ? allowed, use quotes to avoid shell expansion)')
+ parser_list_pkgs.add_argument('-r', '--runtime', help='Show runtime package names instead of recipe-space package names', action='store_true')
+ parser_list_pkgs.add_argument('-p', '--recipe', help='Limit to packages produced by the specified recipe')
+ parser_list_pkgs.add_argument('-u', '--unpackaged', help='Include unpackaged (i.e. empty) packages', action='store_true')
+ parser_list_pkgs.set_defaults(func=list_pkgs)
+
parser_lookup_recipe = subparsers.add_parser('lookup-recipe',
help='Find recipe producing one or more packages',
description='Looks up the specified runtime package(s) to see which recipe they were produced by')
--
1.9.3
More information about the Openembedded-core
mailing list