bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them
PATCH 1/1 bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them
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]
--- bitbake/lib/bb/cookerdata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
bitbake/lib/bb/cookerdata.py +5 -1
@@ -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')
Signature · 1 line
2.4.11
Quoted 24 lines · Humberto Ibarra
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 <[email protected]>--- bitbake/lib/bb/cookerdata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)bitbake/lib/bb/cookerdata.py +0
-0@@ -295,7 +295,11 @@ class CookerDataBuilder(object): if layer.endswith('/'): layer = layer.rstrip('/')
bitbake/lib/bb/cookerdata.py class CookerDataBuilder(object): · line 305
Quoted 10 lines
bitbake/lib/bb/cookerdata.py +5
-1data.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)
This is potentially racy. Better to just try to open and catch the appropriate exception and check exc.errno for errno.ENOENT.
Signature · 5 lines
Christopher Larson clarson at kergoth dot com Founder - BitBake, OpenEmbedded, OpenZaurus Maintainer - Tslib Senior Software Engineer, Mentor Graphics