summaryrefslogtreecommitdiffstats
path: root/meta/classes/sstate.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-03-18 17:57:45 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-03-23 22:51:25 +0000
commit75c2c03416a7e3864fb18b31690815ab249e117b (patch)
treeea8a4b1d39380e1143c8a0a2cd7ffa378669b027 /meta/classes/sstate.bbclass
parent5372c7b54eca19476435fba18c82c48a9ffc8a74 (diff)
downloadpoky-75c2c03416a7e3864fb18b31690815ab249e117b.tar.gz
sstate: Remove stale objects before the main build
The split of util-linux-uuid out from util-linux caused some interesting sstate file overlap errors on existing build directories. This is a challenge to handle since util-linux depends on util-linux-uuid and has overlapping files in package data and deploy/packages directories. The util-linux build happens later and is what would clean up those files but it happens too late for uuid. Fixing this is hard as we don't know the taskhashes until the task graph is calculated. Once that is ready, we can compare the hashes with the existing hashes and know which sstate tasks are "stale". This patch adds a handler which iterates the sstate manifests looking for matching stamp paths and then removes the manifests along with the associated stamp files. (From OE-Core rev: 60e77b1777c6c304aa1d629c4cfdabe0daa22eb1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sstate.bbclass')
-rw-r--r--meta/classes/sstate.bbclass45
1 files changed, 45 insertions, 0 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index f579168162..1fa8a63d17 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -1223,3 +1223,48 @@ python sstate_eventhandler2() {
1223 if preservestamps: 1223 if preservestamps:
1224 os.remove(preservestampfile) 1224 os.remove(preservestampfile)
1225} 1225}
1226
1227addhandler sstate_eventhandler_stalesstate
1228sstate_eventhandler_stalesstate[eventmask] = "bb.event.StaleSetSceneTasks"
1229python sstate_eventhandler_stalesstate() {
1230 d = e.data
1231 tasks = e.tasks
1232
1233 bb.utils.mkdirhier(d.expand("${SSTATE_MANIFESTS}"))
1234
1235 for a in list(set(d.getVar("SSTATE_ARCHS").split())):
1236 toremove = []
1237 i = d.expand("${SSTATE_MANIFESTS}/index-" + a)
1238 if not os.path.exists(i):
1239 continue
1240 with open(i, "r") as f:
1241 lines = f.readlines()
1242 for l in lines:
1243 try:
1244 (stamp, manifest, workdir) = l.split()
1245 for tid in tasks:
1246 for s in tasks[tid]:
1247 if s.startswith(stamp):
1248 taskname = bb.runqueue.taskname_from_tid(tid)[3:]
1249 manname = manifest + "." + taskname
1250 if os.path.exists(manname):
1251 bb.debug(2, "Sstate for %s is stale, removing related manifest %s" % (tid, manname))
1252 toremove.append((manname, tid, tasks[tid]))
1253 break
1254 except ValueError:
1255 bb.fatal("Invalid line '%s' in sstate manifest '%s'" % (l, i))
1256
1257 if toremove:
1258 msg = "Removing %d stale sstate objects for arch %s" % (len(toremove), a)
1259 bb.event.fire(bb.event.ProcessStarted(msg, len(toremove)), d)
1260
1261 removed = 0
1262 for (manname, tid, stamps) in toremove:
1263 sstate_clean_manifest(manname, d)
1264 for stamp in stamps:
1265 bb.utils.remove(stamp)
1266 removed = removed + 1
1267 bb.event.fire(bb.event.ProcessProgress(msg, removed), d)
1268
1269 bb.event.fire(bb.event.ProcessFinished(msg), d)
1270}