diff options
author | Kang Kai <kai.kang@windriver.com> | 2012-08-28 10:47:19 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-09-07 12:10:40 +0100 |
commit | da98eddd02118f4330d05a1262617ba84029a13a (patch) | |
tree | 4b83207a134eb375acd2ba126148ab1853bb0439 /bitbake/lib | |
parent | 15abf2571ceca8634580538b8635487dbc7c0dd5 (diff) | |
download | poky-da98eddd02118f4330d05a1262617ba84029a13a.tar.gz |
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>
Diffstat (limited to 'bitbake/lib')
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/builder.py | 22 | ||||
-rw-r--r-- | 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 7de47986bb..5421fb6d12 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): | |||
893 | linkname = 'hob-image-' + self.configuration.curr_mach | 893 | linkname = 'hob-image-' + self.configuration.curr_mach |
894 | else: | 894 | else: |
895 | linkname = selected_image + '-' + self.configuration.curr_mach | 895 | linkname = selected_image + '-' + self.configuration.curr_mach |
896 | image_extension = self.get_image_extension() | ||
896 | for image_type in self.parameters.image_types: | 897 | for image_type in self.parameters.image_types: |
897 | for real_image_type in hcc.SUPPORTED_IMAGE_TYPES[image_type]: | 898 | if image_type in image_extension: |
899 | real_types = image_extension[image_type] | ||
900 | else: | ||
901 | real_types = [image_type] | ||
902 | for real_image_type in real_types: | ||
898 | linkpath = self.parameters.image_addr + '/' + linkname + '.' + real_image_type | 903 | linkpath = self.parameters.image_addr + '/' + linkname + '.' + real_image_type |
899 | if os.path.exists(linkpath): | 904 | if os.path.exists(linkpath): |
900 | self.parameters.image_names.append(os.readlink(linkpath)) | 905 | self.parameters.image_names.append(os.readlink(linkpath)) |
@@ -1114,10 +1119,21 @@ class Builder(gtk.Window): | |||
1114 | self.save_template(path) | 1119 | self.save_template(path) |
1115 | dialog.destroy() | 1120 | dialog.destroy() |
1116 | 1121 | ||
1122 | def get_image_extension(self): | ||
1123 | image_extension = {} | ||
1124 | for type in self.parameters.image_types: | ||
1125 | ext = self.handler.runCommand(["getVariable", "IMAGE_EXTENSION_%s" % type]) | ||
1126 | if ext: | ||
1127 | image_extension[type] = ext.split(' ') | ||
1128 | |||
1129 | return image_extension | ||
1130 | |||
1117 | def show_load_my_images_dialog(self): | 1131 | def show_load_my_images_dialog(self): |
1132 | image_extension = self.get_image_extension() | ||
1118 | dialog = ImageSelectionDialog(self.parameters.image_addr, self.parameters.image_types, | 1133 | dialog = ImageSelectionDialog(self.parameters.image_addr, self.parameters.image_types, |
1119 | "Open My Images", self, | 1134 | "Open My Images", self, |
1120 | gtk.FILE_CHOOSER_ACTION_SAVE) | 1135 | gtk.FILE_CHOOSER_ACTION_SAVE, None, |
1136 | image_extension) | ||
1121 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) | 1137 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) |
1122 | HobAltButton.style_button(button) | 1138 | HobAltButton.style_button(button) |
1123 | button = dialog.add_button("Open", gtk.RESPONSE_YES) | 1139 | button = dialog.add_button("Open", gtk.RESPONSE_YES) |
@@ -1334,4 +1350,4 @@ class Builder(gtk.Window): | |||
1334 | format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") | 1350 | format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") |
1335 | self.consolelog.setFormatter(format) | 1351 | self.consolelog.setFormatter(format) |
1336 | 1352 | ||
1337 | self.logger.addHandler(self.consolelog) \ No newline at end of file | 1353 | self.logger.addHandler(self.consolelog) |
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 2001ff424f..6829927e1a 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py | |||
@@ -1172,7 +1172,7 @@ class ImageSelectionDialog (CrumbsDialog): | |||
1172 | }] | 1172 | }] |
1173 | 1173 | ||
1174 | 1174 | ||
1175 | def __init__(self, image_folder, image_types, title, parent, flags, buttons=None): | 1175 | def __init__(self, image_folder, image_types, title, parent, flags, buttons=None, image_extension = {}): |
1176 | super(ImageSelectionDialog, self).__init__(title, parent, flags, buttons) | 1176 | super(ImageSelectionDialog, self).__init__(title, parent, flags, buttons) |
1177 | self.connect("response", self.response_cb) | 1177 | self.connect("response", self.response_cb) |
1178 | 1178 | ||
@@ -1180,6 +1180,7 @@ class ImageSelectionDialog (CrumbsDialog): | |||
1180 | self.image_types = image_types | 1180 | self.image_types = image_types |
1181 | self.image_list = [] | 1181 | self.image_list = [] |
1182 | self.image_names = [] | 1182 | self.image_names = [] |
1183 | self.image_extension = image_extension | ||
1183 | 1184 | ||
1184 | # create visual elements on the dialog | 1185 | # create visual elements on the dialog |
1185 | self.create_visual_elements() | 1186 | self.create_visual_elements() |
@@ -1265,7 +1266,11 @@ class ImageSelectionDialog (CrumbsDialog): | |||
1265 | dirs[:] = [] | 1266 | dirs[:] = [] |
1266 | for f in files: | 1267 | for f in files: |
1267 | for image_type in self.image_types: | 1268 | for image_type in self.image_types: |
1268 | for real_image_type in hcc.SUPPORTED_IMAGE_TYPES[image_type]: | 1269 | if image_type in self.image_extension: |
1270 | real_types = self.image_extension[image_type] | ||
1271 | else: | ||
1272 | real_types = [image_type] | ||
1273 | for real_image_type in real_types: | ||
1269 | if f.endswith('.' + real_image_type): | 1274 | if f.endswith('.' + real_image_type): |
1270 | imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0]) | 1275 | imageset.add(f.rsplit('.' + real_image_type)[0].rsplit('.rootfs')[0]) |
1271 | self.image_list.append(f) | 1276 | self.image_list.append(f) |