Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCH 0/3 V2] hob2: remove hard-coded image types map
@ 2012-08-28  2:47 Kang Kai
  2012-08-28  2:47 ` [PATCH 1/3] hob2: remove the hard-coded images map Kang Kai
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-28  2:47 UTC (permalink / raw)
  To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao

Hi Richard,

This is V2 for Yocto 2795.

Just add variable IMAGE_EXTENSION_live as you suggest, other image types are the same with the real image name extension names.

Add update the hob code accordingly.

Regards,
Kai

The following changes since commit b4c5725af4cd85d5644f0373e2674e903c4eab2b:

  yocto-bsp: add missing xserver-xf86-config .bbappend for qemu (2012-08-25 14:47:07 +0100)

are available in the git repository at:
  git://git.pokylinux.org/poky-contrib kangkai/hob2
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/hob2

Kang Kai (3):
  hob2: remove the hard-coded images map
  hob2: remove class hcc
  image_types.bbclass: add variable for Hob

 bitbake/lib/bb/ui/crumbs/builder.py         |   24 ++++++++++++++++++---
 bitbake/lib/bb/ui/crumbs/hig.py             |   11 +++++++--
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py |    1 -
 bitbake/lib/bb/ui/crumbs/hobwidget.py       |   29 ---------------------------
 meta/classes/image_types.bbclass            |    3 ++
 5 files changed, 31 insertions(+), 37 deletions(-)

-- 
1.7.5.4




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] hob2: remove the hard-coded images map
  2012-08-28  2:47 [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
@ 2012-08-28  2:47 ` Kang Kai
  2012-08-28  2:47 ` [PATCH 2/3] hob2: remove class hcc Kang Kai
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-28  2:47 UTC (permalink / raw)
  To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao

[Yocto #2795]

When a new image type added, the hob will crash because the new type is
not in the hard-coded image dictionary.

For most of the image types, they are same with the image file's
extension name. So use variable "IMAGE_EXTENSION_difftype" to map the
image type which is diff with the image file extension name, such as
type "live". And the variable(s) will be set in image_types.bbclass.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 bitbake/lib/bb/ui/crumbs/builder.py |   22 +++++++++++++++++++---
 bitbake/lib/bb/ui/crumbs/hig.py     |    9 +++++++--
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 7de4798..5421fb6 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -893,8 +893,13 @@ class Builder(gtk.Window):
                 linkname = 'hob-image-' + self.configuration.curr_mach
             else:
                 linkname = selected_image + '-' + self.configuration.curr_mach
+            image_extension = self.get_image_extension()
             for image_type in self.parameters.image_types:
-                for real_image_type in hcc.SUPPORTED_IMAGE_TYPES[image_type]:
+                if image_type in image_extension:
+                    real_types = image_extension[image_type]
+                else:
+                    real_types = [image_type]
+                for real_image_type in real_types:
                     linkpath = self.parameters.image_addr + '/' + linkname + '.' + real_image_type
                     if os.path.exists(linkpath):
                         self.parameters.image_names.append(os.readlink(linkpath))
@@ -1114,10 +1119,21 @@ class Builder(gtk.Window):
             self.save_template(path)
         dialog.destroy()
 
+    def get_image_extension(self):
+        image_extension = {}
+        for type in self.parameters.image_types:
+            ext = self.handler.runCommand(["getVariable", "IMAGE_EXTENSION_%s" % type])
+            if ext:
+                image_extension[type] = ext.split(' ')
+
+        return image_extension
+
     def show_load_my_images_dialog(self):
+        image_extension = self.get_image_extension()
         dialog = ImageSelectionDialog(self.parameters.image_addr, self.parameters.image_types,
                                       "Open My Images", self,
-                                       gtk.FILE_CHOOSER_ACTION_SAVE)
+                                       gtk.FILE_CHOOSER_ACTION_SAVE, None,
+                                       image_extension)
         button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
         HobAltButton.style_button(button)
         button = dialog.add_button("Open", gtk.RESPONSE_YES)
@@ -1334,4 +1350,4 @@ class Builder(gtk.Window):
             format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
             self.consolelog.setFormatter(format)
 
-            self.logger.addHandler(self.consolelog)
\ No newline at end of file
+            self.logger.addHandler(self.consolelog)
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index 2001ff4..6829927 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -1172,7 +1172,7 @@ class ImageSelectionDialog (CrumbsDialog):
     }]
 
 
-    def __init__(self, image_folder, image_types, title, parent, flags, buttons=None):
+    def __init__(self, image_folder, image_types, title, parent, flags, buttons=None, image_extension = {}):
         super(ImageSelectionDialog, self).__init__(title, parent, flags, buttons)
         self.connect("response", self.response_cb)
 
@@ -1180,6 +1180,7 @@ class ImageSelectionDialog (CrumbsDialog):
         self.image_types  = image_types
         self.image_list = []
         self.image_names = []
+        self.image_extension = image_extension
 
         # create visual elements on the dialog
         self.create_visual_elements()
@@ -1265,7 +1266,11 @@ class ImageSelectionDialog (CrumbsDialog):
             dirs[:] = []
             for f in files:
                 for image_type in self.image_types:
-                    for real_image_type in hcc.SUPPORTED_IMAGE_TYPES[image_type]:
+                    if image_type in self.image_extension:
+                        real_types = self.image_extension[image_type]
+                    else:
+                        real_types = [image_type]
+                    for real_image_type in real_types:
                         if f.endswith('.' + real_image_type):
                             imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0])
                             self.image_list.append(f)
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] hob2: remove class hcc
  2012-08-28  2:47 [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
  2012-08-28  2:47 ` [PATCH 1/3] hob2: remove the hard-coded images map Kang Kai
@ 2012-08-28  2:47 ` Kang Kai
  2012-08-28  2:47 ` [PATCH 3/3] image_types.bbclass: add variable for Hob Kang Kai
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-28  2:47 UTC (permalink / raw)
  To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao

Because class hcc is useless, remove it.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 bitbake/lib/bb/ui/crumbs/builder.py         |    2 +-
 bitbake/lib/bb/ui/crumbs/hig.py             |    2 +-
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py |    1 -
 bitbake/lib/bb/ui/crumbs/hobwidget.py       |   29 ---------------------------
 4 files changed, 2 insertions(+), 32 deletions(-)

diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 5421fb6..522bd1d 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -34,7 +34,7 @@ from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage
 from bb.ui.crumbs.packageselectionpage import PackageSelectionPage
 from bb.ui.crumbs.builddetailspage import BuildDetailsPage
 from bb.ui.crumbs.imagedetailspage import ImageDetailsPage
-from bb.ui.crumbs.hobwidget import hwc, HobButton, HobAltButton, hcc
+from bb.ui.crumbs.hobwidget import hwc, HobButton, HobAltButton
 from bb.ui.crumbs.hig import CrumbsMessageDialog, ImageSelectionDialog, \
                              AdvancedSettingDialog, LayerSelectionDialog, \
                              DeployImageDialog
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py
index 6829927..6b573a8 100644
--- a/bitbake/lib/bb/ui/crumbs/hig.py
+++ b/bitbake/lib/bb/ui/crumbs/hig.py
@@ -30,7 +30,7 @@ import shlex
 import subprocess
 import tempfile
 from bb.ui.crumbs.hobcolor import HobColors
-from bb.ui.crumbs.hobwidget import hcc, hic, HobViewTable, HobInfoButton, HobButton, HobAltButton, HobIconChecker
+from bb.ui.crumbs.hobwidget import hic, HobViewTable, HobInfoButton, HobButton, HobAltButton, HobIconChecker
 from bb.ui.crumbs.progressbar import HobProgressBar
 import bb.ui.crumbs.utils
 import bb.process
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 540dde0..dac2f74 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -22,7 +22,6 @@
 import gobject
 import logging
 from bb.ui.crumbs.runningbuild import RunningBuild
-from bb.ui.crumbs.hobwidget import hcc
 
 class HobHandler(gobject.GObject):
 
diff --git a/bitbake/lib/bb/ui/crumbs/hobwidget.py b/bitbake/lib/bb/ui/crumbs/hobwidget.py
index d10c56b..7c23440 100644
--- a/bitbake/lib/bb/ui/crumbs/hobwidget.py
+++ b/bitbake/lib/bb/ui/crumbs/hobwidget.py
@@ -63,35 +63,6 @@ class hic:
     ICON_INDI_TICK_FILE           = os.path.join(HOB_ICON_BASE_DIR, ('indicators/tick.png'))
     ICON_INDI_INFO_FILE           = os.path.join(HOB_ICON_BASE_DIR, ('indicators/info.png'))
 
