All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christopher Larson <clarson@kergoth.com>
To: Humberto Ibarra <humberto.ibarra.lopez@intel.com>
Cc: "bitbake-devel@lists.openembedded.org"
	<bitbake-devel@lists.openembedded.org>
Subject: Re: [PATCH] bitbake/lib/bb/cookerdata.py: Check if layer conf files exist before parsing them
Date: Tue, 10 May 2016 13:01:03 -0700	[thread overview]
Message-ID: <CABcZANmPD2snARFqYQrj5NjnkrBCiCX-WDzvxjd4--Z61t56BA@mail.gmail.com> (raw)
In-Reply-To: <1462902849-6940-1-git-send-email-humberto.ibarra.lopez@intel.com>

[-- 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 --]

      reply	other threads:[~2016-05-10 20:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CABcZANmPD2snARFqYQrj5NjnkrBCiCX-WDzvxjd4--Z61t56BA@mail.gmail.com \
    --to=clarson@kergoth.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=humberto.ibarra.lopez@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.