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

Christopher Larson clarson at kergoth.com
Tue May 10 20:01:03 UTC 2016


On Tue, May 10, 2016 at 10:54 AM, Humberto Ibarra <
humberto.ibarra.lopez at intel.com> wrote:

> 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)
>

This is potentially racy. Better to just try to open and catch the
appropriate exception and check exc.errno for errno.ENOENT.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20160510/2fa17b93/attachment-0002.html>


More information about the bitbake-devel mailing list