Skip to contentSkip to conversation

bitbake+hob: templates enhancement

PATCH New Cristiana Voicu 1 participant 17 messages Jul 29, 2013 Arm STM32

lore
Share & tools
lore
#0 lore raw

cover bitbake+hob: templates enhancement

This set implements the templates functionality in Hob. There are two new files, with two different dialogs. The changes are in bitbake and in Hob.

Cristiana Voicu (16):
hob: labelling changes in Hob
hob: create save image dialog used to save a template hob/bitbake: create a template (a .bb file) from hob through bitbake hob/bitbake: save the description of a custom image
hob: make changes in order to permit from UI to edit an image after
saving it
hob & bitbake: append a value to a variable from hob throught bitbake
hob: change the name and description for the saveimagedialog
hob: the saved image should be editable
hob/bitbake: when an image is saved, it should require an image from
layers
hob: changes to image combo box
hob: retrieve file name of an image
hob: implement the "retrieve image dialog" + changes to image combo
box
bitbake: save packages in IMAGE_INSTALL instead of PACKAGE_INSTALL
hob: set focus on entry name when the name is not correct hob/imagedetailspage: add tooltip for save image recipe button hob/imageconfigurationpage: changes to image combobox

 bitbake/lib/bb/command.py                          |   14 +-
 bitbake/lib/bb/cooker.py                           |   71 +++++++--
 bitbake/lib/bb/data.py                             |    4 +
 bitbake/lib/bb/ui/crumbs/builder.py                |   15 ++
 .../lib/bb/ui/crumbs/hig/retrieveimagedialog.py    |   49 +++++++
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py    |  151 ++++++++++++++++++++
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py        |   25 +++-
 bitbake/lib/bb/ui/crumbs/hoblistmodel.py           |   40 ++++--
 bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py |   76 +++++++---
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py       |   44 +++++-
 10 files changed, 438 insertions(+), 51 deletions(-)
 create mode 100644 bitbake/lib/bb/ui/crumbs/hig/retrieveimagedialog.py
 create mode 100644 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/16 hob: labelling changes in Hob

When the design document for templates in Hob was created, we've noticed that some labels need to change.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py        |    2 +-
 bitbake/lib/bb/ui/crumbs/hoblistmodel.py           |    4 ++--
 bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py |   22 ++++++++------------
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py       |   11 +++++++---
 4 files changed, 20 insertions(+), 19 deletions(-)
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +1 -1
index 8788083..4c6e6fd 100644
@@ -174,7 +174,7 @@ class HobHandler(gobject.GObject):
                 targets.append(self.toolchain)
             if targets[0] == "hob-image":
                 hobImage = self.runCommand(["matchFile", "hob-image.bb"])
-                if self.base_image != "Create your own image":
+                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])
                     targets[0] += version
bitbake/lib/bb/ui/crumbs/hoblistmodel.py +2 -2
index 7f7d82f..94c2453 100644
@@ -476,7 +476,7 @@ class RecipeListModel(gtk.ListStore):
     (COL_NAME, COL_DESC, COL_LIC, COL_GROUP, COL_DEPS, COL_BINB, COL_TYPE, COL_INC, COL_IMG, COL_INSTALL, COL_PN, COL_FADE_INC, COL_SUMMARY, COL_VERSION,
      COL_REVISION, COL_HOMEPAGE, COL_BUGTRACKER) = range(17)
 
