From patchwork Mon Apr 16 13:17:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel, 2/2] data_smart: Improve the calculation of config hash Date: Mon, 16 Apr 2012 13:17:19 -0000 From: Dongxiao Xu X-Patchwork-Id: 25931 Message-Id: <3880b5f056e6a522fee8a7589fb20d4c0da36c91.1334582048.git.dongxiao.xu@intel.com> To: bitbake-devel@lists.openembedded.org For config hash, we put the keys in structure of "set()", which is not order sensitive. Therefore when calculating the md5 value for config hash, we need to identify the order of the keys. Signed-off-by: Dongxiao Xu --- lib/bb/data_smart.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index 2c200db..27fb7d9 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -462,13 +462,14 @@ class DataSmart(MutableMapping): self.delVar(var) def get_hash(self): - data = "" + data = {} config_whitelist = set((self.getVar("BB_HASHCONFIG_WHITELIST", True) or "").split()) keys = set(key for key in iter(self) if not key.startswith("__")) for key in keys: if key in config_whitelist: continue value = self.getVar(key, False) or "" - data = data + key + ': ' + str(value) + '\n' + data.update({key:value}) - return hashlib.md5(data).hexdigest() + data_str = str([(k, data[k]) for k in sorted(data.keys())]) + return hashlib.md5(data_str).hexdigest()