summaryrefslogtreecommitdiffstats
path: root/scripts/oe-pkgdata-util
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-02-06 13:50:28 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-14 08:41:01 +0000
commit8d13d187b52039c2c663f7a780e89cf5e9c9e26d (patch)
tree00566efc696baa3a4f76017e3ccba06cede4641f /scripts/oe-pkgdata-util
parent4b330063791a4b616e2c7e17839b9c0b3ff89fd0 (diff)
downloadpoky-8d13d187b52039c2c663f7a780e89cf5e9c9e26d.tar.gz
oe-pkgdata-util: add list-pkgs subcommand
Add a subcommand to list packages, with options to list packages matching a specification, and packages produced by a particular recipe. (From OE-Core rev: a6791526fec5b78ddefcf1b6b828bd376d0f2bc0) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-pkgdata-util')
-rwxr-xr-xscripts/oe-pkgdata-util94
1 files changed, 94 insertions, 0 deletions
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index 91a1234ba4..2830f48c73 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -253,6 +253,91 @@ def lookup_recipe(args):
253 items.extend(mappings.get(pkg, [])) 253 items.extend(mappings.get(pkg, []))
254 print('\n'.join(items)) 254 print('\n'.join(items))
255 255
256def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged):
257 recipedatafile = os.path.join(pkgdata_dir, recipe)
258 if not os.path.exists(recipedatafile):
259 logger.error("Unable to find packaged recipe with name %s" % recipe)
260 sys.exit(1)
261 packages = []
262 with open(recipedatafile, 'r') as f:
263 for line in f:
264 fields = line.rstrip().split(': ')
265 if fields[0] == 'PACKAGES':
266 packages = fields[1].split()
267 break
268
269 if not unpackaged:
270 pkglist = []
271 for pkg in packages:
272 if os.path.exists(os.path.join(pkgdata_dir, 'runtime', '%s.packaged' % pkg)):
273 pkglist.append(pkg)
274 return pkglist
275 else:
276 return packages
277
278def list_pkgs(args):
279 found = False
280
281 def matchpkg(pkg):
282 if args.pkgspec:
283 matched = False
284 for pkgspec in args.pkgspec:
285 if fnmatch.fnmatchcase(pkg, pkgspec):
286 matched = True
287 break
288 if not matched:
289 return False
290 if not args.unpackaged:
291 if args.runtime:
292 revlink = os.path.join(args.pkgdata_dir, "runtime-reverse", pkg)
293 if os.path.exists(revlink):
294 # We're unlikely to get here if the package was not packaged, but just in case
295 # we add the symlinks for unpackaged files in the future
296 mappedpkg = os.path.basename(os.readlink(revlink))
297 if not os.path.exists(os.path.join(args.pkgdata_dir, 'runtime', '%s.packaged' % mappedpkg)):
298 return False
299 else:
300 return False
301 else:
302 if not os.path.exists(os.path.join(args.pkgdata_dir, 'runtime', '%s.packaged' % pkg)):
303 return False
304 return True
305
306 if args.recipe:
307 packages = get_recipe_pkgs(args.pkgdata_dir, args.recipe, args.unpackaged)
308
309 if args.runtime:
310 pkglist = []
311 runtime_pkgs = lookup_pkglist(packages, args.pkgdata_dir, False)
312 for rtpkgs in runtime_pkgs.values():
313 pkglist.extend(rtpkgs)
314 else:
315 pkglist = packages
316
317 for pkg in pkglist:
318 if matchpkg(pkg):
319 found = True
320 print("%s" % pkg)
321 else:
322 if args.runtime:
323 searchdir = 'runtime-reverse'
324 else:
325 searchdir = 'runtime'
326
327 for root, dirs, files in os.walk(os.path.join(args.pkgdata_dir, searchdir)):
328 for fn in files:
329 if fn.endswith('.packaged'):
330 continue
331 if matchpkg(fn):
332 found = True
333 print("%s" % fn)
334 if not found:
335 if args.pkgspec:
336 logger.error("Unable to find any package matching %s" % args.pkgspec)
337 else:
338 logger.error("No packages found")
339 sys.exit(1)
340
256def find_path(args): 341def find_path(args):
257 import json 342 import json
258 343
@@ -288,6 +373,15 @@ def main():
288 parser_lookup_pkg.add_argument('-r', '--reverse', help='Switch to looking up recipe-space package names from runtime package names', action='store_true') 373 parser_lookup_pkg.add_argument('-r', '--reverse', help='Switch to looking up recipe-space package names from runtime package names', action='store_true')
289 parser_lookup_pkg.set_defaults(func=lookup_pkg) 374 parser_lookup_pkg.set_defaults(func=lookup_pkg)
290 375
376 parser_list_pkgs = subparsers.add_parser('list-pkgs',
377 help='List packages',
378 description='Lists packages that have been built')
379 parser_list_pkgs.add_argument('pkgspec', nargs='*', help='Package name to search for (wildcards * ? allowed, use quotes to avoid shell expansion)')
380 parser_list_pkgs.add_argument('-r', '--runtime', help='Show runtime package names instead of recipe-space package names', action='store_true')
381 parser_list_pkgs.add_argument('-p', '--recipe', help='Limit to packages produced by the specified recipe')
382 parser_list_pkgs.add_argument('-u', '--unpackaged', help='Include unpackaged (i.e. empty) packages', action='store_true')
383 parser_list_pkgs.set_defaults(func=list_pkgs)
384
291 parser_lookup_recipe = subparsers.add_parser('lookup-recipe', 385 parser_lookup_recipe = subparsers.add_parser('lookup-recipe',
292 help='Find recipe producing one or more packages', 386 help='Find recipe producing one or more packages',
293 description='Looks up the specified runtime package(s) to see which recipe they were produced by') 387 description='Looks up the specified runtime package(s) to see which recipe they were produced by')