summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-20 14:19:29 -1000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-22 12:11:06 +0100
commite7a5814b4b74d60a21480f7f386a38d3080f1fc2 (patch)
tree267272c60f7ad64d6ac0f5e040db8e4014021422
parentbf94fcbeef4642bdc323b10e7a0ddb18f74d9c88 (diff)
downloadpoky-e7a5814b4b74d60a21480f7f386a38d3080f1fc2.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: 9039dd25e5d419dd1c60e1b27ff5f9d96c5b0fb5) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 63da9a4f889c5b0e41bc8ec08abe0acea1546479) Signed-off-by: Steve Sakoman <steve@sakoman.com> 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 a8e169a10b..3c89c35ecf 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)
@@ -1175,11 +1177,21 @@ python sstate_eventhandler2() {
1175 i = d.expand("${SSTATE_MANIFESTS}/index-" + a) 1177 i = d.expand("${SSTATE_MANIFESTS}/index-" + a)
1176 if not os.path.exists(i): 1178 if not os.path.exists(i):
1177 continue 1179 continue
1180 manseen = set()
1181 ignore = []
1178 with open(i, "r") as f: 1182 with open(i, "r") as f:
1179 lines = f.readlines() 1183 lines = f.readlines()
1180 for l in lines: 1184 for l in reversed(lines):
1181 try: 1185 try:
1182 (stamp, manifest, workdir) = l.split() 1186 (stamp, manifest, workdir) = l.split()
1187 # The index may have multiple entries for the same manifest as the code above only appends
1188 # new entries and there may be an entry with matching manifest but differing version in stamp/workdir.
1189 # The last entry in the list is the valid one, any earlier entries with matching manifests
1190 # should be ignored.
1191 if manifest in manseen:
1192 ignore.append(l)
1193 continue
1194 manseen.add(manifest)
1183 if stamp not in stamps and stamp not in preservestamps and stamp in machineindex: 1195 if stamp not in stamps and stamp not in preservestamps and stamp in machineindex:
1184 toremove.append(l) 1196 toremove.append(l)
1185 if stamp not in seen: 1197 if stamp not in seen:
@@ -1210,6 +1222,8 @@ python sstate_eventhandler2() {
1210 1222
1211 with open(i, "w") as f: 1223 with open(i, "w") as f:
1212 for l in lines: 1224 for l in lines:
1225 if l in ignore:
1226 continue
1213 f.write(l) 1227 f.write(l)
1214 machineindex |= set(stamps) 1228 machineindex |= set(stamps)
1215 with open(mi, "w") as f: 1229 with open(mi, "w") as f: