summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-12-13 20:07:09 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 12:25:07 +0000
commit8f8a9ef66930ef8375050e80c751dab5ba024d83 (patch)
tree5aff939bf2af2f18a1c07c24315ae57c99720d9b /bitbake
parentf1f3a112a02aef2e7094b4700c9a7d341ee01275 (diff)
downloadpoky-8f8a9ef66930ef8375050e80c751dab5ba024d83.tar.gz
bitbake: tinfoil: pass datastore to server when expanding python references
If you're expanding a value that refers to the value of a variable in python code, we need to ensure that the datastore that gets used to get the value of that variable is the client-side datastore and not just the part of it that's on the server side. For example, suppose you are in client code doing the following: d.setVar('HELLO', 'there') result = d.expand('${@d.getVar("HELLO", True)}') result should be "there" but if the client part wasn't taken into account, it would be whatever value HELLO had in the server portion of the datastore (if any). (Bitbake rev: cbc22a0a9aadc8606b927dbac0f1407ec2736b35) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/command.py11
-rw-r--r--bitbake/lib/bb/data_smart.py2
-rw-r--r--bitbake/lib/bb/tests/data.py10
-rw-r--r--bitbake/lib/bb/tinfoil.py6
4 files changed, 18 insertions, 11 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index b296b8ce84..352838b0aa 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -483,14 +483,13 @@ class CommandsSync:
483 dataStoreConnectorGetVarHistory.readonly = True 483 dataStoreConnectorGetVarHistory.readonly = True
484 484
485 def dataStoreConnectorExpandPythonRef(self, command, params): 485 def dataStoreConnectorExpandPythonRef(self, command, params):
486 dsindex = params[0] 486 config_data_dict = params[0]
487 varname = params[1] 487 varname = params[1]
488 expr = params[2] 488 expr = params[2]
489 if dsindex: 489
490 datastore = self.dataStores[dsindex] 490 config_data = command.remotedatastores.receive_datastore(config_data_dict)
491 else: 491
492 datastore = command.cooker.data 492 varparse = bb.data_smart.VariableParse(varname, config_data)
493 varparse = bb.data_smart.VariableParse(varname, datastore)
494 return varparse.python_sub(expr) 493 return varparse.python_sub(expr)
495 494
496 def dataStoreConnectorRelease(self, command, params): 495 def dataStoreConnectorRelease(self, command, params):
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 5d0ed12d6e..4d0a771283 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -123,7 +123,7 @@ class VariableParse:
123 123
124 if "_remote_data" in self.d: 124 if "_remote_data" in self.d:
125 connector = self.d["_remote_data"] 125 connector = self.d["_remote_data"]
126 return connector.expandPythonRef(self.varname, code) 126 return connector.expandPythonRef(self.varname, code, self.d)
127 127
128 codeobj = compile(code.strip(), self.varname or "<expansion>", "eval") 128 codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
129 129
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 2bd481b5d7..a17245f90a 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -458,8 +458,11 @@ class Remote(unittest.TestCase):
458 return self.d.localkeys() 458 return self.d.localkeys()
459 def getVarHistory(self, name): 459 def getVarHistory(self, name):
460 return self.d.varhistory.variable(name) 460 return self.d.varhistory.variable(name)
461 def expandPythonRef(self, varname, expr): 461 def expandPythonRef(self, varname, expr, d):
462 varparse = bb.data_smart.VariableParse(varname, self.d) 462 localdata = self.d.createCopy()
463 for key in d.localkeys():
464 localdata.setVar(d.getVar(key))
465 varparse = bb.data_smart.VariableParse(varname, localdata)
463 return varparse.python_sub(expr) 466 return varparse.python_sub(expr)
464 def setVar(self, name, value): 467 def setVar(self, name, value):
465 self.d.setVar(name, value) 468 self.d.setVar(name, value)
@@ -483,3 +486,6 @@ class Remote(unittest.TestCase):
483 # Test setVar on client side affects server 486 # Test setVar on client side affects server
484 d2.setVar('HELLO', 'other-world') 487 d2.setVar('HELLO', 'other-world')
485 self.assertEqual(d1.getVar('HELLO'), 'other-world') 488 self.assertEqual(d1.getVar('HELLO'), 'other-world')
489 # Test client side data is incorporated in python expansion (which is done on server)
490 d2.setVar('FOO', 'bar')
491 self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar')
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index c551a9f1f7..720bf4b931 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -29,6 +29,7 @@ import bb.providers
29import bb.taskdata 29import bb.taskdata
30import bb.utils 30import bb.utils
31import bb.command 31import bb.command
32import bb.remotedata
32from bb.cookerdata import CookerConfiguration, ConfigParameters 33from bb.cookerdata import CookerConfiguration, ConfigParameters
33from bb.main import setup_bitbake, BitBakeConfigParameters, BBMainException 34from bb.main import setup_bitbake, BitBakeConfigParameters, BBMainException
34import bb.fetch2 35import bb.fetch2
@@ -69,8 +70,9 @@ class TinfoilDataStoreConnector:
69 return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex)) 70 return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex))
70 def getVarHistory(self, name): 71 def getVarHistory(self, name):
71 return self.tinfoil.run_command('dataStoreConnectorGetVarHistory', self.dsindex, name) 72 return self.tinfoil.run_command('dataStoreConnectorGetVarHistory', self.dsindex, name)
72 def expandPythonRef(self, varname, expr): 73 def expandPythonRef(self, varname, expr, d):
73 ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', self.dsindex, varname, expr) 74 ds = bb.remotedata.RemoteDatastores.transmit_datastore(d)
75 ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', ds, varname, expr)
74 return ret 76 return ret
75 def setVar(self, varname, value): 77 def setVar(self, varname, value):
76 if self.dsindex is None: 78 if self.dsindex is None: