[gnome-continuous-yocto/gnomeostree-3.28-rocko: 3733/8267] bitbake: tinfoil: pass datastore to server when expanding python references



commit 8f8a9ef66930ef8375050e80c751dab5ba024d83
Author: Paul Eggleton <paul eggleton linux intel com>
Date:   Tue Dec 13 20:07:09 2016 +1300

    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>

 bitbake/lib/bb/command.py    |   11 +++++------
 bitbake/lib/bb/data_smart.py |    2 +-
 bitbake/lib/bb/tests/data.py |   10 ++++++++--
 bitbake/lib/bb/tinfoil.py    |    6 ++++--
 4 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index b296b8c..352838b 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -483,14 +483,13 @@ class CommandsSync:
     dataStoreConnectorGetVarHistory.readonly = True
 
     def dataStoreConnectorExpandPythonRef(self, command, params):
-        dsindex = params[0]
+        config_data_dict = params[0]
         varname = params[1]
         expr = params[2]
-        if dsindex:
-            datastore = self.dataStores[dsindex]
-        else:
-            datastore = command.cooker.data
-        varparse = bb.data_smart.VariableParse(varname, datastore)
+
+        config_data = command.remotedatastores.receive_datastore(config_data_dict)
+
+        varparse = bb.data_smart.VariableParse(varname, config_data)
         return varparse.python_sub(expr)
 
     def dataStoreConnectorRelease(self, command, params):
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 5d0ed12..4d0a771 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -123,7 +123,7 @@ class VariableParse:
 
             if "_remote_data" in self.d:
                 connector = self.d["_remote_data"]
-                return connector.expandPythonRef(self.varname, code)
+                return connector.expandPythonRef(self.varname, code, self.d)
 
             codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
 
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 2bd481b..a17245f 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -458,8 +458,11 @@ class Remote(unittest.TestCase):
                 return self.d.localkeys()
             def getVarHistory(self, name):
                 return self.d.varhistory.variable(name)
-            def expandPythonRef(self, varname, expr):
-                varparse = bb.data_smart.VariableParse(varname, self.d)
+            def expandPythonRef(self, varname, expr, d):
+                localdata = self.d.createCopy()
+                for key in d.localkeys():
+                    localdata.setVar(d.getVar(key))
+                varparse = bb.data_smart.VariableParse(varname, localdata)
                 return varparse.python_sub(expr)
             def setVar(self, name, value):
                 self.d.setVar(name, value)
@@ -483,3 +486,6 @@ class Remote(unittest.TestCase):
         # Test setVar on client side affects server
         d2.setVar('HELLO', 'other-world')
         self.assertEqual(d1.getVar('HELLO'), 'other-world')
+        # Test client side data is incorporated in python expansion (which is done on server)
+        d2.setVar('FOO', 'bar')
+        self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar')
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index c551a9f..720bf4b 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -29,6 +29,7 @@ import bb.providers
 import bb.taskdata
 import bb.utils
 import bb.command
+import bb.remotedata
 from bb.cookerdata import CookerConfiguration, ConfigParameters
 from bb.main import setup_bitbake, BitBakeConfigParameters, BBMainException
 import bb.fetch2
@@ -69,8 +70,9 @@ class TinfoilDataStoreConnector:
         return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex))
     def getVarHistory(self, name):
         return self.tinfoil.run_command('dataStoreConnectorGetVarHistory', self.dsindex, name)
-    def expandPythonRef(self, varname, expr):
-        ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', self.dsindex, varname, expr)
+    def expandPythonRef(self, varname, expr, d):
+        ds = bb.remotedata.RemoteDatastores.transmit_datastore(d)
+        ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', ds, varname, expr)
         return ret
     def setVar(self, varname, value):
         if self.dsindex is None:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]