aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/siggen.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-10-08 15:34:32 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-14 16:58:55 +0100
commite4d3077c5b0cc57964640512f3646c2d73c1d855 (patch)
treec31f40251492af6a4493334a39ac9011e92c373b /lib/bb/siggen.py
parent09b3e4e1e3fac737ea4069457e8bbffe1a4fe09d (diff)
downloadbitbake-e4d3077c5b0cc57964640512f3646c2d73c1d855.tar.gz
siggen: handle recipe path changes in siginfo files
Avoid storing paths to files in SRC_URI when writing out the the file checksums to siginfo files. This prevents a move of the source directory being reported by bitbake-diffsigs as files being removed and then added (the signature itself is not affected since the file paths have never been included in the signature). This has required the format of the file checksums in the siginfo file to be changed from a dict to a list of tuples (in order to handle multiple files with the same name under different paths, which is uncommon but possible); the code remains backwards-compatible with older siginfo files that use a dict however. Fixes [YOCTO #5245]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/siggen.py')
-rw-r--r--lib/bb/siggen.py41
1 files changed, 37 insertions, 4 deletions
diff --git a/lib/bb/siggen.py b/lib/bb/siggen.py
index c15ba28ea..52e698c46 100644
--- a/lib/bb/siggen.py
+++ b/lib/bb/siggen.py
@@ -224,7 +224,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
if runtime and k in self.taskhash:
data['runtaskdeps'] = self.runtaskdeps[k]
- data['file_checksum_values'] = self.file_checksum_values[k]
+ data['file_checksum_values'] = [(os.path.basename(f), cs) for f,cs in self.file_checksum_values[k].items()]
data['runtaskhashes'] = {}
for dep in data['runtaskdeps']:
data['runtaskhashes'][dep] = self.taskhash[dep]
@@ -322,6 +322,39 @@ def compare_sigfiles(a, b, recursecb = None):
removed = sb - sa
return changed, added, removed
+ def file_checksums_diff(a, b):
+ from collections import Counter
+ # Handle old siginfo format
+ if isinstance(a, dict):
+ a = [(os.path.basename(f), cs) for f, cs in a.items()]
+ if isinstance(b, dict):
+ b = [(os.path.basename(f), cs) for f, cs in b.items()]
+ # Compare lists, ensuring we can handle duplicate filenames if they exist
+ removedcount = Counter(a)
+ removedcount.subtract(b)
+ addedcount = Counter(b)
+ addedcount.subtract(a)
+ added = []
+ for x in b:
+ if addedcount[x] > 0:
+ addedcount[x] -= 1
+ added.append(x)
+ removed = []
+ changed = []
+ for x in a:
+ if removedcount[x] > 0:
+ removedcount[x] -= 1
+ for y in added:
+ if y[0] == x[0]:
+ changed.append((x[0], x[1], y[1]))
+ added.remove(y)
+ break
+ else:
+ removed.append(x)
+ added = [x[0] for x in added]
+ removed = [x[0] for x in removed]
+ return changed, added, removed
+
if 'basewhitelist' in a_data and a_data['basewhitelist'] != b_data['basewhitelist']:
output.append("basewhitelist changed from '%s' to '%s'" % (a_data['basewhitelist'], b_data['basewhitelist']))
if a_data['basewhitelist'] and b_data['basewhitelist']:
@@ -357,10 +390,10 @@ def compare_sigfiles(a, b, recursecb = None):
for dep in changed:
output.append("Variable %s value changed from '%s' to '%s'" % (dep, a_data['varvals'][dep], b_data['varvals'][dep]))
- changed, added, removed = dict_diff(a_data['file_checksum_values'], b_data['file_checksum_values'])
+ changed, added, removed = file_checksums_diff(a_data['file_checksum_values'], b_data['file_checksum_values'])
if changed:
- for f in changed:
- output.append("Checksum for file %s changed from %s to %s" % (f, a_data['file_checksum_values'][f], b_data['file_checksum_values'][f]))
+ for f, old, new in changed:
+ output.append("Checksum for file %s changed from %s to %s" % (f, old, new))
if added:
for f in added:
output.append("Dependency on checksum of file %s was added" % (f))