All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Cristiana Voicu <cristiana.voicu@intel.com>
Cc: bitbake-devel@lists.openembedded.org
Subject: Re: [PATCH] hob/bitbake: custom image is now using the base image
Date: Thu, 06 Dec 2012 15:22:13 +0000	[thread overview]
Message-ID: <1354807333.12928.6.camel@ted> (raw)
In-Reply-To: <1354799706-9226-1-git-send-email-cristiana.voicu@intel.com>

On Thu, 2012-12-06 at 15:15 +0200, Cristiana Voicu wrote:
> Till now, a custom image made in Hob was using only the packages from
> the base image. Now it is using everything declared in the base image.
> Also next to hob-image.bb, it creates another .bb file which is used
> in building process. Those images are ignored by git.
> 
> [YOCTO #2601]
> Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
> ---
>  .gitignore                                  |    1 +
>  bitbake/lib/bb/command.py                   |    8 +++++--
>  bitbake/lib/bb/cooker.py                    |   31 +++++++++++++++++++++++++--
>  bitbake/lib/bb/ui/crumbs/builder.py         |    3 +++
>  bitbake/lib/bb/ui/crumbs/hobeventhandler.py |    5 +++--
>  5 files changed, 42 insertions(+), 6 deletions(-)
> 
> diff --git a/.gitignore b/.gitignore
> index 88c91f6..003f09a 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -15,3 +15,4 @@ meta-*
>  *~
>  !meta-yocto
>  !meta-yocto-bsp
> +hob-image-*.bb
> diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
> index 3f28bca..48b09e4 100644
> --- a/bitbake/lib/bb/command.py
> +++ b/bitbake/lib/bb/command.py
> @@ -220,8 +220,12 @@ class CommandsAsync:
>          """
>          pkgs_to_build = params[0]
>          task = params[1]
> -
> -        command.cooker.buildTargets(pkgs_to_build, task)
> +        if len(params) > 2:
> +            base_image = params[2]
> +            package_queue = params[3]
> +            command.cooker.buildTargets(pkgs_to_build, task, base_image, package_queue)
> +        else:
> +            command.cooker.buildTargets(pkgs_to_build, task)
>      buildTargets.needcache = True
>  
>      def generateDepTreeEvent(self, command, params):
> diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
> index 6b58f91..22d8bd1 100644
> --- a/bitbake/lib/bb/cooker.py
> +++ b/bitbake/lib/bb/cooker.py
> @@ -23,7 +23,7 @@
>  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>  
>  from __future__ import print_function
> -import sys, os, glob, os.path, re, time
> +import sys, os, glob, os.path, re, time, shutil
>  import atexit
>  import itertools
>  import logging
> @@ -1127,11 +1127,14 @@ class BBCooker:
>  
>          self.server_registration_cb(buildFileIdle, rq)
>  
> -    def buildTargets(self, targets, task):
> +    def buildTargets(self, targets, task, base_image=None, package_queue=None):
>          """
>          Attempt to build the targets specified
>          """
>  
> +        if base_image != None and targets[0] == "hob-image":
> +            self.prepareHobImage(base_image, package_queue)
> +
>          # Need files parsed
>          self.updateCache()
>  
> @@ -1188,6 +1191,30 @@ class BBCooker:
>  
>          self.server_registration_cb(buildTargetsIdle, rq)

This looks good, I'd just ask for one tweak.

Rather than overload "buildTargets", lets add a new command say
"generateNewImage" which generates the this. Lets also not make this
"hob" specific, lets pass in the necessary parameters.

This may mean we need to also add a command to run "matchFile" on the
server so we can call the "generateNewImage" command with the right
options.

Cheers,

Richard


> +    def prepareHobImage(self, base_image, package_queue):
> +        '''
> +        Create a new hob-image with a "require" base_image statement
> +        '''
> +        hob_image = self.matchFile("hob-image.bb")
> +        base_image = self.matchFile(str(base_image) + ".bb")
> +        with open(hob_image, "a") as hobimagefile:
> +            hobimagefile.write("require " + base_image + "\n")
> +            package_install = "PACKAGE_INSTALL_forcevariable = \""
> +            for package in package_queue:
> +                package_install += str(package) + " "
> +            package_install += "\"\n"
> +            hobimagefile.write(package_install)
> +
> +        dir_hob_image = os.path.dirname(hob_image)
> +        timestr = time.strftime("%Y%m%d-%H%M%S")
> +        dest = dir_hob_image + "/hob-image-" + str(timestr) + ".bb"
> +        shutil.copyfile(hob_image, dest)
> +
> +        self.parser.reparse(hob_image)
> +
> +        with open(hob_image, "w") as hobimagefile:
> +            hobimagefile.write("inherit image\n")
> +
>      def updateCache(self):
>          if self.state == state.running:
>              return
> diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
> index 2f3d6d0..663c322 100755
> --- a/bitbake/lib/bb/ui/crumbs/builder.py
> +++ b/bitbake/lib/bb/ui/crumbs/builder.py
> @@ -611,15 +611,18 @@ class Builder(gtk.Window):
>          # Build image
>          self.set_user_config()
>          toolchain_packages = []
> +        base_image = None
>          if self.configuration.toolchain_build:
>              toolchain_packages = self.package_model.get_selected_packages_toolchain()
>          if self.configuration.selected_image == self.recipe_model.__custom_image__:
>              packages = self.package_model.get_selected_packages()
>              image = self.hob_image
> +            base_image = self.configuration.initial_selected_image
>          else:
>              packages = []
>              image = self.configuration.selected_image
>          self.handler.generate_image(image,
> +                                    base_image,
>                                      self.hob_toolchain,
>                                      packages,
>                                      toolchain_packages,
> diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
> index 8a2ac5f..1583f76 100644
> --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
> +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
> @@ -166,7 +166,7 @@ class HobHandler(gobject.GObject):
>              if self.toolchain_packages:
>                  self.runCommand(["setVariable", "TOOLCHAIN_TARGET_TASK", " ".join(self.toolchain_packages)])
>                  targets.append(self.toolchain)
> -            self.runCommand(["buildTargets", targets, self.default_task])
> +            self.runCommand(["buildTargets", targets, self.default_task, self.base_image, self.package_queue])
>  
>      def display_error(self):
>          self.clear_busy()
> @@ -386,8 +386,9 @@ class HobHandler(gobject.GObject):
>          self.commands_async.append(self.SUB_BUILD_RECIPES)
>          self.run_next_command(self.GENERATE_PACKAGES)
>  
> -    def generate_image(self, image, toolchain, image_packages=[], toolchain_packages=[], default_task="build"):
> +    def generate_image(self, image, base_image, toolchain, image_packages=[], toolchain_packages=[], default_task="build"):
>          self.image = image
> +        self.base_image = base_image
>          self.toolchain = toolchain
>          self.package_queue = image_packages
>          self.toolchain_packages = toolchain_packages





  reply	other threads:[~2012-12-06 15:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-06 13:15 [PATCH] hob/bitbake: custom image is now using the base image Cristiana Voicu
2012-12-06 15:22 ` Richard Purdie [this message]
2012-12-06 15:35   ` Voicu, Cristiana

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=1354807333.12928.6.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=cristiana.voicu@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.