From: Cristiana Voicu <cristiana.voicu@intel.com>
To: bitbake-devel@lists.openembedded.org
Subject: [PATCH_V3 03/16] hob/bitbake: create a template (a .bb file) from hob through bitbake
Date: Mon, 29 Jul 2013 15:59:17 +0300 [thread overview]
Message-ID: <1375102770-14079-4-git-send-email-cristiana.voicu@intel.com> (raw)
In-Reply-To: <1375102770-14079-1-git-send-email-cristiana.voicu@intel.com>
Modified generateNewImage function from cooker, in order to be used to
save a template in Hob.
Created a command to ensure that some dirs are created. The templates
(recipes) will be saved in {TOPDIR}/recipes/images folder.
Called these methods from Hob.
[YOCTO #4193]
Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
---
bitbake/lib/bb/command.py | 8 +++++++-
bitbake/lib/bb/cooker.py | 24 ++++++++++++++++-------
bitbake/lib/bb/ui/crumbs/builder.py | 10 ++++++++++
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py | 2 +-
bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 9 ++++++++-
bitbake/lib/bb/ui/crumbs/imagedetailspage.py | 2 ++
6 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 1727654..1893cce 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -214,7 +214,13 @@ class CommandsSync:
image = params[0]
base_image = params[1]
package_queue = params[2]
- return command.cooker.generateNewImage(image, base_image, package_queue)
+ timestamp = params[3]
+ return command.cooker.generateNewImage(image, base_image,
+ package_queue, timestamp)
+
+ def ensureDir(self, command, params):
+ directory = params[0]
+ bb.utils.mkdirhier(directory)
def setVarFile(self, command, params):
"""
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 49e6345..4a5638f 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1100,16 +1100,25 @@ class BBCooker:
self.configuration.server_register_idlecallback(buildTargetsIdle, rq)
- def generateNewImage(self, image, base_image, package_queue):
+ def generateNewImage(self, image, base_image, package_queue, timestamp):
'''
- Create a new image with a "require" base_image statement
+ Create a new image with a "require"/"inherit" base_image statement
'''
- image_name = os.path.splitext(image)[0]
- timestr = time.strftime("-%Y%m%d-%H%M%S")
- dest = image_name + str(timestr) + ".bb"
+ if timestamp:
+ image_name = os.path.splitext(image)[0]
+ timestr = time.strftime("-%Y%m%d-%H%M%S")
+ dest = image_name + str(timestr) + ".bb"
+ else:
+ if not image.endswith(".bb"):
+ dest = image + ".bb"
+ else:
+ dest = image
with open(dest, "w") as imagefile:
- imagefile.write("require " + base_image + "\n")
+ if base_image is None:
+ imagefile.write("inherit image\n")
+ else:
+ imagefile.write("require " + base_image + "\n")
package_install = "PACKAGE_INSTALL_forcevariable = \""
for package in package_queue:
package_install += str(package) + " "
@@ -1117,7 +1126,8 @@ class BBCooker:
imagefile.write(package_install)
self.state = state.initial
- return timestr
+ if timestamp:
+ return timestr
def updateCache(self):
if self.state == state.running:
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 317a2fe..0a04c90 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -593,6 +593,16 @@ class Builder(gtk.Window):
toolchain_packages,
self.configuration.default_task)
+ def generate_new_image(self, image):
+ base_image = self.configuration.initial_selected_image
+ if base_image == self.recipe_model.__custom_image__:
+ base_image = None
+ packages = self.package_model.get_selected_packages()
+ self.handler.generate_new_image(image, base_image, packages)
+
+ def ensure_dir(self, directory):
+ self.handler.ensure_dir(directory)
+
def get_parameters_sync(self):
return self.handler.get_parameters()
diff --git a/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py b/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
index 3fc389a..b2fa3bd 100644
--- a/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
+++ b/bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
@@ -117,7 +117,7 @@ class SaveImageDialog (CrumbsDialog):
text = self.name_entry.get_text()
new_text = text.replace("-","")
if new_text.islower() and new_text.isalnum():
- print(text)
+ self.builder.generate_new_image(self.directory+text)
self.destroy()
else:
self.show_invalid_input_error_dialog()
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 294eb5d..34cd347 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -176,7 +176,7 @@ class HobHandler(gobject.GObject):
hobImage = self.runCommand(["matchFile", "hob-image.bb"])
if self.base_image != "Start with an empty image recipe":
baseImage = self.runCommand(["matchFile", self.base_image + ".bb"])
- version = self.runCommand(["generateNewImage", hobImage, baseImage, self.package_queue])
+ version = self.runCommand(["generateNewImage", hobImage, baseImage, self.package_queue, True])
targets[0] += version
self.recipe_model.set_custom_image_version(version)
@@ -426,6 +426,13 @@ class HobHandler(gobject.GObject):
self.commands_async.append(self.SUB_BUILD_IMAGE)
self.run_next_command(self.GENERATE_IMAGE)
+ def generate_new_image(self, image, base_image, package_queue):
+ base_image = self.runCommand(["matchFile", self.base_image + ".bb"])
+ self.runCommand(["generateNewImage", image, base_image, package_queue, False])
+
+ def ensure_dir(self, directory):
+ self.runCommand(["ensureDir", directory])
+
def build_succeeded_async(self):
self.building = False
diff --git a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
index a02ab61..f55d43f 100755
--- a/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
+++ b/bitbake/lib/bb/ui/crumbs/imagedetailspage.py
@@ -624,6 +624,8 @@ class ImageDetailsPage (HobPage):
def save_button_clicked_cb(self, button):
topdir = self.builder.get_topdir()
images_dir = topdir + "/recipes/images/"
+ self.builder.ensure_dir(images_dir)
+
dialog = SaveImageDialog(images_dir, "Save image recipe", self.builder,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
response = dialog.run()
--
1.7.9.5
next prev parent reply other threads:[~2013-07-29 12:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-29 12:59 [PATCH_V3 00/16] bitbake+hob: templates enhancement Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 01/16] hob: labelling changes in Hob Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 02/16] hob: create save image dialog used to save a template Cristiana Voicu
2013-07-29 12:59 ` Cristiana Voicu [this message]
2013-07-29 12:59 ` [PATCH_V3 04/16] hob/bitbake: save the description of a custom image Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 05/16] hob: make changes in order to permit from UI to edit an image after saving it Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 06/16] hob & bitbake: append a value to a variable from hob throught bitbake Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 07/16] hob: change the name and description for the saveimagedialog Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 08/16] hob: the saved image should be editable Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 09/16] hob/bitbake: when an image is saved, it should require an image from layers Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 10/16] hob: changes to image combo box Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 11/16] hob: retrieve file name of an image Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 12/16] hob: implement the "retrieve image dialog" + changes to image combo box Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 13/16] bitbake: save packages in IMAGE_INSTALL instead of PACKAGE_INSTALL Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 14/16] hob: set focus on entry name when the name is not correct Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 15/16] hob/imagedetailspage: add tooltip for save image recipe button Cristiana Voicu
2013-07-29 12:59 ` [PATCH_V3 16/16] hob/imageconfigurationpage: changes to image combobox Cristiana Voicu
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=1375102770-14079-4-git-send-email-cristiana.voicu@intel.com \
--to=cristiana.voicu@intel.com \
--cc=bitbake-devel@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 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.