[oe-commits] [bitbake] 18/20: data_smart: Fix expand_cache and _remove operator interaction issues
git at git.openembedded.org
git at git.openembedded.org
Wed Oct 17 11:26:10 UTC 2018
This is an automated email from the git hooks/post-receive script.
rpurdie pushed a commit to branch master-next
in repository bitbake.
commit a9bd4dd252680ff28e75254a5350d771b1cf3517
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Wed Oct 17 10:51:19 2018 +0100
data_smart: Fix expand_cache and _remove operator interaction issues
The contents of the expand_cache is meant to match the return value of
getVarFlag() but the implementation was mostly in expandWithRefs(). If
an incorrect key was passed to expandWithRefs(), or a variable was only
partially expanded with no remove processing, the cache could become
corrupted.
Move the code to getVarFlag making the data lifecycle very clear, meaning
other calls to expandWithRefs() cannot corrupt the cache.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/data_smart.py | 41 ++++++++++++++++++-----------------------
1 file changed, 18 insertions(+), 23 deletions(-)
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 7b2c0a8..2521e59 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -105,11 +105,7 @@ class VariableParse:
if self.varname and key:
if self.varname == key:
raise Exception("variable %s references itself!" % self.varname)
- if key in self.d.expand_cache:
- varparse = self.d.expand_cache[key]
- var = varparse.value
- else:
- var = self.d.getVarFlag(key, "_content")
+ var = self.d.getVarFlag(key, "_content")
self.references.add(key)
if var is not None:
return var
@@ -412,9 +408,6 @@ class DataSmart(MutableMapping):
if not isinstance(s, str): # sanity check
return VariableParse(varname, self, s)
- if varname and varname in self.expand_cache:
- return self.expand_cache[varname]
-
varparse = VariableParse(varname, self)
while s.find('${') != -1:
@@ -438,9 +431,6 @@ class DataSmart(MutableMapping):
varparse.value = s
- if varname:
- self.expand_cache[varname] = varparse
-
return varparse
def expand(self, s, varname = None):
@@ -732,6 +722,17 @@ class DataSmart(MutableMapping):
self.dict["__exportlist"]["_content"].add(var)
def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False):
+ if flag == "_content":
+ cachename = var
+ else:
+ if not flag:
+ bb.warn("Calling getVarFlag with flag unset is invalid")
+ return None
+ cachename = var + "[" + flag + "]"
+
+ if expand and cachename in self.expand_cache:
+ return self.expand_cache[cachename].value
+
local_var, overridedata = self._findVar(var)
value = None
if flag == "_content" and overridedata is not None and not parsing:
@@ -796,14 +797,9 @@ class DataSmart(MutableMapping):
if match:
value = r + value
- if expand and value:
- # Only getvar (flag == _content) hits the expand cache
- cachename = None
- if flag == "_content":
- cachename = var
- else:
- cachename = var + "[" + flag + "]"
- value = self.expand(value, cachename)
+ if expand:
+ self.expand_cache[cachename] = self.expandWithRefs(value, cachename)
+ value = self.expand_cache[cachename].value
if value and flag == "_content" and local_var is not None and "_remove" in local_var and not parsing:
removes = []
@@ -821,10 +817,9 @@ class DataSmart(MutableMapping):
filtered = filter(lambda v: v not in removes,
__whitespace_split__.split(value))
value = "".join(filtered)
- if expand and var in self.expand_cache:
- # We need to ensure the expand cache has the correct value
- # flag == "_content" here
- self.expand_cache[var].value = value
+ if expand and cachename in self.expand_cache:
+ self.expand_cache[cachename].value = value
+
return value
def delVarFlag(self, var, flag, **loginfo):
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list