* [PATCH 0/3] One recipetool fix and a couple enhancements
@ 2015-06-29 20:49 Christopher Larson
2015-06-29 20:50 ` [PATCH 1/3] recipetool: catch BBHandledException from parsing Christopher Larson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christopher Larson @ 2015-06-29 20:49 UTC (permalink / raw)
To: openembedded-core
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 *.dts
The 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:
git@github.com: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(-)
--
2.2.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] recipetool: catch BBHandledException from parsing
2015-06-29 20:49 [PATCH 0/3] One recipetool fix and a couple enhancements Christopher Larson
@ 2015-06-29 20:50 ` Christopher Larson
2015-06-29 20:50 ` [PATCH 2/3] recipetool: also load plugins from BBPATH Christopher Larson
2015-06-29 20:50 ` [PATCH 3/3] recipetool.append: add extralines arg to appendsrc Christopher Larson
2 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2015-06-29 20:50 UTC (permalink / raw)
To: openembedded-core
This ensures that we don't see a traceback on parsing failures.
Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
scripts/recipetool | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/recipetool b/scripts/recipetool
index c68bef4..3063cf7 100755
--- a/scripts/recipetool
+++ b/scripts/recipetool
@@ -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
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] recipetool: also load plugins from BBPATH
2015-06-29 20:49 [PATCH 0/3] One recipetool fix and a couple enhancements Christopher Larson
2015-06-29 20:50 ` [PATCH 1/3] recipetool: catch BBHandledException from parsing Christopher Larson
@ 2015-06-29 20:50 ` Christopher Larson
2015-06-29 20:50 ` [PATCH 3/3] recipetool.append: add extralines arg to appendsrc Christopher Larson
2 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2015-06-29 20:50 UTC (permalink / raw)
To: openembedded-core
This makes it easier to extend, as a layer can add its own sub-commands.
Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
scripts/recipetool | 67 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 40 insertions(+), 27 deletions(-)
diff --git a/scripts/recipetool b/scripts/recipetool
index 3063cf7..5ebef6b 100755
--- a/scripts/recipetool
+++ b/scripts/recipetool
@@ -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
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] recipetool.append: add extralines arg to appendsrc
2015-06-29 20:49 [PATCH 0/3] One recipetool fix and a couple enhancements Christopher Larson
2015-06-29 20:50 ` [PATCH 1/3] recipetool: catch BBHandledException from parsing Christopher Larson
2015-06-29 20:50 ` [PATCH 2/3] recipetool: also load plugins from BBPATH Christopher Larson
@ 2015-06-29 20:50 ` Christopher Larson
2 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2015-06-29 20:50 UTC (permalink / raw)
To: openembedded-core
This makes the function more reusable for other sub-commands.
Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
scripts/lib/recipetool/append.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py
index 9903871..24a7903 100644
--- a/scripts/lib/recipetool/append.py
+++ b/scripts/lib/recipetool/append.py
@@ -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:
--
2.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-29 20:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-29 20:49 [PATCH 0/3] One recipetool fix and a couple enhancements Christopher Larson
2015-06-29 20:50 ` [PATCH 1/3] recipetool: catch BBHandledException from parsing Christopher Larson
2015-06-29 20:50 ` [PATCH 2/3] recipetool: also load plugins from BBPATH Christopher Larson
2015-06-29 20:50 ` [PATCH 3/3] recipetool.append: add extralines arg to appendsrc Christopher Larson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox