bitbake: 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 rev: e7c84f056af9c613920d5adcd078a011e0387193) Signed-off-by: Kang Kai <kai.kang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
15abf2571c
commit
da98eddd02
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue