diff options
-rwxr-xr-x | scripts/oe-pkgdata-util | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util index 9b9098215c..e4d262d7b7 100755 --- a/scripts/oe-pkgdata-util +++ b/scripts/oe-pkgdata-util | |||
@@ -274,6 +274,61 @@ def lookup_recipe(args): | |||
274 | items.extend(mappings.get(pkg, [])) | 274 | items.extend(mappings.get(pkg, [])) |
275 | print('\n'.join(items)) | 275 | print('\n'.join(items)) |
276 | 276 | ||
277 | def package_info(args): | ||
278 | # Handle both multiple arguments and multiple values within an arg (old syntax) | ||
279 | packages = [] | ||
280 | if args.file: | ||
281 | with open(args.file, 'r') as f: | ||
282 | for line in f: | ||
283 | splitline = line.split() | ||
284 | if splitline: | ||
285 | packages.append(splitline[0]) | ||
286 | else: | ||
287 | for pkgitem in args.pkg: | ||
288 | packages.extend(pkgitem.split()) | ||
289 | if not packages: | ||
290 | logger.error("No packages specified") | ||
291 | sys.exit(1) | ||
292 | |||
293 | mappings = defaultdict(lambda: defaultdict(str)) | ||
294 | for pkg in packages: | ||
295 | pkgfile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg) | ||
296 | if os.path.exists(pkgfile): | ||
297 | with open(pkgfile, 'r') as f: | ||
298 | for line in f: | ||
299 | fields = line.rstrip().split(': ') | ||
300 | if fields[0].endswith("_" + pkg): | ||
301 | k = fields[0][:len(fields[0]) - len(pkg) - 1] | ||
302 | else: | ||
303 | k = fields[0] | ||
304 | v = fields[1] if len(fields) == 2 else "" | ||
305 | mappings[pkg][k] = v | ||
306 | |||
307 | if len(mappings) < len(packages): | ||
308 | missing = list(set(packages) - set(mappings.keys())) | ||
309 | logger.error("The following packages could not be found: %s" % | ||
310 | ', '.join(missing)) | ||
311 | sys.exit(1) | ||
312 | |||
313 | items = [] | ||
314 | for pkg in packages: | ||
315 | pkg_version = mappings[pkg]['PKGV'] | ||
316 | if mappings[pkg]['PKGE']: | ||
317 | pkg_version = mappings[pkg]['PKGE'] + ":" + pkg_version | ||
318 | if mappings[pkg]['PKGR']: | ||
319 | pkg_version = pkg_version + "-" + mappings[pkg]['PKGR'] | ||
320 | recipe = mappings[pkg]['PN'] | ||
321 | recipe_version = mappings[pkg]['PV'] | ||
322 | if mappings[pkg]['PE']: | ||
323 | recipe_version = mappings[pkg]['PE'] + ":" + recipe_version | ||
324 | if mappings[pkg]['PR']: | ||
325 | recipe_version = recipe_version + "-" + mappings[pkg]['PR'] | ||
326 | pkg_size = mappings[pkg]['PKGSIZE'] | ||
327 | |||
328 | items.append("%s %s %s %s %s" % | ||
329 | (pkg, pkg_version, recipe, recipe_version, pkg_size)) | ||
330 | print('\n'.join(items)) | ||
331 | |||
277 | def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged): | 332 | def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged): |
278 | recipedatafile = os.path.join(pkgdata_dir, recipe) | 333 | recipedatafile = os.path.join(pkgdata_dir, recipe) |
279 | if not os.path.exists(recipedatafile): | 334 | if not os.path.exists(recipedatafile): |
@@ -470,6 +525,13 @@ def main(): | |||
470 | parser_lookup_recipe.add_argument('pkg', nargs='+', help='Runtime package name to look up') | 525 | parser_lookup_recipe.add_argument('pkg', nargs='+', help='Runtime package name to look up') |
471 | parser_lookup_recipe.set_defaults(func=lookup_recipe) | 526 | parser_lookup_recipe.set_defaults(func=lookup_recipe) |
472 | 527 | ||
528 | parser_package_info = subparsers.add_parser('package-info', | ||
529 | help='Shows version, recipe and size information for one or more packages', | ||
530 | description='Looks up the specified runtime package(s) and display information') | ||
531 | parser_package_info.add_argument('pkg', nargs='*', help='Runtime package name to look up') | ||
532 | parser_package_info.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)') | ||
533 | parser_package_info.set_defaults(func=package_info) | ||
534 | |||
473 | parser_find_path = subparsers.add_parser('find-path', | 535 | parser_find_path = subparsers.add_parser('find-path', |
474 | help='Find package providing a target path', | 536 | help='Find package providing a target path', |
475 | description='Finds the recipe-space package providing the specified target path') | 537 | description='Finds the recipe-space package providing the specified target path') |