xref: /openbmc/openbmc/poky/scripts/lib/recipetool/edit.py (revision d25ed3241ddffad58c7a52e45e388e6c48d5123a)
1# Recipe creation tool - edit plugin
2#
3# This sub-command edits the recipe and appends for the specified target
4#
5# Example: recipetool edit busybox
6#
7# Copyright (C) 2018 Mentor Graphics Corporation
8#
9# SPDX-License-Identifier: GPL-2.0-only
10#
11
12import argparse
13import errno
14import logging
15import os
16import re
17import subprocess
18import sys
19import scriptutils
20
21
22logger = logging.getLogger('recipetool')
23tinfoil = None
24
25
26def tinfoil_init(instance):
27    global tinfoil
28    tinfoil = instance
29
30
31def edit(args):
32    import oe.recipeutils
33
34    recipe_path = tinfoil.get_recipe_file(args.target)
35    appends = tinfoil.get_file_appends(recipe_path)
36
37    return scriptutils.run_editor([recipe_path] + list(appends), logger)
38
39
40def register_commands(subparsers):
41    parser = subparsers.add_parser('edit',
42                                   help='Edit the recipe and appends for the specified target. This obeys $VISUAL if set, otherwise $EDITOR, otherwise vi.')
43    parser.add_argument('target', help='Target recipe/provide to edit')
44    parser.set_defaults(func=edit, parserecipes=True)
45