From patchwork Mon Apr 9 08:41:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel, 2/6] data_smart: Improve the calculation of config hash Date: Mon, 09 Apr 2012 08:41:58 -0000 From: Dongxiao Xu X-Patchwork-Id: 25357 Message-Id: To: bitbake-devel@lists.openembedded.org The order of keys are not sensitive for config hash, so we need to identify its order while calculating the md5 value. While for certain values, order is also not sensitive (for example, BBINCLUDED), we also need to identify its order while calculating md5 value. This could fix the problem that Martin Jansa reported in the mailing list: http://lists.linuxtogo.org/pipermail/bitbake-devel/2012-March/002122.html Signed-off-by: Dongxiao Xu --- lib/bb/data_smart.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index 2c200db..cc61a03 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -462,13 +462,17 @@ class DataSmart(MutableMapping): self.delVar(var) def get_hash(self): - data = "" + data = {} config_whitelist = set((self.getVar("BB_HASHCONFIG_WHITELIST", True) or "").split()) + config_sort = set((self.getVar("BB_HASHCONFIG_SORT", 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' + if key in config_sort: + value = " ".join(sorted(value.split())) + 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()