[bitbake-devel] [PATCH 1/2] bitbake-layers: fix error handling in add-layer / remove-layer

Paul Eggleton paul.eggleton at linux.intel.com
Mon Dec 29 11:14:26 UTC 2014


* Fix add-layer error message when a layer is already in BBLAYERS
* Ensure we show an error message if we can't find BBLAYERS at all

Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
 bin/bitbake-layers | 2 +-
 lib/bb/utils.py    | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/bin/bitbake-layers b/bin/bitbake-layers
index edb4d2f..9879498 100755
--- a/bin/bitbake-layers
+++ b/bin/bitbake-layers
@@ -130,7 +130,7 @@ usage: add-layer <layerdir>
         (notadded, _) = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None)
         if notadded:
             for item in notadded:
-                sys.stderr.write("Specified layer %s not in BBLAYERS\n" % item)
+                sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item)
 
 
     def do_remove_layer(self, dirname):
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index f26349f..ef8cd4d 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1012,7 +1012,11 @@ def edit_bblayers_conf(bblayers_conf, add, remove):
     addlayers = layerlist_param(add)
     removelayers = layerlist_param(remove)
 
+    # Need to use a list here because we can't set non-local variables from a callback in python 2.x
+    bblayercalls = []
+
     def handle_bblayers(varname, origvalue):
+        bblayercalls.append(varname)
         updated = False
         bblayers = [remove_trailing_sep(x) for x in origvalue.split()]
         if removelayers:
@@ -1040,5 +1044,9 @@ def edit_bblayers_conf(bblayers_conf, add, remove):
             return (origvalue, 2, False)
 
     edit_metadata_file(bblayers_conf, ['BBLAYERS'], handle_bblayers)
+
+    if not bblayercalls:
+        raise Exception('Unable to find BBLAYERS in %s' % bblayers_conf)
+
     return (notadded, notremoved)
 
-- 
1.9.3




More information about the bitbake-devel mailing list