One recipetool fix and a couple enhancements
cover One recipetool fix and a couple enhancements
With this in, we can add custom recipetool commands in layers, which is a useful capability. For Mentor, I intend to add
https://gist.github.com/kergoth/14ea8d0932f321b60d49 into meta-mentor/meta-mel/lib/recipetool/ to get some convenience sub-commands available:
$ recipetool kernel_set_defconfig meta-mylayer /path/to/defconfig
$ recipetool kernel_add_fragments meta-mylayer one.cfg two.cfg
$ recipetool kernel_set_configs meta-mylayer CONFIG_LOCALVERSION_AUTO=n CONFIG_LOCALVERSION=-test
$ recipetool kernel_add_dts meta-mylayer *.dtsThe following changes since commit 592a1d94a7b0e80059016adb59c4c61e256206f0:
oeqa/parselogs: Whitelist qemumips64 runtime error (2015-06-27 22:49:49 +0100)
are available in the git repository at:
[email protected]:kergoth/openembedded-core recipetool-bits
for you to fetch changes up to 974591c62ec573ee96badb28786aacd3df35ca53:
recipetool.append: add extralines arg to appendsrc (2015-06-29 08:31:45 -0700)
----------------------------------------------------------------
Christopher Larson (3):
recipetool: catch BBHandledException from parsing
recipetool: also load plugins from BBPATH recipetool.append: add extralines arg to appendsrc
scripts/lib/recipetool/append.py | 4 +-- scripts/recipetool | 73 ++++++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 31 deletions(-)
Signature · 1 line
2.2.1
PATCH 1/3 recipetool: catch BBHandledException from parsing
This ensures that we don't see a traceback on parsing failures.
--- scripts/recipetool | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
scripts/recipetool +5 -3
@@ -82,9 +82,11 @@ def main(): scriptutils.logger_setup_color(logger, args.color) - tinfoil_init(getattr(args, 'parserecipes', False)) - - ret = args.func(args) + try: + tinfoil_init(getattr(args, 'parserecipes', False)) + ret = args.func(args) + except bb.BBHandledException: + ret = 1 return ret
Signature · 1 line
2.2.1
PATCH 2/3 recipetool: also load plugins from BBPATH
This makes it easier to extend, as a layer can add its own sub-commands.
--- scripts/recipetool | 67 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 27 deletions(-)
scripts/recipetool +40 -27
@@ -36,11 +36,8 @@ def tinfoil_init(parserecipes): import logging tinfoil = bb.tinfoil.Tinfoil() tinfoil.prepare(not parserecipes) - - for plugin in plugins: - if hasattr(plugin, 'tinfoil_init'): - plugin.tinfoil_init(tinfoil) tinfoil.logger.setLevel(logger.getEffectiveLevel()) + return tinfoil def main():
@@ -48,42 +45,58 @@ def main(): logger.error("This script can only be run after initialising the build environment (e.g. by using oe-init-build-env)") sys.exit(1) - parser = argparse.ArgumentParser(description="OpenEmbedded recipe tool", - epilog="Use %(prog)s <subcommand> --help to get help on a specific command") - parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') - parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') - parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') - subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>') + def create_global_parser(**kwargs): + parser = argparse.ArgumentParser(description="OpenEmbedded recipe tool", + epilog="Use %(prog)s <subcommand> --help to get help on a specific command", **kwargs) + parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') + parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') + parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') + return parser + + parser = create_global_parser(add_help=False) + initial_args, unparsed_args = parser.parse_known_args(sys.argv[1:]) + if initial_args.debug: + logger.setLevel(logging.DEBUG) + elif initial_args.quiet: + logger.setLevel(logging.ERROR) + + # Re-create the parser here because adding the subparsers doesn't cause + # ArgumentParser to re-generate the formatted help text after + # parse_known_args() + parser = create_global_parser() + + import scriptpath + bitbakepath = scriptpath.add_bitbake_lib_path() + if not bitbakepath: + logger.error("Unable to find bitbake by searching parent directory of this script or PATH") + sys.exit(1) + logger.debug('Found bitbake path: %s' % bitbakepath) - scriptutils.load_plugins(logger, plugins, os.path.join(scripts_path, 'lib', 'recipetool')) + scriptutils.logger_setup_color(logger, initial_args.color) + + subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>') + tinfoil = tinfoil_init(False) + for path in ([scripts_path] + + tinfoil.config_data.getVar('BBPATH', True).split(':')): + pluginpath = os.path.join(path, 'lib', 'recipetool') + scriptutils.load_plugins(logger, plugins, pluginpath) registered = False for plugin in plugins: if hasattr(plugin, 'register_command'): registered = True plugin.register_command(subparsers) + if hasattr(plugin, 'tinfoil_init'): + plugin.tinfoil_init(tinfoil) if not registered: logger.error("No commands registered - missing plugins?") sys.exit(1) - args = parser.parse_args() - - if args.debug: - logger.setLevel(logging.DEBUG) - elif args.quiet: - logger.setLevel(logging.ERROR) - - import scriptpath - bitbakepath = scriptpath.add_bitbake_lib_path() - if not bitbakepath: - logger.error("Unable to find bitbake by searching parent directory of this script or PATH") - sys.exit(1) - logger.debug('Found bitbake path: %s' % bitbakepath) - - scriptutils.logger_setup_color(logger, args.color) + args = parser.parse_args(unparsed_args, namespace=initial_args) try: - tinfoil_init(getattr(args, 'parserecipes', False)) + if getattr(args, 'parserecipes', False): + tinfoil.parseRecipes() ret = args.func(args) except bb.BBHandledException: ret = 1
Signature · 1 line
2.2.1
PATCH 3/3 recipetool.append: add extralines arg to appendsrc
In reply to Christopher LarsonThis makes the function more reusable for other sub-commands.
--- scripts/lib/recipetool/append.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/lib/recipetool/append.py +2 -2
@@ -334,7 +334,7 @@ def appendfile(args): return 3 -def appendsrc(args, files, rd): +def appendsrc(args, files, rd, extralines=None): import oe.recipeutils srcdir = rd.getVar('S', True)
@@ -349,7 +349,7 @@ def appendsrc(args, files, rd): simplified[simple_uri] = uri copyfiles = {} - extralines = [] + extralines = extralines or [] for newfile, srcfile in files.iteritems(): src_destdir = os.path.dirname(srcfile) if not args.use_workdir:
Signature · 1 line
2.2.1