summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/standard.py
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-28 09:25:13 +0000
commit316b57b62e2607e4ffd20377fec3276594b802b4 (patch)
treee7ebd4befe3247e891ddd36fd5d56725e03b0c5f /scripts/lib/devtool/standard.py
parentebe5f0b872751fd11167a018f1ff7dc350da476e (diff)
downloadpoky-316b57b62e2607e4ffd20377fec3276594b802b4.tar.gz
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. (From OE-Core rev: dbfe8fa2e86c2bb50bef47c389017cdf93543321) 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/standard.py')
-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):
1140 return 0 1140 return 0
1141 1141
1142 1142
1143def edit_recipe(args, config, basepath, workspace):
1144 """Entry point for the devtool 'edit-recipe' subcommand"""
1145 if args.any_recipe:
1146 tinfoil = setup_tinfoil(config_only=False, basepath=basepath)
1147 try:
1148 rd = parse_recipe(config, tinfoil, args.recipename, True)
1149 if not rd:
1150 return 1
1151 recipefile = rd.getVar('FILE', True)
1152 finally:
1153 tinfoil.shutdown()
1154 else:
1155 check_workspace_recipe(workspace, args.recipename)
1156 bbappend = workspace[args.recipename]['bbappend']
1157 bbfile = os.path.basename(bbappend).replace('.bbappend', '.bb').replace('%', '*')
1158 recipefile = glob.glob(os.path.join(config.workspace_path,
1159 'recipes',
1160 args.recipename,
1161 bbfile))
1162 if recipefile:
1163 recipefile = recipefile[0]
1164 else:
1165 raise DevtoolError("Recipe file for %s is not under the workspace" %
1166 args.recipename)
1167
1168 editor = os.environ.get('EDITOR', None)
1169 if not editor:
1170 raise DevtoolError("EDITOR environment variable not set")
1171
1172 import subprocess
1173 try:
1174 subprocess.check_call('%s "%s"' % (editor, recipefile), shell=True)
1175 except subprocess.CalledProcessError as e:
1176 return e.returncode
1177
1178 return 0
1179
1180
1143def register_commands(subparsers, context): 1181def register_commands(subparsers, context):
1144 """Register devtool subcommands from this plugin""" 1182 """Register devtool subcommands from this plugin"""
1145 parser_add = subparsers.add_parser('add', help='Add a new recipe', 1183 parser_add = subparsers.add_parser('add', help='Add a new recipe',
@@ -1204,3 +1242,9 @@ def register_commands(subparsers, context):
1204 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)') 1242 parser_reset.add_argument('--all', '-a', action="store_true", help='Reset all recipes (clear workspace)')
1205 parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output') 1243 parser_reset.add_argument('--no-clean', '-n', action="store_true", help='Don\'t clean the sysroot to remove recipe output')
1206 parser_reset.set_defaults(func=reset) 1244 parser_reset.set_defaults(func=reset)
1245
1246 parser_edit_recipe = subparsers.add_parser('edit-recipe', help='Edit a recipe file in your workspace',
1247 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.')
1248 parser_edit_recipe.add_argument('recipename', help='Recipe to edit')
1249 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')
1250 parser_edit_recipe.set_defaults(func=edit_recipe)