<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 10, 2016 at 10:54 AM, Humberto Ibarra <span dir="ltr"><<a href="mailto:humberto.ibarra.lopez@intel.com" target="_blank">humberto.ibarra.lopez@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":qk" class="a3s aXjCH">If an invalid layer is added to bblayers.<span class="il">conf</span>, the parsing of said file<br>
ends with a trace and an "Unable to parse" exception. This is not the<br>
ideal output, especially considering that we know exactly why this is failing.<br>
<br>
This patch checks if a layer <span class="il">conf</span> file exists before trying to parse it.<br>
If it does not, a clear and more concise message is send to the user.<br>
Otherwise, the parsing continues.<br>
<br>
[Yocto #9506]<br>
<br>
Signed-off-by: Humberto Ibarra <<a href="mailto:humberto.ibarra.lopez@intel.com">humberto.ibarra.lopez@intel.com</a>><br>
---<br>
<span class="il">bitbake</span>/lib/<span class="il">bb</span>/cookerdata.py | 6 +++++-<br>
1 file changed, 5 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/<span class="il">bitbake</span>/lib/<span class="il">bb</span>/cookerdata.py b/<span class="il">bitbake</span>/lib/<span class="il">bb</span>/cookerdata.py<br>
index 50259a9..28f652e 100644<br>
--- a/<span class="il">bitbake</span>/lib/<span class="il">bb</span>/cookerdata.py<br>
+++ b/<span class="il">bitbake</span>/lib/<span class="il">bb</span>/cookerdata.py<br>
@@ -295,7 +295,11 @@ <span class="il">class</span> CookerDataBuilder(object):<br>
if layer.endswith('/'):<br>
layer = layer.rstrip('/')<br>
data.setVar('LAYERDIR', layer)<br>
- data = parse_config_file(os.path.join(layer, "<span class="il">conf</span>", "layer.<span class="il">conf</span>"), data)<br>
+ layer_config_file = os.path.join(layer, "<span class="il">conf</span>", "layer.<span class="il">conf</span>")<br>
+ if not os.path.exists(layer_config_file):<br>
+ parselog.critical("Unable to find layer configuration file: %s" % layer_config_file)<br>
+ sys.exit(1)<br>
+ data = parse_config_file(layer_config_file, data)</div></blockquote></div><br>This is potentially racy. Better to just try to open and catch the appropriate exception and check exc.errno for errno.ENOENT.<br>-- <br><div class="gmail_signature">Christopher Larson<br>clarson at kergoth dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div>
</div></div>