From 1c3ff8623f03a4995fc07fb9fa4a914e02b3b048 Mon Sep 17 00:00:00 2001 From: Dongxiao Xu Date: Thu, 29 Mar 2012 20:01:19 +0800 Subject: Hob: Fix the setting hash calculation Sometimes even setting are not changed, the hash values differs due to variable order issue. This commit fixes the issue. (Bitbake rev: 1fe0996f89952af72cbdc46ca7c6495868d27a56) Signed-off-by: Dongxiao Xu Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hig.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index a21c6106a4..9adb28117a 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py @@ -337,19 +337,30 @@ class AdvancedSettingDialog (CrumbsDialog): self.setting_store = None self.image_types_checkbuttons = {} - self.variables = {} - self.variables["PACKAGE_FORMAT"] = self.configuration.curr_package_format - self.variables["INCOMPATIBLE_LICENSE"] = self.configuration.incompat_license - self.variables["IMAGE_FSTYPES"] = self.configuration.image_fstypes - for key in self.configuration.extra_setting.keys(): - self.variables[key] = self.configuration.extra_setting[key] - self.md5 = hashlib.md5(str(sorted(self.variables.items()))).hexdigest() + self.md5 = self.config_md5() self.settings_changed = False # create visual elements on the dialog self.create_visual_elements() self.connect("response", self.response_cb) + def _get_sorted_value(self, var): + return " ".join(sorted(str(var).split())) + "\n" + + def config_md5(self): + data = "" + data += ("PACKAGE_CLASSES: " + self.configuration.curr_package_format + '\n') + data += ("DISTRO: " + self._get_sorted_value(self.configuration.curr_distro)) + data += ("IMAGE_ROOTFS_SIZE: " + self._get_sorted_value(self.configuration.image_rootfs_size)) + data += ("IMAGE_EXTRA_SIZE: " + self._get_sorted_value(self.configuration.image_extra_size)) + data += ("INCOMPATIBLE_LICENSE: " + self._get_sorted_value(self.configuration.incompat_license)) + data += ("SDK_MACHINE: " + self._get_sorted_value(self.configuration.curr_sdk_machine)) + data += ("TOOLCHAIN_BUILD: " + self._get_sorted_value(self.configuration.toolchain_build)) + data += ("IMAGE_FSTYPES: " + self._get_sorted_value(self.configuration.image_fstypes)) + for key in self.configuration.extra_setting.keys(): + data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) + return hashlib.md5(data).hexdigest() + def create_visual_elements(self): self.nb = gtk.Notebook() self.nb.set_show_tabs(True) @@ -589,15 +600,12 @@ class AdvancedSettingDialog (CrumbsDialog): self.cvs_proxy_text.set_sensitive(self.enable_proxy) def response_cb(self, dialog, response_id): - self.variables = {} - package_format = [] package_format.append(self.rootfs_combo.get_active_text()) for child in self.check_hbox: if isinstance(child, gtk.CheckButton) and child.get_active(): package_format.append(child.get_label()) self.configuration.curr_package_format = " ".join(package_format) - self.variables["PACKAGE_FORMAT"] = self.configuration.curr_package_format self.configuration.curr_distro = self.distro_combo.get_active_text() self.configuration.dldir = self.dldir_text.get_text() @@ -613,7 +621,6 @@ class AdvancedSettingDialog (CrumbsDialog): if self.image_types_checkbuttons[image_type].get_active(): self.configuration.image_fstypes += (" " + image_type) self.configuration.image_fstypes.strip() - self.variables["IMAGE_FSTYPES"] = self.configuration.image_fstypes if self.gplv3_checkbox.get_active(): if "GPLv3" not in self.configuration.incompat_license.split(): @@ -623,7 +630,6 @@ class AdvancedSettingDialog (CrumbsDialog): self.configuration.incompat_license = self.configuration.incompat_license.split().remove("GPLv3") self.configuration.incompat_license = " ".join(self.configuration.incompat_license or []) self.configuration.incompat_license = self.configuration.incompat_license.strip() - self.variables["INCOMPATIBLE_LICENSE"] = self.configuration.incompat_license self.configuration.toolchain_build = self.toolchain_checkbox.get_active() @@ -633,7 +639,6 @@ class AdvancedSettingDialog (CrumbsDialog): key = self.setting_store.get_value(it, 0) value = self.setting_store.get_value(it, 1) self.configuration.extra_setting[key] = value - self.variables[key] = value it = self.setting_store.iter_next(it) self.configuration.all_proxy = self.all_proxy_text.get_text() @@ -643,7 +648,7 @@ class AdvancedSettingDialog (CrumbsDialog): self.configuration.git_proxy_host, self.configuration.git_proxy_port = self.git_proxy_text.get_text().split(':') self.configuration.cvs_proxy_host, self.configuration.cvs_proxy_port = self.cvs_proxy_text.get_text().split(':') - md5 = hashlib.md5(str(sorted(self.variables.items()))).hexdigest() + md5 = self.config_md5() self.settings_changed = (self.md5 != md5) # -- cgit v1.2.3-54-g00ecf