Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Ed Bartosh <ed.bartosh@linux.intel.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 01/17] image.py: write bitbake variables to .env file
Date: Sun, 30 Aug 2015 12:24:48 +0100	[thread overview]
Message-ID: <1440933888.32588.68.camel@linuxfoundation.org> (raw)
In-Reply-To: <db48ab408d16d06aa46cbae805d88217f24f64c2.1440071413.git.ed.bartosh@linux.intel.com>

On Thu, 2015-08-20 at 14:56 +0300, Ed Bartosh wrote:
> Write set of bitbake variables associated with the image into
> build/tmp/sysroots/<machine>/imagedata/<image>.env
> 
> This is needed for wic to be able to get bitbake variables without
> running 'bitbake -e'.

I've just realised what this code is doing, its writing out nearly the
whole data store :(

Is there no way we can know which variables wic may later need? I'm not
keen at all to see an iteration of d.keys() and the list of things not
to write out looks arbitrary at best :(

We need to find a better way of doing this...

I'd also prefer we only do this if we know we're going to be writing a
wic image.

Cheers,

Richard


> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
> ---
>  meta/lib/oe/image.py | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/meta/lib/oe/image.py b/meta/lib/oe/image.py
> index 699c30f..a7fdefa 100644
> --- a/meta/lib/oe/image.py
> +++ b/meta/lib/oe/image.py
> @@ -321,6 +321,27 @@ class Image(ImageDepGraph):
>  
>          return image_cmd_groups
>  
> +    def _write_env(self):
> +        """
> +        Write environment variables
> +        to tmp/sysroots/<machine>/imgdata/<image>.env
> +        """
> +        stdir = self.d.getVar('STAGING_DIR_TARGET', True)
> +        outdir = os.path.join(stdir, 'imgdata')
> +        if not os.path.exists(outdir):
> +            os.makedirs(outdir)
> +        basename = self.d.getVar('IMAGE_BASENAME', True)
> +        with open(os.path.join(outdir, basename) + '.env', 'w') as envf:
> +            for var in sorted(self.d.keys()):
> +                # filter out as much as we can to reduce file size
> +                if var.startswith('_') or var.startswith('BB_') \
> +                   or not var.isupper() or self.d.getVarFlag(var, "func") \
> +                   or var in ('BBINCLUDED', 'SRCPV', 'MIRRORS'):
> +                    continue
> +                value = self.d.getVar(var, True)
> +                if value:
> +                    envf.write('%s="%s"\n' % (var, value.strip()))
> +
>      def create(self):
>          bb.note("###### Generate images #######")
>          pre_process_cmds = self.d.getVar("IMAGE_PREPROCESS_COMMAND", True)
> @@ -332,6 +353,8 @@ class Image(ImageDepGraph):
>  
>          image_cmd_groups = self._get_imagecmds()
>  
> +        self._write_env()
> +
>          for image_cmds in image_cmd_groups:
>              # create the images in parallel
>              nproc = multiprocessing.cpu_count()
> -- 
> 2.1.4
> 




  reply	other threads:[~2015-08-30 11:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 11:56 [PATCH 00/17] Build wic images with bitbake Ed Bartosh
2015-08-20 11:56 ` [PATCH 01/17] image.py: write bitbake variables to .env file Ed Bartosh
2015-08-30 11:24   ` Richard Purdie [this message]
2015-08-30 13:17     ` Ed Bartosh
2015-08-20 11:56 ` [PATCH 02/17] oe-selftest: test generation of <image>.env Ed Bartosh
2015-08-20 11:56 ` [PATCH 03/17] wic: remove undescore from function name Ed Bartosh
2015-08-20 11:56 ` [PATCH 04/17] wic: add BitbakeVars class Ed Bartosh
2015-08-20 11:56 ` [PATCH 05/17] wic: create new method _parse_line Ed Bartosh
2015-08-20 11:56 ` [PATCH 06/17] wic: add default_image attribute to BitbakeVars Ed Bartosh
2015-08-20 11:56 ` [PATCH 07/17] wic: set default image Ed Bartosh
2015-08-20 11:56 ` [PATCH 08/17] wic: implement getting variables from .env files Ed Bartosh
2015-08-20 11:56 ` [PATCH 09/17] wic: implement --vars option Ed Bartosh
2015-08-20 11:56 ` [PATCH 10/17] wic: rename variable Ed Bartosh
2015-08-20 11:56 ` [PATCH 11/17] wic: deferred call of hlp.get_wic_plugins_help() Ed Bartosh
2015-08-20 11:56 ` [PATCH 12/17] image_types.bbclass: add wic image type Ed Bartosh
2015-08-20 11:56 ` [PATCH 13/17] wic-image-minimal: add wic image recipe and .wks Ed Bartosh
2015-08-20 11:56 ` [PATCH 14/17] oe-selftest: test building wic image by bitbake Ed Bartosh
2015-08-20 12:55   ` Mario Domenech Goulart
2015-08-20 11:56 ` [PATCH 15/17] image.py: set bitbake variable ROOTFS_SIZE Ed Bartosh
2015-08-20 11:56 ` [PATCH 16/17] wic: use " Ed Bartosh
2015-08-20 11:56 ` [PATCH 17/17] image.py: add script output to the rootfs log Ed Bartosh
  -- strict thread matches above, loose matches on Subject: below --
2015-08-25  9:04 [PATCH v2 00/17] Build wic images with bitbake Ed Bartosh
2015-08-25  9:04 ` [PATCH 01/17] image.py: write bitbake variables to .env file Ed Bartosh

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=1440933888.32588.68.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=ed.bartosh@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox