1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

bitbake: cooker/cookerdata: Rework the way the datastores are reset

As far as I could tell, the current code could result in some strange
situations where some data was set back to the original data store copy
but the multiconfig data was not restored. There are also some changes made
to the datastore which did not persist.

The data store was also being reset at every client reset, which seems
a little excessive if we can reset it to the original condition properly.

Move the __depends -> __base_depends rename into databuilder along with
the __bbclasstype change so these are saved in the original data.

Tweak the databuilder code to be clearer and easier to follow on which
copies are where, then save copies of all the mc datastores.

Finally, drop the cache invalidation upon reset for the base config
as we shouldn't need that now (oe-selftest -r tinfoil works with memory
resident bitbake which was the original reproducer requiring that change).

(Bitbake rev: 5f8b9b9c35b4ec0c8c539bf54ca85f068f4a5094)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2022-12-21 20:32:02 +00:00
parent cb8efd4d20
commit 4c5d6edb0b
2 changed files with 22 additions and 18 deletions
+3 -6
View File
@@ -400,9 +400,7 @@ class BBCooker:
self.disableDataTracking() self.disableDataTracking()
for mc in self.databuilder.mcdata.values(): for mc in self.databuilder.mcdata.values():
mc.renameVar("__depends", "__base_depends")
self.add_filewatch(mc.getVar("__base_depends", False), self.configwatcher) self.add_filewatch(mc.getVar("__base_depends", False), self.configwatcher)
mc.setVar("__bbclasstype", "recipe")
self.baseconfig_valid = True self.baseconfig_valid = True
self.parsecache_valid = False self.parsecache_valid = False
@@ -436,10 +434,8 @@ class BBCooker:
upstream=upstream, upstream=upstream,
) )
self.hashserv.serve_as_process() self.hashserv.serve_as_process()
self.data.setVar("BB_HASHSERVE", self.hashservaddr)
self.databuilder.origdata.setVar("BB_HASHSERVE", self.hashservaddr)
self.databuilder.data.setVar("BB_HASHSERVE", self.hashservaddr)
for mc in self.databuilder.mcdata: for mc in self.databuilder.mcdata:
self.databuilder.mcorigdata[mc].setVar("BB_HASHSERVE", self.hashservaddr)
self.databuilder.mcdata[mc].setVar("BB_HASHSERVE", self.hashservaddr) self.databuilder.mcdata[mc].setVar("BB_HASHSERVE", self.hashservaddr)
bb.parse.init_parser(self.data) bb.parse.init_parser(self.data)
@@ -1788,8 +1784,9 @@ class BBCooker:
if hasattr(self, "data"): if hasattr(self, "data"):
self.databuilder.reset() self.databuilder.reset()
self.data = self.databuilder.data self.data = self.databuilder.data
# In theory tinfoil could have modified the base data before parsing,
# ideally need to track if anything did modify the datastore
self.parsecache_valid = False self.parsecache_valid = False
self.baseconfig_valid = False
class CookerExit(bb.event.Event): class CookerExit(bb.event.Event):
+19 -12
View File
@@ -263,6 +263,7 @@ class CookerDataBuilder(object):
self.mcdata = {} self.mcdata = {}
def parseBaseConfiguration(self, worker=False): def parseBaseConfiguration(self, worker=False):
mcdata = {}
data_hash = hashlib.sha256() data_hash = hashlib.sha256()
try: try:
self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles) self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles)
@@ -288,18 +289,18 @@ class CookerDataBuilder(object):
bb.parse.init_parser(self.data) bb.parse.init_parser(self.data)
data_hash.update(self.data.get_hash().encode('utf-8')) data_hash.update(self.data.get_hash().encode('utf-8'))
self.mcdata[''] = self.data mcdata[''] = self.data
multiconfig = (self.data.getVar("BBMULTICONFIG") or "").split() multiconfig = (self.data.getVar("BBMULTICONFIG") or "").split()
for config in multiconfig: for config in multiconfig:
if config[0].isdigit(): if config[0].isdigit():
bb.fatal("Multiconfig name '%s' is invalid as multiconfigs cannot start with a digit" % config) bb.fatal("Multiconfig name '%s' is invalid as multiconfigs cannot start with a digit" % config)
mcdata = self.parseConfigurationFiles(self.prefiles, self.postfiles, config) parsed_mcdata = self.parseConfigurationFiles(self.prefiles, self.postfiles, config)
bb.event.fire(bb.event.ConfigParsed(), mcdata) bb.event.fire(bb.event.ConfigParsed(), parsed_mcdata)
self.mcdata[config] = mcdata mcdata[config] = parsed_mcdata
data_hash.update(mcdata.get_hash().encode('utf-8')) data_hash.update(parsed_mcdata.get_hash().encode('utf-8'))
if multiconfig: if multiconfig:
bb.event.fire(bb.event.MultiConfigParsed(self.mcdata), self.data) bb.event.fire(bb.event.MultiConfigParsed(mcdata), self.data)
self.data_hash = data_hash.hexdigest() self.data_hash = data_hash.hexdigest()
except (SyntaxError, bb.BBHandledException): except (SyntaxError, bb.BBHandledException):
@@ -332,17 +333,23 @@ class CookerDataBuilder(object):
if issues: if issues:
raise bb.BBHandledException() raise bb.BBHandledException()
for mc in mcdata:
mcdata[mc].renameVar("__depends", "__base_depends")
mcdata[mc].setVar("__bbclasstype", "recipe")
# Create a copy so we can reset at a later date when UIs disconnect # Create a copy so we can reset at a later date when UIs disconnect
self.origdata = self.data self.mcorigdata = mcdata
self.data = bb.data.createCopy(self.origdata) for mc in mcdata:
self.mcdata[''] = self.data self.mcdata[mc] = bb.data.createCopy(mcdata[mc])
self.data = self.mcdata['']
def reset(self): def reset(self):
# We may not have run parseBaseConfiguration() yet # We may not have run parseBaseConfiguration() yet
if not hasattr(self, 'origdata'): if not hasattr(self, 'mcorigdata'):
return return
self.data = bb.data.createCopy(self.origdata) for mc in self.mcorigdata:
self.mcdata[''] = self.data self.mcdata[mc] = bb.data.createCopy(self.mcorigdata[mc])
self.data = self.mcdata['']
def _findLayerConf(self, data): def _findLayerConf(self, data):
return findConfigFile("bblayers.conf", data) return findConfigFile("bblayers.conf", data)