-    __custom_image__ = "Create your own image"
+    __custom_image__ = "Start with an empty image recipe"
 
     __gsignals__ = {
         "recipe-selection-changed" : (gobject.SIGNAL_RUN_LAST,
@@ -679,7 +679,7 @@ class RecipeListModel(gtk.ListStore):
 
         # dummy image for prompt
         self.set(self.append(), self.COL_NAME, self.__custom_image__,
-                 self.COL_DESC, "Use 'Edit image' to customize recipes and packages " \
+                 self.COL_DESC, "Use 'Edit image recipe' to customize recipes and packages " \
                                 "to be included in your image ",
                  self.COL_LIC, "", self.COL_GROUP, "",
                  self.COL_DEPS, "", self.COL_BINB, "",
bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py +9 -13
index 1f7453a..e4c6606 100644
@@ -35,7 +35,7 @@ from bb.ui.crumbs.hobpages import HobPage
 class ImageConfigurationPage (HobPage):
 
     __dummy_machine__ = "--select a machine--"
-    __dummy_image__   = "--select a base image--"
+    __dummy_image__   = "Select from my image recipes"
 
     def __init__(self, builder):
         super(ImageConfigurationPage, self).__init__(builder, "Image configuration")
@@ -200,12 +200,9 @@ class ImageConfigurationPage (HobPage):
         markup += "http://www.yoctoproject.org/docs/current/dev-manual/"
         markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>."
         self.layer_info_icon = HobInfoButton("<b>Layers</b>" + "*" + markup, self.get_parent())
-#        self.progress_box = gtk.HBox(False, 6)
         self.progress_bar = HobProgressBar()
-#        self.progress_box.pack_start(self.progress_bar, expand=True, fill=True)
         self.stop_button = HobAltButton("Stop")
         self.stop_button.connect("clicked", self.stop_button_clicked_cb)
-#        self.progress_box.pack_end(stop_button, expand=False, fill=False)
         self.machine_separator = gtk.HSeparator()
 
     def set_config_machine_layout(self, show_progress_bar = False):
@@ -229,14 +226,15 @@ class ImageConfigurationPage (HobPage):
     def create_config_baseimg(self):
         self.image_title = gtk.Label()
         self.image_title.set_alignment(0, 1.0)
-        mark = "<span %s>Select a base image</span>" % self.span_tag('x-large', 'bold')
+        mark = "<span %s>Select an image recipe</span>" % self.span_tag('x-large', 'bold')
         self.image_title.set_markup(mark)
 
         self.image_title_desc = gtk.Label()
         self.image_title_desc.set_alignment(0, 0.5)
-        mark = ("<span %s>Base images are a starting point for the type of image you want. "
+
+        mark = ("<span %s>Image recipes are a starting point for the type of image you want. "
                 "You can build them as \n"
-                "they are or customize them to your specific needs.\n</span>") % self.span_tag('medium')
+                "they are or edit them to suit your needs.\n</span>") % self.span_tag('medium')
         self.image_title_desc.set_markup(mark)
 
         self.image_combo = gtk.combo_box_new_text()
@@ -272,15 +270,13 @@ class ImageConfigurationPage (HobPage):
 
         # create button "Build image"
         self.just_bake_button = HobButton("Build image")
-        #self.just_bake_button.set_size_request(205, 49)
-        self.just_bake_button.set_tooltip_text("Build target image")
+        self.just_bake_button.set_tooltip_text("Build the image recipe as it is")
         self.just_bake_button.connect("clicked", self.just_bake_button_clicked_cb)
         button_box.pack_end(self.just_bake_button, expand=False, fill=False)
 
-        # create button "Edit Image"
-        self.edit_image_button = HobAltButton("Edit image")
-        #self.edit_image_button.set_size_request(205, 49)
-        self.edit_image_button.set_tooltip_text("Edit target image")
+        # create button "Edit image recipe"
+        self.edit_image_button = HobAltButton("Edit image recipe")
+        self.edit_image_button.set_tooltip_text("Customize the recipes and packages to be included in your image")
         self.edit_image_button.connect("clicked", self.edit_image_button_clicked_cb)
         button_box.pack_end(self.edit_image_button, expand=False, fill=False)
 
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +8 -3
index 268ac68..4b0e749 100755
@@ -333,13 +333,18 @@ class ImageDetailsPage (HobPage):
         #    self.kernel_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=change_kernel_button)
         #    self.box_group_area.pack_start(self.kernel_detail, expand=True, fill=True)
 
-        # Machine, Base image and Layers
+        # Machine, Image recipe and Layers
         layer_num_limit = 15
-        varlist = ["Machine: ", "Base image: ", "Layers: "]
+        varlist = ["Machine: ", "Image recipe: ", "Layers: "]
         vallist = []
         self.setting_detail = None
         if self.build_succeeded:
             vallist.append(machine)
+            if base_image == self.builder.recipe_model.__custom_image__:
+                if self.builder.configuration.initial_selected_image == self.builder.recipe_model.__custom_image__:
+                    base_image ="New image recipe"
+                else:
+                    base_image = self.builder.configuration.initial_selected_image + " (edited)"
             vallist.append(base_image)
             i = 0
             for layer in layers:
@@ -359,7 +364,7 @@ class ImageDetailsPage (HobPage):
                 i += 1
 
             edit_config_button = HobAltButton("Edit configuration")
-            edit_config_button.set_tooltip_text("Edit machine, base image and recipes")
+            edit_config_button.set_tooltip_text("Edit machine and image recipe")
             edit_config_button.connect("clicked", self.edit_config_button_clicked_cb)
             self.setting_detail = self.DetailBox(varlist=varlist, vallist=vallist, button=edit_config_button)
             self.box_group_area.pack_start(self.setting_detail, expand=True, fill=True)
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/16 hob: create save image dialog used to save a template

In reply to Cristiana Voicu

Implemented a new dialog used by Hob. This dialog was desinged in order to permit to save only in a particular directory. Also, it has a field where the user can type a description for the image.
Implemented in the handler a method to retrieve the topdir variable, because the changes will be saved in {topdir}/recipes/images directory.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/builder.py             |    3 +
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |  136 +++++++++++++++++++++++
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py     |    3 +
 bitbake/lib/bb/ui/crumbs/hoblistmodel.py        |    3 +
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py    |   20 +++-
 5 files changed, 163 insertions(+), 2 deletions(-)
 create mode 100644 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py
bitbake/lib/bb/ui/crumbs/builder.py +3 -0
index a7bd21c..317a2fe 100755
@@ -1451,3 +1451,6 @@ class Builder(gtk.Window):
             self.consolelog.setFormatter(format)
 
             self.logger.addHandler(self.consolelog)
+
+    def get_topdir(self):
+        return self.handler.get_topdir()
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py new file +136 -0

136 lines not on this page · raw message

bitbake/lib/bb/ui/crumbs/hobeventhandler.py +3 -0
index 4c6e6fd..294eb5d 100644
@@ -452,6 +452,9 @@ class HobHandler(gobject.GObject):
     def get_logfile(self):
         return self.server.runCommand(["getVariable", "BB_CONSOLELOG"])[0]
 
+    def get_topdir(self):
+        return self.runCommand(["getVariable", "TOPDIR"]) or ""
+
     def _remove_redundant(self, string):
         ret = []
         for i in string.split():
bitbake/lib/bb/ui/crumbs/hoblistmodel.py +3 -0
index 94c2453..d8f3256 100644
@@ -882,3 +882,6 @@ class RecipeListModel(gtk.ListStore):
 
     def get_custom_image_version(self):
         return self.custom_image_version
+
+    def is_custom_image(self):
+        return self.get_selected_image() == self.__custom_image__
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +18 -2
index 4b0e749..a02ab61 100755
@@ -27,6 +27,7 @@ from bb.ui.crumbs.hobwidget import hic, HobViewTable, HobAltButton, HobButton
 from bb.ui.crumbs.hobpages import HobPage
 import subprocess
 from bb.ui.crumbs.hig.crumbsdialog import CrumbsDialog
+from bb.ui.crumbs.hig.saveimagedialog import SaveImageDialog
 
 #
 # ImageDetailsPage
@@ -259,7 +260,7 @@ class ImageDetailsPage (HobPage):
             self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
             self.box_group_area.pack_start(self.build_result, expand=False, fill=False)
 
-        self.buttonlist = ["Build new image", "Run image", "Deploy image"]
+        self.buttonlist = ["Build new image", "Save image recipe", "Run image", "Deploy image"]
 
         # Name
         self.image_store = []
@@ -340,7 +341,7 @@ class ImageDetailsPage (HobPage):
         self.setting_detail = None
         if self.build_succeeded:
             vallist.append(machine)
-            if base_image == self.builder.recipe_model.__custom_image__:
+            if self.builder.recipe_model.is_custom_image():
                 if self.builder.configuration.initial_selected_image == self.builder.recipe_model.__custom_image__:
                     base_image ="New image recipe"
                 else:
@@ -579,6 +580,13 @@ class ImageDetailsPage (HobPage):
             created = True
             is_runnable = True
 
+        name = "Save image recipe"
+        if name in buttonlist and self.builder.recipe_model.is_custom_image():
+            save_button = HobAltButton("Save image recipe")
+            button_id = save_button.connect("clicked", self.save_button_clicked_cb)
+            self.button_ids[button_id] = save_button
+            self.details_bottom_buttons.pack_end(save_button, expand=False, fill=False)
+
         name = "Build new image"
         if name in buttonlist:
             # create button "Build new image"
@@ -613,6 +621,14 @@ class ImageDetailsPage (HobPage):
             else:
                 self.builder.runqemu_image(self.toggled_image, self.sel_kernel)
 
+    def save_button_clicked_cb(self, button):
+        topdir = self.builder.get_topdir()
+        images_dir = topdir + "/recipes/images/"
+        dialog = SaveImageDialog(images_dir, "Save image recipe", self.builder,
+                              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
+        response = dialog.run()
+        dialog.destroy()
+
     def build_new_button_clicked_cb(self, button):
         self.builder.initiate_new_build_async()
 
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/16 hob/bitbake: create a template (a .bb file) from hob through bitbake

In reply to Cristiana Voicu

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]
---
 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(-)
bitbake/lib/bb/command.py +7 -1
index 1727654..1893cce 100644
@@ -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):
         """
bitbake/lib/bb/cooker.py +17 -7
index 49e6345..4a5638f 100644
@@ -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:
bitbake/lib/bb/ui/crumbs/builder.py +10 -0
index 317a2fe..0a04c90 100755
@@ -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()
 
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py +1 -1
index 3fc389a..b2fa3bd 100644
@@ -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()
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +8 -1
index 294eb5d..34cd347 100644
@@ -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
 
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +2 -0
index a02ab61..f55d43f 100755
@@ -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()
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/16 hob/bitbake: save the description of a custom image

In reply to Cristiana Voicu

When an new image is saved, the dialog for this action has a field for the description. Changed how an image is saved, by appending the DESCRIPTION variable at the end of the .bb file.

[YOCTO #4193]
---
 bitbake/lib/bb/command.py                       |    3 ++-
 bitbake/lib/bb/cooker.py                        |    5 ++++-
 bitbake/lib/bb/ui/crumbs/builder.py             |    4 ++--
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |    4 +++-
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py     |    6 +++---
 5 files changed, 14 insertions(+), 8 deletions(-)
bitbake/lib/bb/command.py +2 -1
index 1893cce..5eb34af 100644
@@ -215,8 +215,9 @@ class CommandsSync:
         base_image = params[1]
         package_queue = params[2]
         timestamp = params[3]
+        description = params[4]
         return command.cooker.generateNewImage(image, base_image,
-                                 package_queue, timestamp)
+                        package_queue, timestamp, description)
 
     def ensureDir(self, command, params):
         directory = params[0]
bitbake/lib/bb/cooker.py +4 -1
index 4a5638f..7ca9947 100644
@@ -1100,7 +1100,7 @@ class BBCooker:
 
         self.configuration.server_register_idlecallback(buildTargetsIdle, rq)
 
-    def generateNewImage(self, image, base_image, package_queue, timestamp):
+    def generateNewImage(self, image, base_image, package_queue, timestamp, description):
         '''
         Create a new image with a "require"/"inherit" base_image statement
         '''
@@ -1125,6 +1125,9 @@ class BBCooker:
             package_install += "\"\n"
             imagefile.write(package_install)
 
+            description_var = "DESCRIPTION = \"" + description + "\"\n"
+            imagefile.write(description_var)
+
         self.state = state.initial
         if timestamp:
             return timestr
bitbake/lib/bb/ui/crumbs/builder.py +2 -2
index 0a04c90..6bf4024 100755
@@ -593,12 +593,12 @@ class Builder(gtk.Window):
                                     toolchain_packages,
                                     self.configuration.default_task)
 
-    def generate_new_image(self, image):
+    def generate_new_image(self, image, description):
         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)
+        self.handler.generate_new_image(image, base_image, packages, description)
 
     def ensure_dir(self, directory):
         self.handler.ensure_dir(directory)
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py +3 -1
index b2fa3bd..b94e69f 100644
@@ -116,8 +116,10 @@ class SaveImageDialog (CrumbsDialog):
     def save_button_cb(self, button):
         text = self.name_entry.get_text()
         new_text = text.replace("-","")
+        description_buffer = self.description_entry.get_buffer()
+        description = description_buffer.get_text(description_buffer.get_start_iter(),description_buffer.get_end_iter())
         if new_text.islower() and new_text.isalnum():
-            self.builder.generate_new_image(self.directory+text)
+            self.builder.generate_new_image(self.directory+text, description)
             self.destroy()
         else:
             self.show_invalid_input_error_dialog()
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +3 -3
index 34cd347..42fd0b9 100644
@@ -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, True])
+                    version = self.runCommand(["generateNewImage", hobImage, baseImage, self.package_queue, True, ""])
                     targets[0] += version
                     self.recipe_model.set_custom_image_version(version)
 
@@ -426,9 +426,9 @@ 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):
+    def generate_new_image(self, image, base_image, package_queue, description):
         base_image = self.runCommand(["matchFile", self.base_image + ".bb"])
-        self.runCommand(["generateNewImage", image, base_image, package_queue, False])
+        self.runCommand(["generateNewImage", image, base_image, package_queue, False, description])
 
     def ensure_dir(self, directory):
         self.runCommand(["ensureDir", directory])
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 5/16 hob: make changes in order to permit from UI to edit an image after saving it

In reply to Cristiana Voicu

Added the image name to the list model, in order to show the image name as the user named it.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |    4 ++++
 bitbake/lib/bb/ui/crumbs/hoblistmodel.py        |   28 +++++++++++++++--------
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py    |   10 ++++++--
 3 files changed, 31 insertions(+), 11 deletions(-)
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py +4 -0
index b94e69f..9ea512f 100644
@@ -119,7 +119,11 @@ class SaveImageDialog (CrumbsDialog):
         description_buffer = self.description_entry.get_buffer()
         description = description_buffer.get_text(description_buffer.get_start_iter(),description_buffer.get_end_iter())
         if new_text.islower() and new_text.isalnum():
+            self.builder.image_details_page.image_saved = True
             self.builder.generate_new_image(self.directory+text, description)
+            self.builder.recipe_model.set_in_list(text, description)
+            self.builder.recipe_model.set_selected_image(text)
+            self.builder.image_details_page.show_page(self.builder.IMAGE_GENERATED)
             self.destroy()
         else:
             self.show_invalid_input_error_dialog()
bitbake/lib/bb/ui/crumbs/hoblistmodel.py +19 -9
index d8f3256..34ff76a 100644
@@ -678,15 +678,8 @@ class RecipeListModel(gtk.ListStore):
         self.clear()
 
         # dummy image for prompt
-        self.set(self.append(), self.COL_NAME, self.__custom_image__,
-                 self.COL_DESC, "Use 'Edit image recipe' to customize recipes and packages " \
-                                "to be included in your image ",
-                 self.COL_LIC, "", self.COL_GROUP, "",
-                 self.COL_DEPS, "", self.COL_BINB, "",
-                 self.COL_TYPE, "image", self.COL_INC, False,
-                 self.COL_IMG, False, self.COL_INSTALL, "", self.COL_PN, self.__custom_image__,
-                 self.COL_SUMMARY, "", self.COL_VERSION, "", self.COL_REVISION, "",
-                 self.COL_HOMEPAGE, "", self.COL_BUGTRACKER, "")
+        self.set_in_list(self.__custom_image__,  "Use 'Edit image recipe' to customize recipes and packages " \
+                                "to be included in your image ")
 
         for item in event_model["pn"]:
             name = item
@@ -732,6 +725,23 @@ class RecipeListModel(gtk.ListStore):
             self.pn_path[pn] = path
             it = self.iter_next(it)
 
+    def set_in_list(self, item, desc):
+        self.set(self.append(), self.COL_NAME, item,
+                 self.COL_DESC, desc,
+                 self.COL_LIC, "", self.COL_GROUP, "",
+                 self.COL_DEPS, "", self.COL_BINB, "",
+                 self.COL_TYPE, "image", self.COL_INC, False,
+                 self.COL_IMG, False, self.COL_INSTALL, "", self.COL_PN, item,
+                 self.COL_SUMMARY, "", self.COL_VERSION, "", self.COL_REVISION, "",
+                 self.COL_HOMEPAGE, "", self.COL_BUGTRACKER, "")
+        self.pn_path = {}
+        it = self.get_iter_first()
+        while it:
+            pn = self.get_value(it, self.COL_NAME)
+            path = self.get_path(it)
+            self.pn_path[pn] = path
+            it = self.iter_next(it)
+
     """
     Update the model, send out the notification.
     """
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +8 -2
index f55d43f..eaa4588 100755
@@ -189,6 +189,7 @@ class ImageDetailsPage (HobPage):
         self.image_store = []
         self.button_ids = {}
         self.details_bottom_buttons = gtk.HBox(False, 6)
+        self.image_saved = False
         self.create_visual_elements()
 
     def create_visual_elements(self):
@@ -248,7 +249,7 @@ class ImageDetailsPage (HobPage):
         self.pack_start(self.group_align, expand=True, fill=True)
 
         self.build_result = None
-        if self.build_succeeded and self.builder.current_step == self.builder.IMAGE_GENERATING:
+        if self.image_saved or (self.build_succeeded and self.builder.current_step == self.builder.IMAGE_GENERATING):
             # building is the previous step
             icon = gtk.Image()
             pixmap_path = hic.ICON_INDI_CONFIRM_FILE
@@ -256,7 +257,10 @@ class ImageDetailsPage (HobPage):
             pix_buffer = gtk.gdk.pixbuf_new_from_file(pixmap_path)
             icon.set_from_pixbuf(pix_buffer)
             varlist = [""]
-            vallist = ["Your image is ready"]
+            if self.image_saved:
+                vallist = ["Your image recipe has been saved"]
+            else:
+                vallist = ["Your image is ready"]
             self.build_result = self.BuildDetailBox(varlist=varlist, vallist=vallist, icon=icon, color=color)
             self.box_group_area.pack_start(self.build_result, expand=False, fill=False)
 
@@ -397,6 +401,7 @@ class ImageDetailsPage (HobPage):
         self.show_all()
         if self.kernel_detail and (not is_runnable):
             self.kernel_detail.hide()
+        self.image_saved = False
 
     def view_files_clicked_cb(self, button, image_addr):
         subprocess.call("xdg-open /%s" % image_addr, shell=True)
@@ -583,6 +588,7 @@ class ImageDetailsPage (HobPage):
         name = "Save image recipe"
         if name in buttonlist and self.builder.recipe_model.is_custom_image():
             save_button = HobAltButton("Save image recipe")
+            save_button.set_sensitive(not self.image_saved)
             button_id = save_button.connect("clicked", self.save_button_clicked_cb)
             self.button_ids[button_id] = save_button
             self.details_bottom_buttons.pack_end(save_button, expand=False, fill=False)
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 6/16 hob & bitbake: append a value to a variable from hob throught bitbake

In reply to Cristiana Voicu

It was necessary to append ${TOPDIR}/recipes/images to BBFILES. Implemented the mechanism to append a value to a variable: a command and the method in cooker.

[YOCTO #4193]
---
 bitbake/lib/bb/command.py                   |    5 +++--
 bitbake/lib/bb/cooker.py                    |   29 +++++++++++++++++++++++++++
 bitbake/lib/bb/data.py                      |    4 ++++
 bitbake/lib/bb/ui/crumbs/builder.py         |    1 +
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py |   11 +++++++++-
 5 files changed, 47 insertions(+), 3 deletions(-)
bitbake/lib/bb/command.py +3 -2
index 5eb34af..33a2440 100644
@@ -153,7 +153,7 @@ class CommandsSync:
         varname = params[0]
         expand = True
         if len(params) > 1:
-            expand = params[1]
+            expand = (params[1] == "True")
 
         return command.cooker.data.getVar(varname, expand)
     getVariable.readonly = True
@@ -230,7 +230,8 @@ class CommandsSync:
         var = params[0]
         val = params[1]
         default_file = params[2]
-        command.cooker.saveConfigurationVar(var, val, default_file)
+        op = params[3]
+        command.cooker.modifyConfigurationVar(var, val, default_file, op)
 
     def createConfigFile(self, command, params):
         """
bitbake/lib/bb/cooker.py +29 -0
index 7ca9947..a4a6be6 100644
@@ -162,6 +162,35 @@ class BBCooker:
         self.data = self.databuilder.data
         self.data_hash = self.databuilder.data_hash
 
+    def modifyConfigurationVar(self, var, val, default_file, op):
+        if op == "append":
+            self.appendConfigurationVar(var, val, default_file)
+        elif op == "set":
+            self.saveConfigurationVar(var, val, default_file)
+
+    def appendConfigurationVar(self, var, val, default_file):
+        #add append var operation to the end of default_file
+        default_file = bb.cookerdata.findConfigFile(default_file)
+
+        with open(default_file, 'r') as f:
+            contents = f.readlines()
+        f.close()
+
+        total = ""
+        for c in contents:
+            total += c
+
+        total += "#added by bitbake"
+        total += "\n%s += \"%s\"\n" % (var, val)
+
+        with open(default_file, 'w') as f:
+            f.write(total)
+        f.close()
+
+        #add to history
+        loginfo = {"op":append, "file":default_file, "line":total.count("\n")}
+        self.data.appendVar(var, val, **loginfo)
+
     def saveConfigurationVar(self, var, val, default_file):
 
         replaced = False
bitbake/lib/bb/data.py +4 -0
index 87c4808..8c9cb0f 100644
@@ -97,6 +97,10 @@ def delVar(var, d):
     """Removes a variable from the data set"""
     d.delVar(var)
 
+def appendVar(var, value, d):
+    """Append additional value to a variable"""
+    d.appendVar(var, value)
+
 def setVarFlag(var, flag, flagvalue, d):
     """Set a flag for a given variable to a given value"""
     d.setVarFlag(var, flag, flagvalue)
bitbake/lib/bb/ui/crumbs/builder.py +1 -0
index 6bf4024..3ddfb36 100755
@@ -440,6 +440,7 @@ class Builder(gtk.Window):
         self.handler.connect("recipe-populated",         self.handler_recipe_populated_cb)
         self.handler.connect("package-populated",        self.handler_package_populated_cb)
 
+        self.handler.append_to_bbfiles("${TOPDIR}/recipes/images/*.bb")
         self.initiate_new_build_async()
 
         signal.signal(signal.SIGINT, self.event_handle_SIGINT)
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +10 -1
index 42fd0b9..7854742 100644
@@ -471,9 +471,18 @@ class HobHandler(gobject.GObject):
 
     def set_var_in_file(self, var, val, default_file=None):
         self.runCommand(["enableDataTracking"])
-        self.server.runCommand(["setVarFile", var, val, default_file])
+        self.server.runCommand(["setVarFile", var, val, default_file, "set"])
         self.runCommand(["disableDataTracking"])
 
+    def append_var_in_file(self, var, val, default_file=None):
+        self.server.runCommand(["setVarFile", var, val, default_file, "append"])
+
+    def append_to_bbfiles(self, val):
+        bbfiles = self.runCommand(["getVariable", "BBFILES", "False"]) or ""
+        bbfiles = bbfiles.split()
+        if val not in bbfiles:
+            self.append_var_in_file("BBFILES", val, "local.conf")
+
     def get_parameters(self):
         # retrieve the parameters from bitbake
         params = {}
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 7/16 hob: change the name and description for the saveimagedialog

In reply to Cristiana Voicu

The image name and description should be saved for a future save.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |    8 +++++++-
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py    |    6 ++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py +7 -1
index 9ea512f..a20afcd 100644
@@ -29,10 +29,12 @@ class SaveImageDialog (CrumbsDialog):
     This class is used to create a dialog that permits to save
     a custom image in a predefined directory.
     """
-    def __init__(self, directory, title, parent, flags, buttons=None):
+    def __init__(self, directory, name, description, title, parent, flags, buttons=None):
         super(SaveImageDialog, self).__init__(title, parent, flags, buttons)
         self.directory = directory
         self.builder = parent
+        self.name_field = name
+        self.description_field = description
 
         # create visual elements on the dialog
         self.create_visual_elements()
@@ -52,6 +54,7 @@ class SaveImageDialog (CrumbsDialog):
         content += "characters. The only special character you can use is the ASCII hyphen (-)."
         sub_label.set_markup(content)
         self.name_entry = gtk.Entry()
+        self.name_entry.set_text(self.name_field)
         self.name_entry.set_size_request(350,30)
         self.name_entry.connect("changed", self.name_entry_changed)
         sub_vbox.pack_start(label, expand=False, fill=False)
@@ -67,6 +70,7 @@ class SaveImageDialog (CrumbsDialog):
         sub_label.set_alignment(0, 0)
         sub_label.set_markup("The description should be less than 150 characters long.")
         self.description_entry = gtk.TextView()
+        self.description_entry.get_buffer().set_text(self.description_field)
         self.description_entry.set_wrap_mode(gtk.WRAP_WORD)
         self.description_entry.set_size_request(350,150)
         sub_vbox.pack_start(label, expand=False, fill=False)
@@ -124,6 +128,8 @@ class SaveImageDialog (CrumbsDialog):
             self.builder.recipe_model.set_in_list(text, description)
             self.builder.recipe_model.set_selected_image(text)
             self.builder.image_details_page.show_page(self.builder.IMAGE_GENERATED)
+            self.builder.image_details_page.name_field_template = text
+            self.builder.image_details_page.description_field_template = description
             self.destroy()
         else:
             self.show_invalid_input_error_dialog()
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +4 -2
index eaa4588..f50552f 100755
@@ -191,6 +191,8 @@ class ImageDetailsPage (HobPage):
         self.details_bottom_buttons = gtk.HBox(False, 6)
         self.image_saved = False
         self.create_visual_elements()
+        self.name_field_template = ""
+        self.description_field_template = ""
 
     def create_visual_elements(self):
         # create visual elements
@@ -632,8 +634,8 @@ class ImageDetailsPage (HobPage):
         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)
+        dialog = SaveImageDialog(images_dir, self.name_field_template, self.description_field_template,
+                 "Save image recipe", self.builder, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
         response = dialog.run()
         dialog.destroy()
 
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH 8/16 hob: the saved image should be editable

In reply to Cristiana Voicu

Also, the image can be saved when the a name is filled.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py +3 -1
index a20afcd..644a4a4 100644
@@ -99,7 +99,8 @@ class SaveImageDialog (CrumbsDialog):
         self.save_button.set_label("Save")
         self.save_button.connect("clicked", self.save_button_cb)
         self.save_button.set_size_request(110, 30)
-        self.save_button.set_sensitive(False)
+        if self.name_entry.get_text() == '':
+            self.save_button.set_sensitive(False)
 
         table.attach(cancel_button, 2, 3, 0, 1)
         table.attach(self.save_button, 3, 4, 0, 1)
@@ -124,6 +125,7 @@ class SaveImageDialog (CrumbsDialog):
         description = description_buffer.get_text(description_buffer.get_start_iter(),description_buffer.get_end_iter())
         if new_text.islower() and new_text.isalnum():
             self.builder.image_details_page.image_saved = True
+            self.builder.customized = False
             self.builder.generate_new_image(self.directory+text, description)
             self.builder.recipe_model.set_in_list(text, description)
             self.builder.recipe_model.set_selected_image(text)
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH 9/16 hob/bitbake: when an image is saved, it should require an image from layers

In reply to Cristiana Voicu

Saving an image that requires another image will cause issues when the second on is removed. So, we have agreed to "require" only the images from layers.
The functionality is implemented in bitbake, in order to be more abstract, and it is used by Hob when an image recipe is saved.

[YOCTO #4193]
---
 bitbake/lib/bb/cooker.py |    7 +++++++
 1 file changed, 7 insertions(+)
bitbake/lib/bb/cooker.py +7 -0
index a4a6be6..f009210 100644
@@ -1143,10 +1143,17 @@ class BBCooker:
             else:
                 dest = image
 
+        if base_image:
+            with open(base_image, 'r') as f:
+                require_line = f.readline()
+
         with open(dest, "w") as imagefile:
             if base_image is None:
                 imagefile.write("inherit image\n")
             else:
+                topdir = self.data.getVar("TOPDIR")
+                if topdir in base_image:
+                    base_image = require_line.split()[1]
                 imagefile.write("require " + base_image + "\n")
             package_install = "PACKAGE_INSTALL_forcevariable = \""
             for package in package_queue:
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH 10/16 hob: changes to image combo box

In reply to Cristiana Voicu

Added an item for the custom images.
Added a separator in the combo box.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py +14 -2
index e4c6606..8da2861 100644
@@ -35,7 +35,8 @@ from bb.ui.crumbs.hobpages import HobPage
 class ImageConfigurationPage (HobPage):
 
     __dummy_machine__ = "--select a machine--"
-    __dummy_image__   = "Select from my image recipes"
+    __dummy_image__   = "--select an image recipe--"
+    __custom_image__  = "Select from my image recipes"
 
     def __init__(self, builder):
         super(ImageConfigurationPage, self).__init__(builder, "Image configuration")
@@ -238,6 +239,7 @@ class ImageConfigurationPage (HobPage):
         self.image_title_desc.set_markup(mark)
 
         self.image_combo = gtk.combo_box_new_text()
+        self.image_combo.set_row_separator_func(self.combo_separator_func, None)
         self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb)
 
         self.image_desc = gtk.Label()
@@ -256,6 +258,11 @@ class ImageConfigurationPage (HobPage):
 
         self.image_separator = gtk.HSeparator()
 
+    def combo_separator_func(self, model, iter, user_data):
+        name = model.get_value(iter, 0)
+        if name == "--Separator--":
+            return True
+
     def set_config_baseimg_layout(self):
         self.gtable.attach(self.image_title, 0, 40, 15+self.warning_shift, 17+self.warning_shift)
         self.gtable.attach(self.image_title_desc, 0, 40, 18+self.warning_shift, 22+self.warning_shift)
@@ -358,6 +365,8 @@ class ImageConfigurationPage (HobPage):
     def image_combo_changed_cb(self, combo):
         self.builder.window_sensitive(False)
         selected_image = self.image_combo.get_active_text()
+        if selected_image == self.__custom_image__:
+            return
         if not selected_image or (selected_image == self.__dummy_image__):
             return
 
@@ -424,6 +433,10 @@ class ImageConfigurationPage (HobPage):
             self.image_combo.append_text(self.__dummy_image__)
             cnt = cnt + 1
 
+        self.image_combo.append_text(self.__custom_image__)
+        self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
+        self.image_combo.append_text("--Separator--")
+
         # append and set active
         while it:
             path = image_model.get_path(it)
@@ -453,7 +466,6 @@ class ImageConfigurationPage (HobPage):
                     active = cnt
                 cnt = cnt + 1
 
-        self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
         if selected_image == self.builder.recipe_model.__custom_image__:
             active = cnt
 
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH 11/16 hob: retrieve file name of an image

In reply to Cristiana Voicu

The entire file name (with the path) is needed to know if the image is located in the "build" directory or it comes from layers. According to this information, the image is placed differently in the combobox.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/hoblistmodel.py           |    7 +++++--
 bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py |    5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)
bitbake/lib/bb/ui/crumbs/hoblistmodel.py +5 -2
index 34ff76a..74d335c 100644
@@ -474,7 +474,7 @@ class RecipeListModel(gtk.ListStore):
     provide filtered views of the data.
     """
     (COL_NAME, COL_DESC, COL_LIC, COL_GROUP, COL_DEPS, COL_BINB, COL_TYPE, COL_INC, COL_IMG, COL_INSTALL, COL_PN, COL_FADE_INC, COL_SUMMARY, COL_VERSION,
-     COL_REVISION, COL_HOMEPAGE, COL_BUGTRACKER) = range(17)
+     COL_REVISION, COL_HOMEPAGE, COL_BUGTRACKER, COL_FILE) = range(18)
 
     __custom_image__ = "Start with an empty image recipe"
 
@@ -504,6 +504,7 @@ class RecipeListModel(gtk.ListStore):
                                 gobject.TYPE_STRING,
                                 gobject.TYPE_STRING,
                                 gobject.TYPE_STRING,
+                                gobject.TYPE_STRING,
                                 gobject.TYPE_STRING)
         self.sort_column_id, self.sort_order = RecipeListModel.COL_NAME, gtk.SORT_ASCENDING
 
