* [PATCH] bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them
@ 2016-05-10 17:54 Humberto Ibarra
2016-05-10 20:01 ` Christopher Larson
0 siblings, 1 reply; 2+ messages in thread
From: Humberto Ibarra @ 2016-05-10 17:54 UTC (permalink / raw)
To: bitbake-devel
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@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them
2016-05-10 17:54 [PATCH] bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them Humberto Ibarra
@ 2016-05-10 20:01 ` Christopher Larson
0 siblings, 0 replies; 2+ messages in thread
From: Christopher Larson @ 2016-05-10 20:01 UTC (permalink / raw)
To: Humberto Ibarra; +Cc: bitbake-devel
[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]
On Tue, May 10, 2016 at 10:54 AM, Humberto Ibarra <
humberto.ibarra.lopez@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@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
[-- Attachment #2: Type: text/html, Size: 2919 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-10 20:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-10 17:54 [PATCH] bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them Humberto Ibarra
2016-05-10 20:01 ` Christopher Larson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.