summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-08-19 14:20:11 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:05:50 +0100
commitae7d04832be5b9cbed29b5e78518f22660b6d178 (patch)
treeaf3efe76a6f20b4cdee2adcddd470ed530e180f4
parenta3967e2ba531fbc4880c5efe8f9d1683428297e2 (diff)
downloadpoky-ae7d04832be5b9cbed29b5e78518f22660b6d178.tar.gz
bitbake: bitbake-layers: show-recipes: allow filtering by class inheritance
Add a -i/--inherits option to filter the output to include only recipes inheriting the specified class(es). Implements [YOCTO #7475]. (Bitbake rev: e4ec622d9dc5f882049f5e8027331ec1e17681de) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/bin/bitbake-layers48
1 files changed, 43 insertions, 5 deletions
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index d6db859c3b..fb130444b1 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -54,6 +54,8 @@ def logger_create(name, output=sys.stderr):
54 54
55logger = logger_create('bitbake-layers', sys.stdout) 55logger = logger_create('bitbake-layers', sys.stdout)
56 56
57class UserError(Exception):
58 pass
57 59
58class Commands(): 60class Commands():
59 def __init__(self): 61 def __init__(self):
@@ -388,7 +390,7 @@ are overlayed will also be listed, with a " (skipped)" suffix.
388""" 390"""
389 self.init_bbhandler() 391 self.init_bbhandler()
390 392
391 items_listed = self.list_recipes('Overlayed recipes', None, True, args.same_version, args.filenames, True) 393 items_listed = self.list_recipes('Overlayed recipes', None, True, args.same_version, args.filenames, True, None)
392 394
393 # Check for overlayed .bbclass files 395 # Check for overlayed .bbclass files
394 classes = defaultdict(list) 396 classes = defaultdict(list)
@@ -451,11 +453,22 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
451""" 453"""
452 self.init_bbhandler() 454 self.init_bbhandler()
453 455
454 title = 'Available recipes:' 456 inheritlist = args.inherits.split(',') if args.inherits else []
455 self.list_recipes(title, args.pnspec, False, False, args.filenames, args.multiple) 457 if inheritlist or args.pnspec or args.multiple:
458 title = 'Matching recipes:'
459 else:
460 title = 'Available recipes:'
461 self.list_recipes(title, args.pnspec, False, False, args.filenames, args.multiple, inheritlist)
462
456 463
464 def list_recipes(self, title, pnspec, show_overlayed_only, show_same_ver_only, show_filenames, show_multi_provider_only, inherits):
465 if inherits:
466 bbpath = str(self.bbhandler.config_data.getVar('BBPATH', True))
467 for classname in inherits:
468 classfile = 'classes/%s.bbclass' % classname
469 if not bb.utils.which(bbpath, classfile, history=False):
470 raise UserError('No class named %s found in BBPATH' % classfile)
457 471
458 def list_recipes(self, title, pnspec, show_overlayed_only, show_same_ver_only, show_filenames, show_multi_provider_only):
459 pkg_pn = self.bbhandler.cooker.recipecache.pkg_pn 472 pkg_pn = self.bbhandler.cooker.recipecache.pkg_pn
460 (latest_versions, preferred_versions) = bb.providers.findProviders(self.bbhandler.config_data, self.bbhandler.cooker.recipecache, pkg_pn) 473 (latest_versions, preferred_versions) = bb.providers.findProviders(self.bbhandler.config_data, self.bbhandler.cooker.recipecache, pkg_pn)
461 allproviders = bb.providers.allProviders(self.bbhandler.cooker.recipecache) 474 allproviders = bb.providers.allProviders(self.bbhandler.cooker.recipecache)
@@ -493,6 +506,9 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
493 logger.plain("%s:", pn) 506 logger.plain("%s:", pn)
494 logger.plain(" %s %s%s", layer.ljust(20), ver, skipped) 507 logger.plain(" %s %s%s", layer.ljust(20), ver, skipped)
495 508
509 global_inherit = (self.bbhandler.config_data.getVar('INHERIT', True) or "").split()
510 cls_re = re.compile('classes/')
511
496 preffiles = [] 512 preffiles = []
497 items_listed = False 513 items_listed = False
498 for p in sorted(pkg_pn): 514 for p in sorted(pkg_pn):
@@ -504,11 +520,28 @@ skipped recipes will also be listed, with a " (skipped)" suffix.
504 pref = preferred_versions[p] 520 pref = preferred_versions[p]
505 realfn = bb.cache.Cache.virtualfn2realfn(pref[1]) 521 realfn = bb.cache.Cache.virtualfn2realfn(pref[1])
506 preffile = realfn[0] 522 preffile = realfn[0]
523
507 # We only display once per recipe, we should prefer non extended versions of the 524 # We only display once per recipe, we should prefer non extended versions of the
508 # recipe if present (so e.g. in OpenEmbedded, openssl rather than nativesdk-openssl 525 # recipe if present (so e.g. in OpenEmbedded, openssl rather than nativesdk-openssl
509 # which would otherwise sort first). 526 # which would otherwise sort first).
510 if realfn[1] and realfn[0] in self.bbhandler.cooker.recipecache.pkg_fn: 527 if realfn[1] and realfn[0] in self.bbhandler.cooker.recipecache.pkg_fn:
511 continue 528 continue
529
530 if inherits:
531 matchcount = 0
532 recipe_inherits = self.bbhandler.cooker_data.inherits.get(preffile, [])
533 for cls in recipe_inherits:
534 if cls_re.match(cls):
535 continue
536 classname = os.path.splitext(os.path.basename(cls))[0]
537 if classname in global_inherit:
538 continue
539 elif classname in inherits:
540 matchcount += 1
541 if matchcount != len(inherits):
542 # No match - skip this recipe
543 continue
544
512 if preffile not in preffiles: 545 if preffile not in preffiles:
513 preflayer = self.get_file_layer(preffile) 546 preflayer = self.get_file_layer(preffile)
514 multilayer = False 547 multilayer = False
@@ -990,6 +1023,7 @@ def main():
990 parser_show_recipes = add_command('show-recipes', cmds.do_show_recipes) 1023 parser_show_recipes = add_command('show-recipes', cmds.do_show_recipes)
991 parser_show_recipes.add_argument('-f', '--filenames', help='instead of the default formatting, list filenames of higher priority recipes with the ones they overlay indented underneath', action='store_true') 1024 parser_show_recipes.add_argument('-f', '--filenames', help='instead of the default formatting, list filenames of higher priority recipes with the ones they overlay indented underneath', action='store_true')
992 parser_show_recipes.add_argument('-m', '--multiple', help='only list where multiple recipes (in the same layer or different layers) exist for the same recipe name', action='store_true') 1025 parser_show_recipes.add_argument('-m', '--multiple', help='only list where multiple recipes (in the same layer or different layers) exist for the same recipe name', action='store_true')
1026 parser_show_recipes.add_argument('-i', '--inherits', help='only list recipes that inherit the named class', metavar='CLASS', default='')
993 parser_show_recipes.add_argument('pnspec', nargs='?', help='optional recipe name specification (wildcards allowed, enclose in quotes to avoid shell expansion)') 1027 parser_show_recipes.add_argument('pnspec', nargs='?', help='optional recipe name specification (wildcards allowed, enclose in quotes to avoid shell expansion)')
994 1028
995 parser_show_appends = add_command('show-appends', cmds.do_show_appends) 1029 parser_show_appends = add_command('show-appends', cmds.do_show_appends)
@@ -1019,7 +1053,11 @@ def main():
1019 elif args.quiet: 1053 elif args.quiet:
1020 logger.setLevel(logging.ERROR) 1054 logger.setLevel(logging.ERROR)
1021 1055
1022 ret = args.func(args) 1056 try:
1057 ret = args.func(args)
1058 except UserError as err:
1059 logger.error(str(err))
1060 ret = 1
1023 1061
1024 return ret 1062 return ret
1025 1063