"__depends/__base_depends" ordering and config hash improvement
Hi Richard,
This pull request contains commits that:
1) Retain order of "__depends" and "__base_depends".
2) Improve the config hash calculation.
Please help to review and pull.
Thanks,
Dongxiao
The following changes since commit 98694c1dbc276cc151f393db67bfd43442da28ba:
Hob: fixed a little view issue about package selection page (2012-04-16 12:56:15 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib dxu4/hob-bugfix
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=dxu4/hob-bugfix
Dongxiao Xu (2):
bitbake: Retain order for __depends and __base_depends
data_smart: Improve the calculation of config hash
lib/bb/cache.py | 6 ++++-- lib/bb/cooker.py | 6 ++++-- lib/bb/data_smart.py | 7 ++++--- lib/bb/parse/__init__.py | 12 ++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/2 bitbake: Retain order for __depends and __base_depends
Bitbake take seriously with variables order, therefore when setting values to __depends and __base_depends, we need to retain its order.
--- lib/bb/cache.py | 6 ++++-- lib/bb/cooker.py | 6 ++++-- lib/bb/parse/__init__.py | 12 ++++++++---- 3 files changed, 16 insertions(+), 8 deletions(-)
lib/bb/cache.py +4 -2
@@ -391,12 +391,14 @@ class Cache(object): """Parse the specified filename, returning the recipe information""" infos = [] datastores = cls.load_bbfile(filename, appends, configdata) - depends = set() + depends = [] for variant, data in sorted(datastores.iteritems(), key=lambda i: i[0], reverse=True): virtualfn = cls.realfn2virtual(filename, variant) - depends |= (data.getVar("__depends", False) or set()) + for dep in (data.getVar("__depends", False) or []): + if dep not in depends: + depends.append(dep) if depends and not variant: data.setVar("__depends", depends)
lib/bb/cooker.py +4 -2
@@ -680,8 +680,10 @@ class BBCooker: # Generate a list of parsed configuration files by searching the files # listed in the __depends and __base_depends variables with a .conf suffix. conffiles = [] - dep_files = self.configuration.data.getVar('__depends') or set() - dep_files.union(self.configuration.data.getVar('__base_depends') or set()) + dep_files = self.configuration.data.getVar('__depends') or [] + for dep in (self.configuration.data.getVar('__base_depends') or []): + if dep not in dep_files: + dep_files.append(dep) for f in dep_files: if f[0].endswith(".conf"):
lib/bb/parse/__init__.py +8 -4
@@ -73,8 +73,10 @@ def update_mtime(f): def mark_dependency(d, f): if f.startswith('./'): f = "%s/%s" % (os.getcwd(), f[2:]) - deps = d.getVar('__depends') or set() - deps.update([(f, cached_mtime(f))]) + deps = d.getVar('__depends') or [] + t = cached_mtime(f) + if (f, t) not in deps: + deps.append((f, t)) d.setVar('__depends', deps) def supports(fn, data):
@@ -134,8 +136,10 @@ def vars_from_file(mypkg, d): def get_file_depends(d): '''Return the dependent files''' dep_files = [] - depends = d.getVar('__depends', True) or set() - depends = depends.union(d.getVar('__base_depends', True) or set()) + depends = d.getVar('__depends', True) or [] + for dep in (d.getVar('__base_depends', True) or []): + if dep not in depends: + depends.append(dep) for (fn, _) in depends: dep_files.append(os.path.abspath(fn)) return " ".join(dep_files)
Signature · 1 line
1.7.4.1
PATCH 2/2 data_smart: Improve the calculation of config hash
In reply to Dongxiao XuFor 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.
--- lib/bb/data_smart.py | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
lib/bb/data_smart.py +4 -3
@@ -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()
Signature · 1 line
1.7.4.1