diff options
author | Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com> | 2017-06-05 16:43:55 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:52:51 +0100 |
commit | 576821ea0a7558b626ccc87e9ae0e9ee40864956 (patch) | |
tree | 436e9076e21da7dca0922e47986e6aec6f603883 | |
parent | 1125621b921763ff73614aae228d2d5dbb5bd2ce (diff) | |
download | poky-576821ea0a7558b626ccc87e9ae0e9ee40864956.tar.gz |
bitbake: bitbake-layers: check layer dependencies before adding
In the original implementation, "bitbake-layers add-layers <layer>"
succeeded without error checking. This will further introduce
failures in recipe parsing only when "bitbake" command is executed.
Adding a meta layer without its dependency layer(s) should failed
and exit the process gracefully.
Added extra argument "-F" to force add a layer without checking
layer dependency.
[YOCTO #10913]
(Bitbake rev: 705ab252e631903e6d2e46202b419a9e8adcd861)
Signed-off-by: Phoong Stanley Cheong Kwan <stanley.cheong.kwan.phoong@intel.com>
Signed-off-by: Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/bitbake-layers | 1 | ||||
-rw-r--r-- | bitbake/lib/bblayers/action.py | 26 |
2 files changed, 23 insertions, 4 deletions
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers index 2b05d28470..04e6bec251 100755 --- a/bitbake/bin/bitbake-layers +++ b/bitbake/bin/bitbake-layers | |||
@@ -43,6 +43,7 @@ def main(): | |||
43 | add_help=False) | 43 | add_help=False) |
44 | parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') | 44 | parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') |
45 | parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') | 45 | parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') |
46 | parser.add_argument('-F', '--force', help='Force add without recipe parse verification', action='store_true') | ||
46 | parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') | 47 | parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') |
47 | 48 | ||
48 | global_args, unparsed_args = parser.parse_known_args() | 49 | global_args, unparsed_args = parser.parse_known_args() |
diff --git a/bitbake/lib/bblayers/action.py b/bitbake/lib/bblayers/action.py index cf9470427a..b1326e5f53 100644 --- a/bitbake/lib/bblayers/action.py +++ b/bitbake/lib/bblayers/action.py | |||
@@ -1,7 +1,9 @@ | |||
1 | import fnmatch | 1 | import fnmatch |
2 | import logging | 2 | import logging |
3 | import os | 3 | import os |
4 | import shutil | ||
4 | import sys | 5 | import sys |
6 | import tempfile | ||
5 | 7 | ||
6 | import bb.utils | 8 | import bb.utils |
7 | 9 | ||
@@ -32,10 +34,26 @@ class ActionPlugin(LayerPlugin): | |||
32 | sys.stderr.write("Unable to find bblayers.conf\n") | 34 | sys.stderr.write("Unable to find bblayers.conf\n") |
33 | return 1 | 35 | return 1 |
34 | 36 | ||
35 | notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None) | 37 | # Back up bblayers.conf to tempdir before we add layers |
36 | if notadded: | 38 | tempdir = tempfile.mkdtemp() |
37 | for item in notadded: | 39 | backup = tempdir + "/bblayers.conf.bak" |
38 | sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item) | 40 | shutil.copy2(bblayers_conf, backup) |
41 | |||
42 | try: | ||
43 | notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None) | ||
44 | if not (args.force or notadded): | ||
45 | try: | ||
46 | self.tinfoil.parseRecipes() | ||
47 | except bb.tinfoil.TinfoilUIException: | ||
48 | # Restore the back up copy of bblayers.conf | ||
49 | shutil.copy2(backup, bblayers_conf) | ||
50 | bb.fatal("Parse failure with the specified layer added") | ||
51 | else: | ||
52 | for item in notadded: | ||
53 | sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item) | ||
54 | finally: | ||
55 | # Remove the back up copy of bblayers.conf | ||
56 | shutil.rmtree(tempdir) | ||
39 | 57 | ||
40 | def do_remove_layer(self, args): | 58 | def do_remove_layer(self, args): |
41 | """Remove a layer from bblayers.conf.""" | 59 | """Remove a layer from bblayers.conf.""" |