@@ -692,6 +693,7 @@ class RecipeListModel(gtk.ListStore):
             revision = event_model["pn"][item]["revision"]
             homepage = event_model["pn"][item]["homepage"]
             bugtracker = event_model["pn"][item]["bugtracker"]
+            filename = event_model["pn"][item]["filename"]
             install = []
 
             depends = event_model["depends"].get(item, []) + event_model["rdepends-pn"].get(item, [])
@@ -715,7 +717,8 @@ class RecipeListModel(gtk.ListStore):
                      self.COL_TYPE, atype, self.COL_INC, False,
                      self.COL_IMG, False, self.COL_INSTALL, " ".join(install), self.COL_PN, item,
                      self.COL_SUMMARY, summary, self.COL_VERSION, version, self.COL_REVISION, revision,
-                     self.COL_HOMEPAGE, homepage, self.COL_BUGTRACKER, bugtracker)
+                     self.COL_HOMEPAGE, homepage, self.COL_BUGTRACKER, bugtracker,
+                     self.COL_FILE, filename)
 
         self.pn_path = {}
         it = self.get_iter_first()
bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py +5 -0
index 8da2861..3d86b6b 100644
@@ -437,6 +437,7 @@ class ImageConfigurationPage (HobPage):
         self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
         self.image_combo.append_text("--Separator--")
 
