summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAlexander D. Kanevskiy <kad@kad.name>2016-06-08 18:07:43 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-12 23:47:17 +0100
commit61ba9308d176af3c056084b5ce932d4472e4590a (patch)
treeca5111c3c2c9153948bb22b675f3a6d5ffd3b0ba /scripts
parent8a6c198381ba238d7a2d29c02745d87c5ea30b66 (diff)
downloadpoky-61ba9308d176af3c056084b5ce932d4472e4590a.tar.gz
oe-pkgdata-util: new option to provide full info for binary package(s)
New option can be used for displaying full information about binary package(s), including name, full version, recipe name, recipe full version and package size. This information can be useful inside custom buildhistory class to produce detailed image manifest for further analysis. List of packages can be specified as command line arguments or can be read from file (e.g. from existing image manifest). Warning: In case of image manifest is used as input outside of build process, be aware that pkgdata might change since the time image was built. Output format: {PKG} [PKGE:]{PKGV}[-{PKGR}] {PN} [PE:]{PV}[-{PR}] {PKGSIZE} (From OE-Core rev: bc0cdaa927124150a6c38cd47977ee4da8dd440e) Signed-off-by: Alexander D. Kanevskiy <kad@kad.name> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/oe-pkgdata-util62
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
277def 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
277def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged): 332def 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')