[bitbake-devel] [PATCH] bitbake: command: add getOverrideData command

Chris Laplante chris.laplante at agilent.com
Thu Oct 31 17:35:54 UTC 2019


While working on a script using tinfoil, I needed a way to access the
overridedata for a given variable. Unfortunately, I found that
data_smart does not have remotedata proxying for it.

By adding the getOverrideData command, I am able to use a method like
this to access override data (either for a particular var, or all data):

def get_override_data(d, var=None):
    if "_remote_data" in d:
        connector = d["_remote_data"]  # type: bb.tinfoil.TinfoilDataStoreConnector
        return connector.getOverrideData(var)

    if var:
        return d.overridedata[var]
    return d.overridedata

Signed-off-by: Chris Laplante <chris.laplante at agilent.com>
---
 bitbake/lib/bb/command.py | 10 ++++++++++
 bitbake/lib/bb/tinfoil.py |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 378f389..19ee8d8 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -485,6 +485,16 @@ class CommandsSync:
         return datastore.varhistory.variable(name)
     dataStoreConnectorGetVarHistory.readonly = True
 
+    def dataStoreConnectorGetOverrideData(self, command, params):
+        dsindex = params[0]
+        datastore = command.remotedatastores[dsindex]
+        ret = datastore.overridedata
+        if len(params) > 1:
+            name = params[1]
+            return ret[name]
+        return ret
+    dataStoreConnectorGetOverrideData.readonly = True
+
     def dataStoreConnectorExpandPythonRef(self, command, params):
         config_data_dict = params[0]
         varname = params[1]
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index 0a1b913..7c8c493 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -65,6 +65,10 @@ 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 getOverrideData(self, name=None):
+        if name:
+            return self.tinfoil.run_command('dataStoreConnectorGetOverrideData', self.dsindex, name)
+        return self.tinfoil.run_command('dataStoreConnectorGetOverrideData', self.dsindex)
     def expandPythonRef(self, varname, expr, d):
         ds = bb.remotedata.RemoteDatastores.transmit_datastore(d)
         ret = self.tinfoil.run_command('dataStoreConnectorExpandPythonRef', ds, varname, expr)
-- 
2.7.4



More information about the bitbake-devel mailing list