summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-15 14:41:57 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-08 22:01:19 +0000
commit267eca35c1ac1e59a780ff433ad32018e294cc0f (patch)
tree2003f5d106602d04dc4fb8e6548b719405cc8d76
parentbf411441f5368284ae6a6ac9707c689f48973083 (diff)
downloadpoky-267eca35c1ac1e59a780ff433ad32018e294cc0f.tar.gz
bitbake: fetch2/checksum/siggen: Fix taskhashes not tracking file directories
Currently if you have something like: SRC_URI = "file://foobar;subdir=${S}" and a file like: foobar/1/somefile and then move it to: foobar/2/somefile the task checksums don't reflect/notice this. The file-checksum fields encode two pieces of data, the file path and whether or not the file exists. Changing the code which uses these fields is problematic. We can however add a "/./" path element which means "include the bit after the marker in the checksum" which the path walking code can use to mark which bits of the path are visible to the fetcher. I'm not convinced this is great design but it does appear to work. (Bitbake rev: b4975d2ecf615ac4c240808fbc5a3f879a93846b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/checksum.py12
-rw-r--r--bitbake/lib/bb/siggen.py11
2 files changed, 21 insertions, 2 deletions
diff --git a/bitbake/lib/bb/checksum.py b/bitbake/lib/bb/checksum.py
index 1d50a26426..fb8a77f6ab 100644
--- a/bitbake/lib/bb/checksum.py
+++ b/bitbake/lib/bb/checksum.py
@@ -50,6 +50,7 @@ class FileChecksumCache(MultiProcessCache):
50 MultiProcessCache.__init__(self) 50 MultiProcessCache.__init__(self)
51 51
52 def get_checksum(self, f): 52 def get_checksum(self, f):
53 f = os.path.normpath(f)
53 entry = self.cachedata[0].get(f) 54 entry = self.cachedata[0].get(f)
54 cmtime = self.mtime_cache.cached_mtime(f) 55 cmtime = self.mtime_cache.cached_mtime(f)
55 if entry: 56 if entry:
@@ -84,15 +85,24 @@ class FileChecksumCache(MultiProcessCache):
84 return None 85 return None
85 return checksum 86 return checksum
86 87
88 #
89 # Changing the format of file-checksums is problematic as both OE and Bitbake have
90 # knowledge of them. We need to encode a new piece of data, the portion of the path
91 # we care about from a checksum perspective. This means that files that change subdirectory
92 # are tracked by the task hashes. To do this, we do something horrible and put a "/./" into
93 # the path. The filesystem handles it but it gives us a marker to know which subsection
94 # of the path to cache.
95 #
87 def checksum_dir(pth): 96 def checksum_dir(pth):
88 # Handle directories recursively 97 # Handle directories recursively
89 if pth == "/": 98 if pth == "/":
90 bb.fatal("Refusing to checksum /") 99 bb.fatal("Refusing to checksum /")
100 pth = pth.rstrip("/")
91 dirchecksums = [] 101 dirchecksums = []
92 for root, dirs, files in os.walk(pth, topdown=True): 102 for root, dirs, files in os.walk(pth, topdown=True):
93 [dirs.remove(d) for d in list(dirs) if d in localdirsexclude] 103 [dirs.remove(d) for d in list(dirs) if d in localdirsexclude]
94 for name in files: 104 for name in files:
95 fullpth = os.path.join(root, name) 105 fullpth = os.path.join(root, name).replace(pth, os.path.join(pth, "."))
96 checksum = checksum_file(fullpth) 106 checksum = checksum_file(fullpth)
97 if checksum: 107 if checksum:
98 dirchecksums.append((fullpth, checksum)) 108 dirchecksums.append((fullpth, checksum))
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index 578ba5d661..44965c8cca 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -328,6 +328,8 @@ class SignatureGeneratorBasic(SignatureGenerator):
328 328
329 for (f, cs) in self.file_checksum_values[tid]: 329 for (f, cs) in self.file_checksum_values[tid]:
330 if cs: 330 if cs:
331 if "/./" in f:
332 data = data + "./" + f.split("/./")[1]
331 data = data + cs 333 data = data + cs
332 334
333 if tid in self.taints: 335 if tid in self.taints:
@@ -385,7 +387,12 @@ class SignatureGeneratorBasic(SignatureGenerator):
385 387
386 if runtime and tid in self.taskhash: 388 if runtime and tid in self.taskhash:
387 data['runtaskdeps'] = self.runtaskdeps[tid] 389 data['runtaskdeps'] = self.runtaskdeps[tid]
388 data['file_checksum_values'] = [(os.path.basename(f), cs) for f,cs in self.file_checksum_values[tid]] 390 data['file_checksum_values'] = []
391 for f,cs in self.file_checksum_values[tid]:
392 if "/./" in f:
393 data['file_checksum_values'].append(("./" + f.split("/./")[1], cs))
394 else:
395 data['file_checksum_values'].append((os.path.basename(f), cs))
389 data['runtaskhashes'] = {} 396 data['runtaskhashes'] = {}
390 for dep in data['runtaskdeps']: 397 for dep in data['runtaskdeps']:
391 data['runtaskhashes'][dep] = self.get_unihash(dep) 398 data['runtaskhashes'][dep] = self.get_unihash(dep)
@@ -1028,6 +1035,8 @@ def calc_taskhash(sigdata):
1028 1035
1029 for c in sigdata['file_checksum_values']: 1036 for c in sigdata['file_checksum_values']:
1030 if c[1]: 1037 if c[1]:
1038 if "./" in c[0]:
1039 data = data + c[0]
1031 data = data + c[1] 1040 data = data + c[1]
1032 1041
1033 if 'taint' in sigdata: 1042 if 'taint' in sigdata: