hob2: remove hard-coded image types map
cover hob2: remove hard-coded image types map
Hi Richard,
This is for Yocto 2795.
Read from a new variable IMAGE_TYPES_MAP to get the map. Add the IMAGE_TYPES_MAP to bitbake.conf. The format of IMAGE_TYPES_MAP is:
"image_type1:realname_extend1 image_type2:realname_extend2,extend3 ..."
Regards,
Kai
The following changes since commit 054d95edad8d79ef1c6b30681395d50f3c6335b4:
poky.conf: restore Ubuntu 12.04 LTS to tested distro list (2012-08-23 17:23:40 +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
bitbake.conf: add variable IMAGE_TYPES_MAP
bitbake/lib/bb/ui/crumbs/builder.py | 35 +++++++++++++++++++++++--- bitbake/lib/bb/ui/crumbs/hig.py | 9 ++++-- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 4 ++- bitbake/lib/bb/ui/crumbs/hobwidget.py | 29 ---------------------- meta/conf/bitbake.conf | 3 ++ 5 files changed, 43 insertions(+), 37 deletions(-)
Signature · 1 line
1.7.5.4
PATCH 1/3 hob2: remove the hard-coded images map
[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.
--- 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(-)
bitbake/lib/bb/ui/crumbs/builder.py +30 -3
@@ -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) + self.logger.addHandler(self.consolelog)
bitbake/lib/bb/ui/crumbs/hig.py +5 -2
@@ -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)
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +3 -0
@@ -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():
Signature · 1 line
1.7.5.4
PATCH 2/3 hob2: remove class hcc
In reply to Kang KaiBecause class hcc is useless, so remove it.
--- 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(-)
bitbake/lib/bb/ui/crumbs/builder.py +1 -1
@@ -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
bitbake/lib/bb/ui/crumbs/hig.py +1 -1
@@ -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
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +0 -1
@@ -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):
bitbake/lib/bb/ui/crumbs/hobwidget.py +0 -29
@@ -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
Signature · 1 line
1.7.5.4
PATCH 3/3 bitbake.conf: add variable IMAGE_TYPES_MAP
In reply to Kang KaiAdd 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 ..."
--- meta/conf/bitbake.conf | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
meta/conf/bitbake.conf +3 -0
@@ -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"
Signature · 1 line
1.7.5.4
Re: [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP
Quoted 16 lines · Kang Kai
Add variable
IMAGE_TYPES_MAPto replace the hob2 hard-coded image types map.The format of
IMAGE_TYPES_MAPis:
"image_type1:realname_extend1 image_type2:realname_extend2,extend3 ..."Signed-off-by Kang Kai <[email protected]>--- meta/conf/bitbake.conf | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)meta/conf/bitbake.conf +0
-0
meta/conf/bitbake.conf BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc defaultval _append _prepend deps depends lock · line 775
Quoted 6 lines
meta/conf/bitbake.conf +3
-0@@ -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
Re: [PATCH 3/3] bitbake.conf: add variable IMAGE_TYPES_MAP
Quoted 18 lines · Richard Purdie
Quoted 17 lines · Kang Kai
Add variable
IMAGE_TYPES_MAPto replace the hob2 hard-coded image types map.The format of
IMAGE_TYPES_MAPis:
"image_type1:realname_extend1 image_type2:realname_extend2,extend3 ..."Signed-off-by Kang Kai<[email protected]>--- meta/conf/bitbake.conf | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)meta/conf/bitbake.conf +0
-0@@ -770,3 +770,6 @@ BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc defaultval _append _prepend deps depends lock
Quoted 5 lines
meta/conf/bitbake.conf BB_SIGNATURE_EXCLUDE_FLAGS ?= "doc defaultval _append _prepend deps depends lock · line 775
Quoted 5 lines
meta/conf/bitbake.conf +3
-0MLPREFIX ??= "" 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,
Quoted 11 lines
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
Quoted 6 lines
Cheers,
Richard