* [PATCH 1/3] hob2: remove the hard-coded images map
2012-08-24 9:15 [PATCH 0/3] hob2: remove hard-coded image types map Kang Kai
@ 2012-08-24 9:15 ` Kang Kai
2012-08-24 9:15 ` [PATCH 2/3] hob2: remove class hcc Kang Kai
2012-08-24 9:15 ` [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP Kang Kai
2 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-24 9:15 UTC (permalink / raw)
To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao
[Yocto #2795]
When a new image type added, because it is not in the hard-coded image
dictionary, then hob crashes.
Use a variable IMAGE_TYPES_MAP to present the image maps in a conf file.
If a new image type added, just update the IMAGE_TYPES_MAP.
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
bitbake/lib/bb/ui/crumbs/builder.py | 33 ++++++++++++++++++++++++--
bitbake/lib/bb/ui/crumbs/hig.py | 7 ++++-
bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 3 ++
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 7de4798..dde4214 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -451,8 +451,32 @@ class Builder(gtk.Window):
self.handler.set_config_filter(hob_conf_filter)
+ self.get_image_types()
+
self.initiate_new_build_async()
+ def get_image_types(self):
+ self.configuration.supported_image_types = {}
+ content = self.handler.get_image_types()
+ if content is None:
+ return
+
+ # format of variable IMAGE_TYPES_MAP should be:
+ # IMAGE_TYPES_MAP = "type1:name1 type2:name2,name3 ..."
+ content = content.strip()
+ content = re.sub("\s+", ' ', content)
+ content = re.sub("\s*:\s*", ':', content)
+ content = re.sub("\s*,\s*", ',', content)
+ items = content.split(' ')
+ for item in items:
+ try:
+ index = item.index(':')
+ typename = item[0:index]
+ realnames = item[index+1:]
+ self.configuration.supported_image_types[typename] = realnames.split(',')
+ except:
+ pass
+
def create_visual_elements(self):
self.set_title("Hob")
self.set_icon_name("applications-development")
@@ -894,7 +918,9 @@ class Builder(gtk.Window):
else:
linkname = selected_image + '-' + self.configuration.curr_mach
for image_type in self.parameters.image_types:
- for real_image_type in hcc.SUPPORTED_IMAGE_TYPES[image_type]:
+ if image_type not in self.configuration.supported_image_types:
+ continue
+ for real_image_type in self.configuration.supported_image_types[image_type]:
linkpath = self.parameters.image_addr + '/' + linkname + '.' + real_image_type
if os.path.exists(linkpath):
self.parameters.image_names.append(os.readlink(linkpath))
@@ -1117,7 +1143,8 @@ class Builder(gtk.Window):
def show_load_my_images_dialog(self):
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,
+ self.configuration.supported_image_types)
button = dialog.add_button("Cancel", gtk.RESPONSE_NO)
HobAltButton.style_button(button)
button = dialog.add_button("Open", gtk.RESPONSE_YES)
@@ -1334,4 +1361,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..014ea98 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, supported_image_types={}):
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.supported_image_types = supported_image_types
# create visual elements on the dialog
self.create_visual_elements()
@@ -1265,7 +1266,9 @@ 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 not in self.supported_image_types:
+ continue
+ for real_image_type in self.supported_image_types[image_type]:
if f.endswith('.' + real_image_type):
imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0])
self.image_list.append(f)
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 540dde0..16ab246 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -393,6 +393,9 @@ class HobHandler(gobject.GObject):
def get_logfile(self):
return self.server.runCommand(["getVariable", "BB_CONSOLELOG"])
+ def get_image_types(self):
+ return self.server.runCommand(["getVariable", "IMAGE_TYPES_MAP"])
+
def _remove_redundant(self, string):
ret = []
for i in string.split():
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] hob2: remove class hcc
2012-08-24 9:15 [PATCH 0/3] hob2: remove hard-coded image types map Kang Kai
2012-08-24 9:15 ` [PATCH 1/3] hob2: remove the hard-coded images map Kang Kai
@ 2012-08-24 9:15 ` Kang Kai
2012-08-24 9:15 ` [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP Kang Kai
2 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-24 9:15 UTC (permalink / raw)
To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao
Because class hcc is useless, so 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 dde4214..5677ccd 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 014ea98..7b6742d 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 16ab246..623e7d1 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] bitbake.conf: add variable IMAGE_TYPES_MAP
2012-08-24 9:15 [PATCH 0/3] hob2: remove hard-coded image types map Kang Kai
2012-08-24 9:15 ` [PATCH 1/3] hob2: remove the hard-coded images map Kang Kai
2012-08-24 9:15 ` [PATCH 2/3] hob2: remove class hcc Kang Kai
@ 2012-08-24 9:15 ` Kang Kai
2012-08-25 7:45 ` Richard Purdie
2 siblings, 1 reply; 6+ messages in thread
From: Kang Kai @ 2012-08-24 9:15 UTC (permalink / raw)
To: richard.purdie; +Cc: bitbake-devel, Zhenfeng.Zhao
Add variable IMAGE_TYPES_MAP to replace the hob2 hard-coded image types
map.
The format of IMAGE_TYPES_MAP is:
"image_type1:realname_extend1 image_type2:realname_extend2,extend3 ..."
Signed-off-by: Kang Kai <kai.kang@windriver.com>
---
meta/conf/bitbake.conf | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index ad98756..7d2a9b9 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -770,3 +770,6 @@ BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc defaultval _append _prepend deps depends lock
MLPREFIX ??= ""
MULTILIB_VARIANTS ??= ""
+
+# Used by to Hob to filter image files
+IMAGE_TYPES_MAP = "btrfs:btrfs cpio.gz:cpio.gz cpio.lzma:cpio.lzma cpio.xz:cpio.xz cpio:cpio cramfs:cramfs elf:elf ext2.bz2:ext2.bz2 ext2.gz:ext2.gz ext2.lzma:ext2.lzma ext2:ext2 ext3.gz:ext3.gz ext3:ext3 jffs2:jffs2 live:hddimg,iso squashfs-lzma:squashfs-lzma squashfs:squashfs sum.jffs2:sum.jffs2 tar.bz2:tar.bz2 tar.gz:tar.gz tar.xz:tar.xz tar:tar ubi:ubi vmdk:vmdk"
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP
2012-08-24 9:15 ` [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP Kang Kai
@ 2012-08-25 7:45 ` Richard Purdie
2012-08-27 2:06 ` Kang Kai
0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2012-08-25 7:45 UTC (permalink / raw)
To: Kang Kai; +Cc: bitbake-devel, Zhenfeng.Zhao
On Fri, 2012-08-24 at 17:15 +0800, Kang Kai wrote:
> Add variable IMAGE_TYPES_MAP to replace the hob2 hard-coded image types
> map.
>
> The format of IMAGE_TYPES_MAP is:
> "image_type1:realname_extend1 image_type2:realname_extend2,extend3 ..."
>
> Signed-off-by: Kang Kai <kai.kang@windriver.com>
> ---
> meta/conf/bitbake.conf | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index ad98756..7d2a9b9 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -770,3 +770,6 @@ BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc defaultval _append _prepend deps depends lock
>
> MLPREFIX ??= ""
> MULTILIB_VARIANTS ??= ""
> +
> +# Used by to Hob to filter image files
> +IMAGE_TYPES_MAP = "btrfs:btrfs cpio.gz:cpio.gz cpio.lzma:cpio.lzma cpio.xz:cpio.xz cpio:cpio cramfs:cramfs elf:elf ext2.bz2:ext2.bz2 ext2.gz:ext2.gz ext2.lzma:ext2.lzma ext2:ext2 ext3.gz:ext3.gz ext3:ext3 jffs2:jffs2 live:hddimg,iso squashfs-lzma:squashfs-lzma squashfs:squashfs sum.jffs2:sum.jffs2 tar.bz2:tar.bz2 tar.gz:tar.gz tar.xz:tar.xz tar:tar ubi:ubi vmdk:vmdk"
I think this still overcomplicates things. Firstly, can't we assume the
names map 1:1 with some exceptions.
For the exceptions, lets just add something like:
IMAGE_EXTENSION_live = "hddimg iso"
to image_types.bbclass (or image-live.bbclass)
and then the UI can query that variable name and assume a 1:1 mapping if
its not present.
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP
2012-08-25 7:45 ` Richard Purdie
@ 2012-08-27 2:06 ` Kang Kai
0 siblings, 0 replies; 6+ messages in thread
From: Kang Kai @ 2012-08-27 2:06 UTC (permalink / raw)
To: Richard Purdie; +Cc: bitbake-devel, Zhenfeng.Zhao
On 2012年08月25日 15:45, Richard Purdie wrote:
> On Fri, 2012-08-24 at 17:15 +0800, Kang Kai wrote:
>> Add variable IMAGE_TYPES_MAP to replace the hob2 hard-coded image types
>> map.
>>
>> The format of IMAGE_TYPES_MAP is:
>> "image_type1:realname_extend1 image_type2:realname_extend2,extend3 ..."
>>
>> Signed-off-by: Kang Kai<kai.kang@windriver.com>
>> ---
>> meta/conf/bitbake.conf | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
>> index ad98756..7d2a9b9 100644
>> --- a/meta/conf/bitbake.conf
>> +++ b/meta/conf/bitbake.conf
>> @@ -770,3 +770,6 @@ BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc defaultval _append _prepend deps depends lock
>>
>> MLPREFIX ??= ""
>> MULTILIB_VARIANTS ??= ""
>> +
>> +# Used by to Hob to filter image files
>> +IMAGE_TYPES_MAP = "btrfs:btrfs cpio.gz:cpio.gz cpio.lzma:cpio.lzma cpio.xz:cpio.xz cpio:cpio cramfs:cramfs elf:elf ext2.bz2:ext2.bz2 ext2.gz:ext2.gz ext2.lzma:ext2.lzma ext2:ext2 ext3.gz:ext3.gz ext3:ext3 jffs2:jffs2 live:hddimg,iso squashfs-lzma:squashfs-lzma squashfs:squashfs sum.jffs2:sum.jffs2 tar.bz2:tar.bz2 tar.gz:tar.gz tar.xz:tar.xz tar:tar ubi:ubi vmdk:vmdk"
Hi Richard,
> I think this still overcomplicates things. Firstly, can't we assume the
> names map 1:1 with some exceptions.
>
> For the exceptions, lets just add something like:
>
> IMAGE_EXTENSION_live = "hddimg iso"
>
> to image_types.bbclass (or image-live.bbclass)
>
> and then the UI can query that variable name and assume a 1:1 mapping if
> its not present.
Thanks a lot.
I'll update it.
Regards,
Kai
>
> Cheers,
>
> Richard
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread