hob2: remove hard-coded image types map
v2 cover hob2: remove hard-coded image types map
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(-)
Signature · 1 line
1.7.5.4
PATCH v2 1/3 hob2: remove the hard-coded images map
[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.
--- bitbake/lib/bb/ui/crumbs/builder.py | 22 +++++++++++++++++++--- bitbake/lib/bb/ui/crumbs/hig.py | 9 +++++++-- 2 files changed, 26 insertions(+), 5 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +19 -3
@@ -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) + self.logger.addHandler(self.consolelog)
bitbake/lib/bb/ui/crumbs/hig.py +7 -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, 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)
Signature · 1 line
1.7.5.4
PATCH v2 2/3 hob2: remove class hcc
In reply to Kang KaiBecause class hcc is useless, 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 v2 3/3 image_types.bbclass: add variable for Hob
In reply to Kang KaiAdd 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.
--- meta/classes/image_types.bbclass | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
meta/classes/image_types.bbclass +3 -0
@@ -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"
Signature · 1 line
1.7.5.4
Quoted 7 lines · Kang Kai
Hi Richard,
This is V2 for Yocto 2795.
Just add variable
IMAGE_EXTENSION_liveas 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
Quoted 24 lines
Regards,
KaiThe 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-contribkangkai/hob2
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/hob2Kang Kai (3):
hob2: remove the hard-coded images map
hob2: remove class hcc
image_types.bbclass: add variable for Hobbitbake/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(-)
Richard Purdie
AppliedQuoted 15 lines · Kang Kai
Hi Richard,
This is V2 for Yocto 2795.
Just add variable
IMAGE_EXTENSION_liveas you suggest, other image types are the same with the real image name extension names.Add update the hob code accordingly.
Regards,
KaiThe following changes since commit
b4c5725af4cd85d5644f0373e2674e903c4eab2b:yocto-bsp: add missing xserver-xf86-config .bbappend for qemu (2012-08-25 14:47:07 +0100)
Quoted 8 lines
are available in the git repository at:
git://git.pokylinux.org/poky-contribkangkai/hob2
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=kangkai/hob2Kang 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