+        topdir = self.builder.get_topdir()
         # append and set active
         while it:
             path = image_model.get_path(it)
@@ -460,6 +461,10 @@ class ImageConfigurationPage (HobPage):
             else:
                 allow = True
 
+            file_name = image_model[path][recipe_model.COL_FILE]
+            if file_name and topdir in file_name:
+                allow = False
+
             if allow:
                 self.image_combo.append_text(image_name)
                 if image_name == selected_image:
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH 12/16 hob: implement the "retrieve image dialog" + changes to image combo box

In reply to Cristiana Voicu

Tha changes related to the image combo box are related to the action done in the retrieveImageDialog. When the user wants to select a customize image, but then he cancels the action, the combo box is set to --select a base image--.
If the user selects an image using the new dialog, a new item with its name is added to the combo box list and then it is activated.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/builder.py                |    1 +
 .../lib/bb/ui/crumbs/hig/retrieveimagedialog.py    |   49 ++++++++++++++++++++
 bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py |   37 +++++++++++++--
 3 files changed, 84 insertions(+), 3 deletions(-)
 create mode 100644 bitbake/lib/bb/ui/crumbs/hig/retrieveimagedialog.py
bitbake/lib/bb/ui/crumbs/builder.py +1 -0
index 3ddfb36..86fdbfe 100755
@@ -520,6 +520,7 @@ class Builder(gtk.Window):
         self.handler.generate_configuration()
 
     def initiate_new_build_async(self):
+        self.configuration.selected_image = None
         self.switch_page(self.MACHINE_SELECTION)
         self.handler.init_cooker()
         self.handler.set_extra_inherit("image_types")
bitbake/lib/bb/ui/crumbs/hig/retrieveimagedialog.py new file +49 -0

49 lines not on this page · raw message

bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py +34 -3
index 3d86b6b..e1211bc 100644
@@ -28,6 +28,7 @@ from bb.ui.crumbs.hobcolor import HobColors
 from bb.ui.crumbs.hobwidget import hic, HobImageButton, HobInfoButton, HobAltButton, HobButton
 from bb.ui.crumbs.hoblistmodel import RecipeListModel
 from bb.ui.crumbs.hobpages import HobPage
+from bb.ui.crumbs.hig.retrieveimagedialog import RetrieveImageDialog
 
 #
 # ImageConfigurationPage
@@ -48,6 +49,7 @@ class ImageConfigurationPage (HobPage):
         self.machine_combo_changed_by_manual = True
         self.stopping = False
         self.warning_shift = 0
+        self.custom_image_selected = None
         self.create_visual_elements()
 
     def create_visual_elements(self):
@@ -366,8 +368,28 @@ class ImageConfigurationPage (HobPage):
         self.builder.window_sensitive(False)
         selected_image = self.image_combo.get_active_text()
         if selected_image == self.__custom_image__:
