summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-21 20:32:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-31 17:05:17 +0000
commit4c5d6edb0b78ea7621d5196e9fcb5585c8fa04a4 (patch)
tree4c80abeb8ad023f48ec70ac134bb735a735ab916 /bitbake
parentcb8efd4d20d7643632b04ce8350c1b58aed49122 (diff)
downloadpoky-4c5d6edb0b78ea7621d5196e9fcb5585c8fa04a4.tar.gz
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>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cooker.py9
-rw-r--r--bitbake/lib/bb/cookerdata.py31
2 files changed, 22 insertions, 18 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index c712744382..7e0d6b47bf 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -400,9 +400,7 @@ class BBCooker:
400 self.disableDataTracking() 400 self.disableDataTracking()
401 401
402 for mc in self.databuilder.mcdata.values(): 402 for mc in self.databuilder.mcdata.values():
403 mc.renameVar("__depends", "__base_depends")
404 self.add_filewatch(mc.getVar("__base_depends", False), self.configwatcher) 403 self.add_filewatch(mc.getVar("__base_depends", False), self.configwatcher)
405 mc.setVar("__bbclasstype", "recipe")
406 404
407 self.baseconfig_valid = True 405 self.baseconfig_valid = True
408 self.parsecache_valid = False 406 self.parsecache_valid = False
@@ -436,10 +434,8 @@ class BBCooker:
436 upstream=upstream, 434 upstream=upstream,
437 ) 435 )
438 self.hashserv.serve_as_process() 436 self.hashserv.serve_as_process()
439 self.data.setVar("BB_HASHSERVE", self.hashservaddr)
440 self.databuilder.origdata.setVar("BB_HASHSERVE", self.hashservaddr)
441 self.databuilder.data.setVar("BB_HASHSERVE", self.hashservaddr)
442 for mc in self.databuilder.mcdata: 437 for mc in self.databuilder.mcdata:
438 self.databuilder.mcorigdata[mc].setVar("BB_HASHSERVE", self.hashservaddr)
443 self.databuilder.mcdata[mc].setVar("BB_HASHSERVE", self.hashservaddr) 439 self.databuilder.mcdata[mc].setVar("BB_HASHSERVE", self.hashservaddr)
444 440
445 bb.parse.init_parser(self.data) 441 bb.parse.init_parser(self.data)
@@ -1788,8 +1784,9 @@ class BBCooker:
1788 if hasattr(self, "data"): 1784 if hasattr(self, "data"):
1789 self.databuilder.reset() 1785 self.databuilder.reset()
1790 self.data = self.databuilder.data 1786 self.data = self.databuilder.data
1787 # In theory tinfoil could have modified the base data before parsing,
1788 # ideally need to track if anything did modify the datastore
1791 self.parsecache_valid = False 1789 self.parsecache_valid = False
1792 self.baseconfig_valid = False
1793 1790
1794 1791
1795class CookerExit(bb.event.Event): 1792class CookerExit(bb.event.Event):
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 650ae05ec9..b4e0c4216b 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -263,6 +263,7 @@ class CookerDataBuilder(object):
263 self.mcdata = {} 263 self.mcdata = {}
264 264
265 def parseBaseConfiguration(self, worker=False): 265 def parseBaseConfiguration(self, worker=False):
266 mcdata = {}
266 data_hash = hashlib.sha256() 267 data_hash = hashlib.sha256()
267 try: 268 try:
268 self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles) 269 self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles)
@@ -288,18 +289,18 @@ class CookerDataBuilder(object):
288 289
289 bb.parse.init_parser(self.data) 290 bb.parse.init_parser(self.data)
290 data_hash.update(self.data.get_hash().encode('utf-8')) 291 data_hash.update(self.data.get_hash().encode('utf-8'))
291 self.mcdata[''] = self.data 292 mcdata[''] = self.data
292 293
293 multiconfig = (self.data.getVar("BBMULTICONFIG") or "").split() 294 multiconfig = (self.data.getVar("BBMULTICONFIG") or "").split()
294 for config in multiconfig: 295 for config in multiconfig:
295 if config[0].isdigit(): 296 if config[0].isdigit():
296 bb.fatal("Multiconfig name '%s' is invalid as multiconfigs cannot start with a digit" % config) 297 bb.fatal("Multiconfig name '%s' is invalid as multiconfigs cannot start with a digit" % config)
297 mcdata = self.parseConfigurationFiles(self.prefiles, self.postfiles, config) 298 parsed_mcdata = self.parseConfigurationFiles(self.prefiles, self.postfiles, config)
298 bb.event.fire(bb.event.ConfigParsed(), mcdata) 299 bb.event.fire(bb.event.ConfigParsed(), parsed_mcdata)
299 self.mcdata[config] = mcdata 300 mcdata[config] = parsed_mcdata
300 data_hash.update(mcdata.get_hash().encode('utf-8')) 301 data_hash.update(parsed_mcdata.get_hash().encode('utf-8'))
301 if multiconfig: 302 if multiconfig:
302 bb.event.fire(bb.event.MultiConfigParsed(self.mcdata), self.data) 303 bb.event.fire(bb.event.MultiConfigParsed(mcdata), self.data)
303 304
304 self.data_hash = data_hash.hexdigest() 305 self.data_hash = data_hash.hexdigest()
305 except (SyntaxError, bb.BBHandledException): 306 except (SyntaxError, bb.BBHandledException):
@@ -332,17 +333,23 @@ class CookerDataBuilder(object):
332 if issues: 333 if issues:
333 raise bb.BBHandledException() 334 raise bb.BBHandledException()
334 335
336 for mc in mcdata:
337 mcdata[mc].renameVar("__depends", "__base_depends")
338 mcdata[mc].setVar("__bbclasstype", "recipe")
339
335 # Create a copy so we can reset at a later date when UIs disconnect 340 # Create a copy so we can reset at a later date when UIs disconnect
336 self.origdata = self.data 341 self.mcorigdata = mcdata
337 self.data = bb.data.createCopy(self.origdata) 342 for mc in mcdata:
338 self.mcdata[''] = self.data 343 self.mcdata[mc] = bb.data.createCopy(mcdata[mc])
344 self.data = self.mcdata['']
339 345
340 def reset(self): 346 def reset(self):
341 # We may not have run parseBaseConfiguration() yet 347 # We may not have run parseBaseConfiguration() yet
342 if not hasattr(self, 'origdata'): 348 if not hasattr(self, 'mcorigdata'):
343 return 349 return
344 self.data = bb.data.createCopy(self.origdata) 350 for mc in self.mcorigdata:
345 self.mcdata[''] = self.data 351 self.mcdata[mc] = bb.data.createCopy(self.mcorigdata[mc])
352 self.data = self.mcdata['']
346 353
347 def _findLayerConf(self, data): 354 def _findLayerConf(self, data):
348 return findConfigFile("bblayers.conf", data) 355 return findConfigFile("bblayers.conf", data)