summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/command.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-23 12:43:25 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-03-24 22:01:03 +0000
commitd53958766e2c766b95b3947f69b64c409ed433d8 (patch)
tree45e943ca7b1cce938d730cf17cdbb4e472082258 /bitbake/lib/bb/command.py
parent89705a60f3b566743703c3a7597ccc4507293dd9 (diff)
downloadpoky-d53958766e2c766b95b3947f69b64c409ed433d8.tar.gz
bitbake: tinfoil: Simplify remote datastore connections
The current approach to remote datastores used in tinfoil is breaking. For example, adding a devupstream extension to a recipe with a git upstream, making it the preferred version and then running "devtool modify" on it causes get_srcrev() circular dependency issues. The problem is the override handling in the datastore is broken. This gets broken since remotedata:recieve_datastore() sets d.dict but doesn't update d.overridedata (or d.inchistory or d.varhistory). We could play whack-a-mole but the current implementation seems to be flawed to me. It also doesn't cover, or only partially covers some datastore operations and each needs new dedicated command API. Instead, step back and reimplement the way the datastore connector works. With this change, the datastore is either remote or local but the data is not spread on two sides of the connection. All the API is proxied over the connection by a single function for the datastore (and two to support variable history and include history). This code does not support using the datastore as a parameter to any data store functions. We did have one case of that but its just bad code and can be replaced. The result is something which is much simpler and less invasive to the datastore code itself, meaning its behaviour should be much more consistent. The existing tests for the remote data no longer make any sense and are removed. The one bug this code would have is if key/value pairs are returned over the IPC and those values contained a DataSmart object since we don't recurse into return values to find such things. Nothing appears to do that currently so lets worry about it if its ever an issue. This change should simplfy a ton of other issues and avoid a ton of other bugs so is a huge net gain. Tested with bitbake's and OE's selftests. (Bitbake rev: 85e03a64dd0a4ebe71009ec4bdf4192c04a9786e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/command.py')
-rw-r--r--bitbake/lib/bb/command.py91
1 files changed, 25 insertions, 66 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index b38c151b3d..2879950933 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -450,54 +450,38 @@ class CommandsSync:
450 return all_p, best 450 return all_p, best
451 getRuntimeProviders.readonly = True 451 getRuntimeProviders.readonly = True
452 452
453 def dataStoreConnectorFindVar(self, command, params): 453 def dataStoreConnectorCmd(self, command, params):
454 dsindex = params[0] 454 dsindex = params[0]
455 name = params[1] 455 method = params[1]
456 datastore = command.remotedatastores[dsindex] 456 args = params[2]
457 value, overridedata = datastore._findVar(name) 457 kwargs = params[3]
458
459 if value:
460 content = value.get('_content', None)
461 if isinstance(content, bb.data_smart.DataSmart):
462 # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully
463 idx = command.remotedatastores.check_store(content, True)
464 return {'_content': DataStoreConnectionHandle(idx),
465 '_connector_origtype': 'DataStoreConnectionHandle',
466 '_connector_overrides': overridedata}
467 elif isinstance(content, set):
468 return {'_content': list(content),
469 '_connector_origtype': 'set',
470 '_connector_overrides': overridedata}
471 else:
472 value['_connector_overrides'] = overridedata
473 else:
474 value = {}
475 value['_connector_overrides'] = overridedata
476 return value
477 dataStoreConnectorFindVar.readonly = True
478 458
479 def dataStoreConnectorGetKeys(self, command, params): 459 d = command.remotedatastores[dsindex]
480 dsindex = params[0] 460 ret = getattr(d, method)(*args, **kwargs)
481 datastore = command.remotedatastores[dsindex] 461
482 return list(datastore.keys()) 462 if isinstance(ret, bb.data_smart.DataSmart):
483 dataStoreConnectorGetKeys.readonly = True 463 idx = command.remotedatastores.store(ret)
464 return DataStoreConnectionHandle(idx)
484 465
485 def dataStoreConnectorGetVarHistory(self, command, params): 466 return ret
467
468 def dataStoreConnectorVarHistCmd(self, command, params):
486 dsindex = params[0] 469 dsindex = params[0]
487 name = params[1] 470 method = params[1]
488 datastore = command.remotedatastores[dsindex] 471 args = params[2]
489 return datastore.varhistory.variable(name) 472 kwargs = params[3]
490 dataStoreConnectorGetVarHistory.readonly = True
491 473
492 def dataStoreConnectorExpandPythonRef(self, command, params): 474 d = command.remotedatastores[dsindex].varhistory
493 config_data_dict = params[0] 475 return getattr(d, method)(*args, **kwargs)
494 varname = params[1]
495 expr = params[2]
496 476
497 config_data = command.remotedatastores.receive_datastore(config_data_dict) 477 def dataStoreConnectorIncHistCmd(self, command, params):
478 dsindex = params[0]
479 method = params[1]
480 args = params[2]
481 kwargs = params[3]
498 482
499 varparse = bb.data_smart.VariableParse(varname, config_data) 483 d = command.remotedatastores[dsindex].inchistory
500 return varparse.python_sub(expr) 484 return getattr(d, method)(*args, **kwargs)
501 485
502 def dataStoreConnectorRelease(self, command, params): 486 def dataStoreConnectorRelease(self, command, params):
503 dsindex = params[0] 487 dsindex = params[0]
@@ -505,31 +489,6 @@ class CommandsSync:
505 raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex) 489 raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex)
506 command.remotedatastores.release(dsindex) 490 command.remotedatastores.release(dsindex)
507 491
508 def dataStoreConnectorSetVarFlag(self, command, params):
509 dsindex = params[0]
510 name = params[1]
511 flag = params[2]
512 value = params[3]
513 datastore = command.remotedatastores[dsindex]
514 datastore.setVarFlag(name, flag, value)
515
516 def dataStoreConnectorDelVar(self, command, params):
517 dsindex = params[0]
518 name = params[1]
519 datastore = command.remotedatastores[dsindex]
520 if len(params) > 2:
521 flag = params[2]
522 datastore.delVarFlag(name, flag)
523 else:
524 datastore.delVar(name)
525
526 def dataStoreConnectorRenameVar(self, command, params):
527 dsindex = params[0]
528 name = params[1]
529 newname = params[2]
530 datastore = command.remotedatastores[dsindex]
531 datastore.renameVar(name, newname)
532
533 def parseRecipeFile(self, command, params): 492 def parseRecipeFile(self, command, params):
534 """ 493 """
535 Parse the specified recipe file (with or without bbappends) 494 Parse the specified recipe file (with or without bbappends)