-            return
+            topdir = self.builder.get_topdir()
+            images_dir = topdir + "/recipes/images/"
+            self.builder.ensure_dir(images_dir)
+
+            dialog = RetrieveImageDialog(images_dir, "Select from my image recipes",
+                            self.builder, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
+            response = dialog.run()
+            if response == gtk.RESPONSE_OK:
+                image_name = dialog.get_filename()
+                head, tail = os.path.split(image_name)
+                selected_image = os.path.splitext(tail)[0]
+                self.custom_image_selected = selected_image
+                self.update_image_combo(self.builder.recipe_model, selected_image)
+            else:
+                selected_image = self.__dummy_image__
+                self.update_image_combo(self.builder.recipe_model, None)
+            dialog.destroy()
+
         if not selected_image or (selected_image == self.__dummy_image__):
+            self.builder.window_sensitive(True)
+            self.just_bake_button.hide()
+            self.edit_image_button.hide()
             return
 
         # remove __dummy_image__ item from the store list after first user selection
@@ -436,6 +458,7 @@ class ImageConfigurationPage (HobPage):
         self.image_combo.append_text(self.__custom_image__)
         self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
         self.image_combo.append_text("--Separator--")
+        cnt = cnt + 3
 
         topdir = self.builder.get_topdir()
         # append and set active
@@ -471,6 +494,14 @@ class ImageConfigurationPage (HobPage):
                     active = cnt
                 cnt = cnt + 1
 
+        if self.custom_image_selected:
+            self.image_combo.append_text("--Separator--")
+            cnt = cnt + 1
+            self.image_combo.append_text(self.custom_image_selected)
+            if self.custom_image_selected == selected_image:
+                active = cnt
+            cnt = cnt + 1
+
         if selected_image == self.builder.recipe_model.__custom_image__:
             active = cnt
 
@@ -484,14 +515,14 @@ class ImageConfigurationPage (HobPage):
     def layer_button_clicked_cb(self, button):
         # Create a layer selection dialog
         self.builder.show_layer_selection_dialog()
-        
+
     def view_adv_configuration_button_clicked_cb(self, button):
         # Create an advanced settings dialog
         response, settings_changed = self.builder.show_adv_settings_dialog()
         if not response:
             return
         if settings_changed:
-            self.builder.reparse_post_adv_settings()        
+            self.builder.reparse_post_adv_settings()
 
     def just_bake_button_clicked_cb(self, button):
         self.builder.parsing_warnings = []
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH 13/16 bitbake: save packages in IMAGE_INSTALL instead of PACKAGE_INSTALL

In reply to Cristiana Voicu

Hob retrieves the list of recipes and packages using the IMAGE_INSTALL variable, so a custom image should be saved using this variable. Changed how the image is saved in a bb file

[YOCTO #4193]
---
 bitbake/lib/bb/cooker.py |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
bitbake/lib/bb/cooker.py +4 -4
index f009210..97210ba 100644
@@ -1155,11 +1155,11 @@ class BBCooker:
                 if topdir in base_image:
                     base_image = require_line.split()[1]
                 imagefile.write("require " + base_image + "\n")
-            package_install = "PACKAGE_INSTALL_forcevariable = \""
+            image_install = "IMAGE_INSTALL = \""
             for package in package_queue:
-                package_install += str(package) + " "
-            package_install += "\"\n"
-            imagefile.write(package_install)
+                image_install += str(package) + " "
+            image_install += "\"\n"
+            imagefile.write(image_install)
 
             description_var = "DESCRIPTION = \"" + description + "\"\n"
             imagefile.write(description_var)
Signature · 1 line
1.7.9.5
#14 lore raw

PATCH 14/16 hob: set focus on entry name when the name is not correct

In reply to Cristiana Voicu
[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py |    1 +
 1 file changed, 1 insertion(+)
bitbake/lib/bb/ui/crumbs/hig/saveimagedialog.py +1 -0
index 644a4a4..56c00bb 100644
@@ -147,4 +147,5 @@ class SaveImageDialog (CrumbsDialog):
         HobButton.style_button(button)
 
         res = dialog.run()
+        self.name_entry.grab_focus()
         dialog.destroy()
Signature · 1 line
1.7.9.5
#15 lore raw

PATCH 15/16 hob/imagedetailspage: add tooltip for save image recipe button

In reply to Cristiana Voicu
[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/imagedetailspage.py |    1 +
 1 file changed, 1 insertion(+)
bitbake/lib/bb/ui/crumbs/imagedetailspage.py +1 -0
index f50552f..ca33e08 100755
@@ -590,6 +590,7 @@ class ImageDetailsPage (HobPage):
         name = "Save image recipe"
         if name in buttonlist and self.builder.recipe_model.is_custom_image():
             save_button = HobAltButton("Save image recipe")
+            save_button.set_tooltip_text("Keep your changes saving them as an image recipe")
             save_button.set_sensitive(not self.image_saved)
             button_id = save_button.connect("clicked", self.save_button_clicked_cb)
             self.button_ids[button_id] = save_button
Signature · 1 line
1.7.9.5
#16 lore raw

PATCH 16/16 hob/imageconfigurationpage: changes to image combobox

In reply to Cristiana Voicu

Place the "Create your own image recipe" field to the end of the image recipes list.

[YOCTO #4193]
---
 bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/ui/crumbs/imageconfigurationpage.py +1 -1
index e1211bc..dcf1334 100644
@@ -456,7 +456,6 @@ class ImageConfigurationPage (HobPage):
             cnt = cnt + 1
 
         self.image_combo.append_text(self.__custom_image__)
-        self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
         self.image_combo.append_text("--Separator--")
         cnt = cnt + 3
 
@@ -493,6 +492,7 @@ class ImageConfigurationPage (HobPage):
                 if image_name == selected_image:
                     active = cnt
                 cnt = cnt + 1
+        self.image_combo.append_text(self.builder.recipe_model.__custom_image__)
 
         if self.custom_image_selected:
             self.image_combo.append_text("--Separator--")
Signature · 1 line
1.7.9.5