-class hcc:
-
-    SUPPORTED_IMAGE_TYPES = {
-        "jffs2"         : ["jffs2"],
-        "sum.jffs2"     : ["sum.jffs2"],
-        "cramfs"        : ["cramfs"],
-        "ext2"          : ["ext2"],
-        "ext2.gz"       : ["ext2.gz"],
-        "ext2.bz2"      : ["ext2.bz2"],
-        "ext3"          : ["ext3"],
-        "ext3.gz"       : ["ext3.gz"],
-        "ext2.lzma"     : ["ext2.lzma"],
-        "btrfs"         : ["btrfs"],
-        "live"          : ["hddimg", "iso"],
-        "squashfs"      : ["squashfs"],
-        "squashfs-lzma" : ["squashfs-lzma"],
-        "ubi"           : ["ubi"],
-        "tar"           : ["tar"],
-        "tar.gz"        : ["tar.gz"],
-        "tar.bz2"       : ["tar.bz2"],
-        "tar.xz"        : ["tar.xz"],
-        "cpio"          : ["cpio"],
-        "cpio.gz"       : ["cpio.gz"],
-        "cpio.xz"       : ["cpio.xz"],
-        "vmdk"          : ["vmdk"],
-        "cpio.lzma"     : ["cpio.lzma"],
-        "elf"           : ["elf"],
-    }
-
 class HobViewTable (gtk.VBox):
     """
     A VBox to contain the table for different recipe views and package view
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] image_types.bbclass: add variable for Hob
  2012-08-28  2:47 [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
  2012-08-28  2:47 ` [PATCH 1/3] hob2: remove the hard-coded images map Kang Kai
  2012-08-28  2:47 ` [PATCH 2/3] hob2: remove class hcc Kang Kai
@ 2012-08-28  2:47 ` Kang Kai
  2012-09-07  2:29 ` [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
  2012-09-07 10:52 ` Richard Purdie
  4 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-28  2:47 UTC (permalink / raw)
  To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao

Add a new variable "IMAGE_EXTENSION_live" for Hob to map image type
"live" with real image file extension names.

This is for Hob to remove the hard-coded maps.

Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
 meta/classes/image_types.bbclass |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index d286eea..6f8514f 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -247,3 +247,6 @@ RUNNABLE_IMAGE_TYPES ?= "ext2 ext3"
 RUNNABLE_MACHINE_PATTERNS ?= "qemu"
 
 DEPLOYABLE_IMAGE_TYPES ?= "hddimg iso" 
+
+# Use IMAGE_EXTENSION_xxx to map image type 'xxx' with real image file extension name(s) for Hob
+IMAGE_EXTENSION_live = "hddimg iso"
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3 V2] hob2: remove hard-coded image types map
  2012-08-28  2:47 [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
                   ` (2 preceding siblings ...)
  2012-08-28  2:47 ` [PATCH 3/3] image_types.bbclass: add variable for Hob Kang Kai
@ 2012-09-07  2:29 ` Kang Kai
  2012-09-07 10:52 ` Richard Purdie
  4 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-09-07  2:29 UTC (permalink / raw)
  To: Kang Kai; +Cc: bitbake-devel, Zhenfeng.Zhao

On 2012年08月28日 10:47, Kang Kai wrote:
> Hi Richard,
>
> This is V2 for Yocto 2795.
>
> Just add variable IMAGE_EXTENSION_live as you suggest, other image types are the same with the real image name extension names.
>
> Add update the hob code accordingly.
Hi Richard,

Would you like to review these patches please?

Thanks,
Kai

>
> Regards,
> Kai
>
> The following changes since commit b4c5725af4cd85d5644f0373e2674e903c4eab2b:
>
>    yocto-bsp: add missing xserver-xf86-config .bbappend for qemu (2012-08-25 14:47:07 +0100)
>
> are available in the git repository at:
>    git://git.pokylinux.org/poky-contrib kangkai/hob2
>    http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/hob2
>
> Kang Kai (3):
>    hob2: remove the hard-coded images map
>    hob2: remove class hcc
>    image_types.bbclass: add variable for Hob
>
>   bitbake/lib/bb/ui/crumbs/builder.py         |   24 ++++++++++++++++++---
>   bitbake/lib/bb/ui/crumbs/hig.py             |   11 +++++++--
>   bitbake/lib/bb/ui/crumbs/hobeventhandler.py |    1 -
>   bitbake/lib/bb/ui/crumbs/hobwidget.py       |   29 ---------------------------
>   meta/classes/image_types.bbclass            |    3 ++
>   5 files changed, 31 insertions(+), 37 deletions(-)
>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3 V2] hob2: remove hard-coded image types map
  2012-08-28  2:47 [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
                   ` (3 preceding siblings ...)
  2012-09-07  2:29 ` [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
@ 2012-09-07 10:52 ` Richard Purdie
  4 siblings, 0 replies; 6+ messages in thread
From: Richard Purdie @ 2012-09-07 10:52 UTC (permalink / raw)
  To: Kang Kai; +Cc: bitbake-devel, Zhenfeng.Zhao

On Tue, 2012-08-28 at 10:47 +0800, Kang Kai wrote:
> Hi Richard,
> 
> This is V2 for Yocto 2795.
> 
> Just add variable IMAGE_EXTENSION_live as you suggest, other image types are the same with the real image name extension names.
> 
> Add update the hob code accordingly.
> 
> Regards,
> Kai
> 
> The following changes since commit b4c5725af4cd85d5644f0373e2674e903c4eab2b:
> 
>   yocto-bsp: add missing xserver-xf86-config .bbappend for qemu (2012-08-25 14:47:07 +0100)
> 
> are available in the git repository at:
>   git://git.pokylinux.org/poky-contrib kangkai/hob2
>   http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/hob2
> 
> Kang Kai (3):
>   hob2: remove the hard-coded images map
>   hob2: remove class hcc
>   image_types.bbclass: add variable for Hob

Merged to master, thanks.

Richard




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-09-07 11:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-28  2:47 [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
2012-08-28  2:47 ` [PATCH 1/3] hob2: remove the hard-coded images map Kang Kai
2012-08-28  2:47 ` [PATCH 2/3] hob2: remove class hcc Kang Kai
2012-08-28  2:47 ` [PATCH 3/3] image_types.bbclass: add variable for Hob Kang Kai
2012-09-07  2:29 ` [PATCH 0/3 V2] hob2: remove hard-coded image types map Kang Kai
2012-09-07 10:52 ` Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox