diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-03-20 17:05:52 +1300 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-22 11:35:22 +0000 |
| commit | 99414bdb1c64f7f03e12c347cc16c43c2fa336b2 (patch) | |
| tree | ed87faa1728cd3731a846b278269281e348c401b /bitbake/lib | |
| parent | 0cb6f853357f26962748ab1a21490e7d4af53af0 (diff) | |
| download | poky-99414bdb1c64f7f03e12c347cc16c43c2fa336b2.tar.gz | |
bitbake: tinfoil: fix override handling in remote datastores
There was a huge gap in the remote datastore code introduced in the
tinfoil2 rework - we weren't handling overrides at all, since these are
stored separately from the actual data in the DataSmart object. Thus,
when a datastore actually represents a remote datastore we need to go
back to that remote datastore to get the override data as well, so
introduce code to do that.
To avoid a second round-trip I had to modify the _findVar() function to
return the override data as well. This will increase the overhead a
little when that data is superfluous, but without making the function
even uglier I don't think there's a way to avoid that.
(Bitbake rev: 4f9d6f060ed247fb6fa2f45668a892a1788d3f91)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/command.py | 12 | ||||
| -rw-r--r-- | bitbake/lib/bb/data_smart.py | 15 | ||||
| -rw-r--r-- | bitbake/lib/bb/tests/data.py | 4 | ||||
| -rw-r--r-- | bitbake/lib/bb/tinfoil.py | 7 |
4 files changed, 26 insertions, 12 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index db20f3ffad..222a76e580 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
| @@ -457,16 +457,22 @@ class CommandsSync: | |||
| 457 | dsindex = params[0] | 457 | dsindex = params[0] |
| 458 | name = params[1] | 458 | name = params[1] |
| 459 | datastore = command.remotedatastores[dsindex] | 459 | datastore = command.remotedatastores[dsindex] |
| 460 | value = datastore._findVar(name) | 460 | value, overridedata = datastore._findVar(name) |
| 461 | 461 | ||
| 462 | if value: | 462 | if value: |
| 463 | content = value.get('_content', None) | 463 | content = value.get('_content', None) |
| 464 | if isinstance(content, bb.data_smart.DataSmart): | 464 | if isinstance(content, bb.data_smart.DataSmart): |
| 465 | # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully | 465 | # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully |
| 466 | idx = command.remotedatastores.check_store(content, True) | 466 | idx = command.remotedatastores.check_store(content, True) |
| 467 | return {'_content': DataStoreConnectionHandle(idx), '_connector_origtype': 'DataStoreConnectionHandle'} | 467 | return {'_content': DataStoreConnectionHandle(idx), |
| 468 | '_connector_origtype': 'DataStoreConnectionHandle', | ||
| 469 | '_connector_overrides': overridedata} | ||
| 468 | elif isinstance(content, set): | 470 | elif isinstance(content, set): |
| 469 | return {'_content': list(content), '_connector_origtype': 'set'} | 471 | return {'_content': list(content), |
| 472 | '_connector_origtype': 'set', | ||
| 473 | '_connector_overrides': overridedata} | ||
| 474 | else: | ||
| 475 | value['_connector_overrides'] = overridedata | ||
| 470 | return value | 476 | return value |
| 471 | dataStoreConnectorFindVar.readonly = True | 477 | dataStoreConnectorFindVar.readonly = True |
| 472 | 478 | ||
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 4d56081b66..5777d545a8 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
| @@ -473,7 +473,7 @@ class DataSmart(MutableMapping): | |||
| 473 | dest = self.dict | 473 | dest = self.dict |
| 474 | while dest: | 474 | while dest: |
| 475 | if var in dest: | 475 | if var in dest: |
| 476 | return dest[var] | 476 | return dest[var], self.overridedata.get(var, None) |
| 477 | 477 | ||
| 478 | if "_remote_data" in dest: | 478 | if "_remote_data" in dest: |
| 479 | connector = dest["_remote_data"]["_content"] | 479 | connector = dest["_remote_data"]["_content"] |
| @@ -482,12 +482,13 @@ class DataSmart(MutableMapping): | |||
| 482 | if "_data" not in dest: | 482 | if "_data" not in dest: |
| 483 | break | 483 | break |
| 484 | dest = dest["_data"] | 484 | dest = dest["_data"] |
| 485 | return None, self.overridedata.get(var, None) | ||
| 485 | 486 | ||
| 486 | def _makeShadowCopy(self, var): | 487 | def _makeShadowCopy(self, var): |
| 487 | if var in self.dict: | 488 | if var in self.dict: |
| 488 | return | 489 | return |
| 489 | 490 | ||
| 490 | local_var = self._findVar(var) | 491 | local_var, _ = self._findVar(var) |
| 491 | 492 | ||
| 492 | if local_var: | 493 | if local_var: |
| 493 | self.dict[var] = copy.copy(local_var) | 494 | self.dict[var] = copy.copy(local_var) |
| @@ -699,13 +700,13 @@ class DataSmart(MutableMapping): | |||
| 699 | self.dict["__exportlist"]["_content"].add(var) | 700 | self.dict["__exportlist"]["_content"].add(var) |
| 700 | 701 | ||
| 701 | def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False): | 702 | def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False): |
| 702 | local_var = self._findVar(var) | 703 | local_var, overridedata = self._findVar(var) |
| 703 | value = None | 704 | value = None |
| 704 | if flag == "_content" and var in self.overridedata and not parsing: | 705 | if flag == "_content" and overridedata is not None and not parsing: |
| 705 | match = False | 706 | match = False |
| 706 | active = {} | 707 | active = {} |
| 707 | self.need_overrides() | 708 | self.need_overrides() |
| 708 | for (r, o) in self.overridedata[var]: | 709 | for (r, o) in overridedata: |
| 709 | # What about double overrides both with "_" in the name? | 710 | # What about double overrides both with "_" in the name? |
| 710 | if o in self.overridesset: | 711 | if o in self.overridesset: |
| 711 | active[o] = r | 712 | active[o] = r |
| @@ -796,7 +797,7 @@ class DataSmart(MutableMapping): | |||
| 796 | 797 | ||
| 797 | def delVarFlag(self, var, flag, **loginfo): | 798 | def delVarFlag(self, var, flag, **loginfo): |
| 798 | self.expand_cache = {} | 799 | self.expand_cache = {} |
| 799 | local_var = self._findVar(var) | 800 | local_var, _ = self._findVar(var) |
| 800 | if not local_var: | 801 | if not local_var: |
| 801 | return | 802 | return |
| 802 | if not var in self.dict: | 803 | if not var in self.dict: |
| @@ -839,7 +840,7 @@ class DataSmart(MutableMapping): | |||
| 839 | self.dict[var][i] = flags[i] | 840 | self.dict[var][i] = flags[i] |
| 840 | 841 | ||
| 841 | def getVarFlags(self, var, expand = False, internalflags=False): | 842 | def getVarFlags(self, var, expand = False, internalflags=False): |
| 842 | local_var = self._findVar(var) | 843 | local_var, _ = self._findVar(var) |
| 843 | flags = {} | 844 | flags = {} |
| 844 | 845 | ||
| 845 | if local_var: | 846 | if local_var: |
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index 895489e02a..da3f4e66f8 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
| @@ -503,3 +503,7 @@ class Remote(unittest.TestCase): | |||
| 503 | # Test client side data is incorporated in python expansion (which is done on server) | 503 | # Test client side data is incorporated in python expansion (which is done on server) |
| 504 | d2.setVar('FOO', 'bar') | 504 | d2.setVar('FOO', 'bar') |
| 505 | self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar') | 505 | self.assertEqual(d2.expand('${@d.getVar("FOO")}'), 'bar') |
| 506 | # Test overrides work | ||
| 507 | d1.setVar('FOO_test', 'baz') | ||
| 508 | d1.appendVar('OVERRIDES', ':test') | ||
| 509 | self.assertEqual(d2.getVar('FOO'), 'baz') | ||
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py index 940f9ab0d5..00cec59b83 100644 --- a/bitbake/lib/bb/tinfoil.py +++ b/bitbake/lib/bb/tinfoil.py | |||
| @@ -60,12 +60,15 @@ class TinfoilDataStoreConnector: | |||
| 60 | self.dsindex = dsindex | 60 | self.dsindex = dsindex |
| 61 | def getVar(self, name): | 61 | def getVar(self, name): |
| 62 | value = self.tinfoil.run_command('dataStoreConnectorFindVar', self.dsindex, name) | 62 | value = self.tinfoil.run_command('dataStoreConnectorFindVar', self.dsindex, name) |
| 63 | overrides = None | ||
| 63 | if isinstance(value, dict): | 64 | if isinstance(value, dict): |
| 64 | if '_connector_origtype' in value: | 65 | if '_connector_origtype' in value: |
| 65 | value['_content'] = self.tinfoil._reconvert_type(value['_content'], value['_connector_origtype']) | 66 | value['_content'] = self.tinfoil._reconvert_type(value['_content'], value['_connector_origtype']) |
| 66 | del value['_connector_origtype'] | 67 | del value['_connector_origtype'] |
| 67 | 68 | if '_connector_overrides' in value: | |
| 68 | return value | 69 | overrides = value['_connector_overrides'] |
| 70 | del value['_connector_overrides'] | ||
| 71 | return value, overrides | ||
| 69 | def getKeys(self): | 72 | def getKeys(self): |
| 70 | return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex)) | 73 | return set(self.tinfoil.run_command('dataStoreConnectorGetKeys', self.dsindex)) |
| 71 | def getVarHistory(self, name): | 74 | def getVarHistory(self, name): |
