summaryrefslogtreecommitdiff
path: root/scripts/lib/wic/utils/oe
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:01:52 +0000
commitf0ec387ad40fb9c098ac8d761993bc2bacc76e65 (patch)
tree6c5340fca13ff7c3653bb6343f9827c2fab25d4e /scripts/lib/wic/utils/oe
parent914e08cf627e54e5019eda2154663c30b9a68ded (diff)
downloadopenembedded-core-f0ec387ad40fb9c098ac8d761993bc2bacc76e65.tar.gz
openembedded-core-f0ec387ad40fb9c098ac8d761993bc2bacc76e65.tar.bz2
openembedded-core-f0ec387ad40fb9c098ac8d761993bc2bacc76e65.zip
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. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/lib/wic/utils/oe')
-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 @@
"""Miscellaneous functions."""
import os
+import re
from collections import defaultdict
from distutils import spawn
@@ -148,21 +149,18 @@ class BitbakeVars(defaultdict):
self.default_image = None
self.vars_dir = None
- def _parse_line(self, line, image):
+ def _parse_line(self, line, image, matcher=re.compile(r"^(\w+)=(.+)")):
"""
Parse one line from bitbake -e output or from .env file.
Put result key-value pair into the storage.
"""
if "=" not in line:
return
- try:
- key, val = line.split("=")
- except ValueError:
+ match = matcher.match(line)
+ if not match:
return
- key = key.strip()
- val = val.strip()
- if key.replace('_', '').isalnum():
- self[image][key] = val.strip('"')
+ key, val = match.groups()
+ self[image][key] = val.strip('"')
def get_var(self, var, image=None):
"""