[oe-commits] [bitbake] branch master-next updated: bitbake-layers: check layer dependencies before adding

git at git.openembedded.org git at git.openembedded.org
Mon Jun 5 15:57:50 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

The following commit(s) were added to refs/heads/master-next by this push:
     new 705ab25  bitbake-layers: check layer dependencies before adding
705ab25 is described below

commit 705ab252e631903e6d2e46202b419a9e8adcd861
Author: Chang Rebecca Swee Fun <rebecca.swee.fun.chang at intel.com>
AuthorDate: Mon Jun 5 16:43:55 2017 +0800

    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]
    
    Signed-off-by: Phoong Stanley Cheong Kwan <stanley.cheong.kwan.phoong at intel.com>
    Signed-off-by: Chang Rebecca Swee Fun <rebecca.swee.fun.chang at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 bin/bitbake-layers     |  1 +
 lib/bblayers/action.py | 26 ++++++++++++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/bin/bitbake-layers b/bin/bitbake-layers
index 2b05d28..04e6bec 100755
--- a/bin/bitbake-layers
+++ b/bin/bitbake-layers
@@ -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()
diff --git a/lib/bblayers/action.py b/lib/bblayers/action.py
index cf94704..b1326e5 100644
--- a/lib/bblayers/action.py
+++ b/lib/bblayers/action.py
@@ -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."""

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list