[bitbake-devel] [PATCH] bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them

Humberto Ibarra humberto.ibarra.lopez at intel.com
Tue May 10 17:54:09 UTC 2016


If an invalid layer is added to bblayers.conf, the parsing of said file
ends with a trace and an "Unable to parse" exception. This is not the
ideal output, especially considering that we know exactly why this is failing.

This patch checks if a layer conf file exists before trying to parse it.
If it does not, a clear and more concise message is send to the user.
Otherwise, the parsing continues.

[Yocto #9506]

Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez at intel.com>
---
 bitbake/lib/bb/cookerdata.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 50259a9..28f652e 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -295,7 +295,11 @@ class CookerDataBuilder(object):
                 if layer.endswith('/'):
                     layer = layer.rstrip('/')
                 data.setVar('LAYERDIR', layer)
-                data = parse_config_file(os.path.join(layer, "conf", "layer.conf"), data)
+                layer_config_file = os.path.join(layer, "conf", "layer.conf")
+                if not os.path.exists(layer_config_file):
+                    parselog.critical("Unable to find layer configuration file: %s" % layer_config_file)
+                    sys.exit(1)
+                data = parse_config_file(layer_config_file, data)
                 data.expandVarref('LAYERDIR')
 
             data.delVar('LAYERDIR')
-- 
2.4.11




More information about the bitbake-devel mailing list