[bitbake-devel] [PATCH] hob/bitbake: custom image is now using the base image
Cristiana Voicu
cristiana.voicu at intel.com
Thu Dec 6 13:15:06 UTC 2012
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 at 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)
+ 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
--
1.7.9.5
More information about the bitbake-devel
mailing list