summaryrefslogtreecommitdiff
path: root/scripts/lib/devtool
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-12-22 17:03:04 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-22 16:44:03 +0000
commitdbfe8fa2e86c2bb50bef47c389017cdf93543321 (patch)
tree91ab47b4825a2aea451f9ef1f85d0bdcf79dc1ea /scripts/lib/devtool
parent944eacfb849ee69b41e12c9de4f264406281ac6a (diff)
downloadopenembedded-core-dbfe8fa2e86c2bb50bef47c389017cdf93543321.tar.gz
openembedded-core-dbfe8fa2e86c2bb50bef47c389017cdf93543321.tar.bz2
openembedded-core-dbfe8fa2e86c2bb50bef47c389017cdf93543321.zip
devtool: edit-recipe: add new subcommand
Add an "edit-recipe" subcommand that runs your default editor (as specified by the EDITOR environment variable) on the specified recipe in the workspace. Note that by default the recipe file itself must be in the workspace - i.e. as a result of "devtool add" or "devtool upgrade"; however there is a -a/--any-recipe option to override this. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool')
-rw-r--r--scripts/lib/devtool/standard.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index a5e81f31eb..c11de9d35d 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -1140,6 +1140,44 @@ def reset(args, config, basepath, workspace):
return 0
+def edit_recipe(args, config, basepath, workspace):
+ """Entry point for the devtool 'edit-recipe' subcommand"""
+ if args.any_recipe:
+ tinfoil = setup_tinfoil(config_only=False, basepath=basepath)
+ try:
+ rd = parse_recipe(config, tinfoil, args.recipename, True)
+ if not rd:
+ return 1
+ recipefile = rd.getVar('FILE', True)
+ finally:
+ tinfoil.shutdown()
+ else:
+ check_workspace_recipe(workspace, args.recipename)
+ bbappend = workspace[args.recipename]['bbappend']
+ bbfile = os.path.basename(bbappend).replace('.bbappend', '.bb').replace('%', '*')
+ recipefile = glob.glob(os.path.join(config.workspace_path,
+ 'recipes',
+ args.recipename,
+ bbfile))
+ if recipefile:
+ recipefile = recipefile[0]
+ else:
+ raise DevtoolError("Recipe file for %s is not under the workspace" %
+ args.recipename)
+
+ editor = os.environ.get('EDITOR', None)
+ if not editor:
+ raise DevtoolError("EDITOR environment variable not set")
+
+ import subprocess
+ try:
+ subprocess.check_call('%s "%s"' % (editor, recipefile), shell=True)
+ except subprocess.CalledProcessError as e:
+ return e.returncode
+
+ return 0
+
+
def register_commands(subparsers, context):
"""Register devtool subcommands from this plugin"""
parser_add = subparsers.add_parser('add', help='Add a new recipe',
@@ -1204,3 +1242,9 @@ def register_commands(subparsers, context):
parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)')
parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output')
parser_reset.set_defaults(func=reset)
+
+ parser_edit_recipe = subparsers.add_parser('edit-recipe', help='Edit a recipe file in your workspace',
+ description='Runs the default editor (as specified by the EDITOR variable) on the specified recipe. Note that the recipe file itself must be in the workspace (i.e. as a result of "devtool add" or "devtool upgrade"); you can override this with the -a/--any-recipe option.')
+ parser_edit_recipe.add_argument('recipename', help='Recipe to edit')
+ parser_edit_recipe.add_argument('--any-recipe', '-a', action="store_true", help='Edit any recipe, not just where the recipe file itself is in the workspace')
+ parser_edit_recipe.set_defaults(func=edit_recipe)