summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-12-21 17:05:11 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-16 18:05:12 +0000
commit5651e8da6089eb638ab938cb21fd95ec327e84b5 (patch)
treeb12915049702d3a2d5b91676e9d37bc4c66c827c /scripts
parente30f00bca5f61e9693d59e763a3dce633d76f00b (diff)
downloadpoky-5651e8da6089eb638ab938cb21fd95ec327e84b5.tar.gz
wic: fix parsing of 'bitbake -e' output
Current parsing code can wrongly interpret arbitrary lines that are of 'key=value' format as legitimate bitbake variables. Implemented more strict parsing of key=value pairs using regular expressions. (From OE-Core rev: f0ec387ad40fb9c098ac8d761993bc2bacc76e65) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/utils/oe/misc.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/scripts/lib/wic/utils/oe/misc.py b/scripts/lib/wic/utils/oe/misc.py
index fe188c9d26..2a2fcc94fb 100644
--- a/scripts/lib/wic/utils/oe/misc.py
+++ b/scripts/lib/wic/utils/oe/misc.py
@@ -27,6 +27,7 @@
27"""Miscellaneous functions.""" 27"""Miscellaneous functions."""
28 28
29import os 29import os
30import re
30from collections import defaultdict 31from collections import defaultdict
31from distutils import spawn 32from distutils import spawn
32 33
@@ -148,21 +149,18 @@ class BitbakeVars(defaultdict):
148 self.default_image = None 149 self.default_image = None
149 self.vars_dir = None 150 self.vars_dir = None
150 151
151 def _parse_line(self, line, image): 152 def _parse_line(self, line, image, matcher=re.compile(r"^(\w+)=(.+)")):
152 """ 153 """
153 Parse one line from bitbake -e output or from .env file. 154 Parse one line from bitbake -e output or from .env file.
154 Put result key-value pair into the storage. 155 Put result key-value pair into the storage.
155 """ 156 """
156 if "=" not in line: 157 if "=" not in line:
157 return 158 return
158 try: 159 match = matcher.match(line)
159 key, val = line.split("=") 160 if not match:
160 except ValueError:
161 return 161 return
162 key = key.strip() 162 key, val = match.groups()
163 val = val.strip() 163 self[image][key] = val.strip('"')
164 if key.replace('_', '').isalnum():
165 self[image][key] = val.strip('"')
166 164
167 def get_var(self, var, image=None): 165 def get_var(self, var, image=None):
168 """ 166 """