diff options
author | Christopher Larson <chris_larson@mentor.com> | 2016-02-09 16:12:06 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-11 12:27:49 +0000 |
commit | 6fab5fc1bbf491e175ae77d6af679e73d6aa61eb (patch) | |
tree | 03205ea2d373b52e2bf83124bea9e7912d0e2a16 | |
parent | 252f97ec9234f09a049635538e665a985bbb7f0f (diff) | |
download | poky-6fab5fc1bbf491e175ae77d6af679e73d6aa61eb.tar.gz |
recipetool.newappend: add -e/--edit argument
(From OE-Core rev: 2bd518fe3a8cb0022a816a7d1ac8d9a3dedee6d9)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/recipetool/newappend.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/scripts/lib/recipetool/newappend.py b/scripts/lib/recipetool/newappend.py index f9b8d85ecf..5625a8ed52 100644 --- a/scripts/lib/recipetool/newappend.py +++ b/scripts/lib/recipetool/newappend.py | |||
@@ -25,6 +25,7 @@ import errno | |||
25 | import logging | 25 | import logging |
26 | import os | 26 | import os |
27 | import re | 27 | import re |
28 | import subprocess | ||
28 | import sys | 29 | import sys |
29 | 30 | ||
30 | 31 | ||
@@ -89,17 +90,26 @@ def newappend(args): | |||
89 | bb.utils.mkdirhier(os.path.dirname(append_path)) | 90 | bb.utils.mkdirhier(os.path.dirname(append_path)) |
90 | 91 | ||
91 | try: | 92 | try: |
92 | open(append_path, 'a') | 93 | open(append_path, 'a').close() |
93 | except (OSError, IOError) as exc: | 94 | except (OSError, IOError) as exc: |
94 | logger.critical(str(exc)) | 95 | logger.critical(str(exc)) |
95 | return 1 | 96 | return 1 |
96 | 97 | ||
97 | print(append_path) | 98 | if args.edit: |
99 | editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi')) | ||
100 | try: | ||
101 | return subprocess.check_call([editor, append_path, recipe_path]) | ||
102 | except OSError as exc: | ||
103 | logger.error("Execution of editor '%s' failed: %s", editor, exc) | ||
104 | return 1 | ||
105 | else: | ||
106 | print(append_path) | ||
98 | 107 | ||
99 | 108 | ||
100 | def register_commands(subparsers): | 109 | def register_commands(subparsers): |
101 | parser = subparsers.add_parser('newappend', | 110 | parser = subparsers.add_parser('newappend', |
102 | help='Create a bbappend for the specified target in the specified layer') | 111 | help='Create a bbappend for the specified target in the specified layer') |
112 | parser.add_argument('-e', '--edit', help='Edit the new append. This obeys $VISUAL if set, otherwise $EDITOR, otherwise vi.', action='store_true') | ||
103 | parser.add_argument('-w', '--wildcard-version', help='Use wildcard to make the bbappend apply to any recipe version', action='store_true') | 113 | parser.add_argument('-w', '--wildcard-version', help='Use wildcard to make the bbappend apply to any recipe version', action='store_true') |
104 | parser.add_argument('destlayer', help='Base directory of the destination layer to write the bbappend to', type=layer) | 114 | parser.add_argument('destlayer', help='Base directory of the destination layer to write the bbappend to', type=layer) |
105 | parser.add_argument('target', help='Target recipe/provide to append') | 115 | parser.add_argument('target', help='Target recipe/provide to append') |