summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-14 18:06:56 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-22 10:03:10 +0100
commit1170b40cd23978aac9d8e73ee6e30e8ee77e2a50 (patch)
tree2c52bb9843e5c3a8412c20903781ee6361906a4d
parent8bdf443bbbc3eed79b5cd9bd547100825c9050ae (diff)
downloadpoky-1170b40cd23978aac9d8e73ee6e30e8ee77e2a50.tar.gz
sstate: Handle manifest 'corruption' issue
Under certain build patterns, warnings about missing manifests can appear. These are real issues where the manifest was removed and shouldn't have been. Martin Jansa was able to find a reproducer of: MACHINE=qemux86 bitbake zlib-native echo 'PR = "r1"' >> meta/recipes-core/zlib/zlib_1.2.11.bb MACHINE=qemux86-64 bitbake zlib-native MACHINE=qemux86 bitbake zlib-native <the zlib-native manifest is now removed along with the sysroot-components contents> The code maintains a per machine list of stamps but a per PACAGE_ARCH list of stamp/manifest/workdir mappings. The latter is only appended to for speed with the assumption that once stamps are gone, the code wouldn't trigger. The code only ever appends to the mapping list (for speed/efficency under lock) meaning that multiple entries can result where the stamp/workdir differs due to version changes but the manifest remains the same. By switching MACHINE part way through the build, the older stamp is referenced and the manifest is incorrectly removed as it matches an now obsolete entry in the mapping file. There are two possible fixes, one is to rewrite the mapping file every time which means adding regexs, iterating and generally complicating that code. The second option is to only use the last mapping entry in the file for a given manifest and ignore any earlier ones. This patch implments the latter. Also drop the stale entries if we are rewriting it. (From OE-Core rev: fe468802f697d0be41cf3407df2460e1473e35f8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/sstate.bbclass16
1 files changed, 15 insertions, 1 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 8e8efd18d5..79588df2cd 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -319,6 +319,8 @@ def sstate_install(ss, d):
319 if os.path.exists(i): 319 if os.path.exists(i):
320 with open(i, "r") as f: 320 with open(i, "r") as f:
321 manifests = f.readlines() 321 manifests = f.readlines()
322 # We append new entries, we don't remove older entries which may have the same
323 # manifest name but different versions from stamp/workdir. See below.
322 if filedata not in manifests: 324 if filedata not in manifests:
323 with open(i, "a+") as f: 325 with open(i, "a+") as f:
324 f.write(filedata) 326 f.write(filedata)
@@ -1183,11 +1185,21 @@ python sstate_eventhandler_reachablestamps() {
1183 i = d.expand("${SSTATE_MANIFESTS}/index-" + a) 1185 i = d.expand("${SSTATE_MANIFESTS}/index-" + a)
1184 if not os.path.exists(i): 1186 if not os.path.exists(i):
1185 continue 1187 continue
1188 manseen = set()
1189 ignore = []
1186 with open(i, "r") as f: 1190 with open(i, "r") as f:
1187 lines = f.readlines() 1191 lines = f.readlines()
1188 for l in lines: 1192 for l in reversed(lines):
1189 try: 1193 try:
1190 (stamp, manifest, workdir) = l.split() 1194 (stamp, manifest, workdir) = l.split()
1195 # The index may have multiple entries for the same manifest as the code above only appends
1196 # new entries and there may be an entry with matching manifest but differing version in stamp/workdir.
1197 # The last entry in the list is the valid one, any earlier entries with matching manifests
1198 # should be ignored.
1199 if manifest in manseen:
1200 ignore.append(l)
1201 continue
1202 manseen.add(manifest)
1191 if stamp not in stamps and stamp not in preservestamps and stamp in machineindex: 1203 if stamp not in stamps and stamp not in preservestamps and stamp in machineindex:
1192 toremove.append(l) 1204 toremove.append(l)
1193 if stamp not in seen: 1205 if stamp not in seen:
@@ -1218,6 +1230,8 @@ python sstate_eventhandler_reachablestamps() {
1218 1230
1219 with open(i, "w") as f: 1231 with open(i, "w") as f:
1220 for l in lines: 1232 for l in lines:
1233 if l in ignore:
1234 continue
1221 f.write(l) 1235 f.write(l)
1222 machineindex |= set(stamps) 1236 machineindex |= set(stamps)
1223 with open(mi, "w") as f: 1237 with open(mi, "w") as f: