bitbake-layers: check layer dependencies before adding
PATCH v3 1/1 bitbake-layers: check layer dependencies before adding
Change log on v3 patch:
- Use "-F" for force add argument flags.
- This is because "-f" was already been use by oe-selftest causing argument flags overridden and failed oe-selftest.
Tested on the failed test cases, now they are passing.
2017-06-05 16:01:20 - test_bitbakelayers_flatten (oeqa.selftest.bblayers.BitbakeLayers) ... ok 2017-06-05 16:01:35 - test_bitbakelayers_showappends (oeqa.selftest.bblayers.BitbakeLayers) ... ok
Failed logs on v2 patch:
https://autobuilder.yocto.io/builders/nightly-oe-selftest/builds/320/steps/Running%20oe-selftest/logs/stdio
Change log on v2 patch:
- Remove line "return 1", because bb.fatal raises an exception, hence return 1 is not needed.
Regards,
Rebecca
Chang Rebecca Swee Fun (1):
bitbake-layers: check layer dependencies before adding
bitbake/bin/bitbake-layers | 1 + bitbake/lib/bblayers/action.py | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/1 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/bin/bitbake-layers | 1 + bitbake/lib/bblayers/action.py | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)
bitbake/bin/bitbake-layers +1 -0
@@ -43,6 +43,7 @@ def main(): add_help=False) parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') + parser.add_argument('-F', '--force', help='Force add without recipe parse verification', action='store_true') parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') global_args, unparsed_args = parser.parse_known_args()
bitbake/lib/bblayers/action.py +22 -4
@@ -1,7 +1,9 @@ import fnmatch import logging import os +import shutil import sys +import tempfile import bb.utils
@@ -32,10 +34,26 @@ class ActionPlugin(LayerPlugin): sys.stderr.write("Unable to find bblayers.conf\n") return 1 - notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None) - if notadded: - for item in notadded: - sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item) + # Back up bblayers.conf to tempdir before we add layers + tempdir = tempfile.mkdtemp() + backup = tempdir + "/bblayers.conf.bak" + shutil.copy2(bblayers_conf, backup) + + try: + notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None) + if not (args.force or notadded): + try: + self.tinfoil.parseRecipes() + except bb.tinfoil.TinfoilUIException: + # Restore the back up copy of bblayers.conf + shutil.copy2(backup, bblayers_conf) + bb.fatal("Parse failure with the specified layer added") + else: + for item in notadded: + sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item) + finally: + # Remove the back up copy of bblayers.conf + shutil.rmtree(tempdir) def do_remove_layer(self, args): """Remove a layer from bblayers.conf."""
Signature · 1 line
2.7.4