From bcf935cd1bd7b0ed0b636fd8b984cd7dab3ebd3e Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 1 Jun 2022 19:14:41 +0100 Subject: bitbake: cache/siggen: Add unihash cache copy function We see rare failures in eSDK generation with zero sized unihash cache files. This is almost certainly due to races in the cache file being updated. Add a copy function where the cache file can be copied with the lock held to avoid this. (Bitbake rev: 9e72a3915e36cb843037040cb68a82077436dbef) Signed-off-by: Richard Purdie --- bitbake/lib/bb/cache.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'bitbake/lib/bb/cache.py') diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index 92e9a3ced7..988c596c39 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py @@ -24,6 +24,7 @@ from collections.abc import Mapping import bb.utils from bb import PrefixLoggerAdapter import re +import shutil logger = logging.getLogger("BitBake.Cache") @@ -998,3 +999,11 @@ class SimpleCache(object): p.dump([data, self.cacheversion]) bb.utils.unlockfile(glf) + + def copyfile(self, target): + if not self.cachefile: + return + + glf = bb.utils.lockfile(self.cachefile + ".lock") + shutil.copy(self.cachefile, target) + bb.utils.unlockfile(glf) -- cgit v1.2.3-54-g00ecf