summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>2018-07-03 14:54:14 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-14 11:35:56 +0000
commitd6fe480c2bb20674cb1303f5d85fb6f8b66df1e5 (patch)
treeef5bbe60658e241b88485b3f4fb3e900dc72bda6 /scripts
parente47d6f9e710e4fa17fc3fe9740d878affa751339 (diff)
downloadpoky-d6fe480c2bb20674cb1303f5d85fb6f8b66df1e5.tar.gz
wic: allow bitbake variables in kickstarter files
image_types_wic.bbclass has a mechanism for doing variable substitution on .wks files by simply letting the input file be called .wks.in. However, that doesn't allow using variables in files included via the include directive. This is unfortunate, because lacking either the ability to include other files or variable substitution leads to fragile and error-prone duplication between kickstarter files and recipes/configuration files used for various boards. This adds (somewhat naive) support for variable substitution in all files parsed by wic. The user should add all required variables to WICVARS to get them exported appropriately. (From OE-Core rev: 8a75d614a8a1ff72c4af448ac3e1292d0e1d1a79) Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/ksparser.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 7e5a9c5092..08baf76123 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -28,14 +28,30 @@
28import os 28import os
29import shlex 29import shlex
30import logging 30import logging
31import re
31 32
32from argparse import ArgumentParser, ArgumentError, ArgumentTypeError 33from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
33 34
34from wic.engine import find_canned 35from wic.engine import find_canned
35from wic.partition import Partition 36from wic.partition import Partition
37from wic.misc import get_bitbake_var
36 38
37logger = logging.getLogger('wic') 39logger = logging.getLogger('wic')
38 40
41__expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}")
42
43def expand_line(line):
44 while True:
45 m = __expand_var_regexp__.search(line)
46 if not m:
47 return line
48 key = m.group()[2:-1]
49 val = get_bitbake_var(key)
50 if val is None:
51 logger.warning("cannot expand variable %s" % key)
52 return line
53 line = line[:m.start()] + val + line[m.end():]
54
39class KickStartError(Exception): 55class KickStartError(Exception):
40 """Custom exception.""" 56 """Custom exception."""
41 pass 57 pass
@@ -190,6 +206,7 @@ class KickStart():
190 line = line.strip() 206 line = line.strip()
191 lineno += 1 207 lineno += 1
192 if line and line[0] != '#': 208 if line and line[0] != '#':
209 line = expand_line(line)
193 try: 210 try:
194 line_args = shlex.split(line) 211 line_args = shlex.split(line)
195 parsed = parser.parse_args(line_args) 212 parsed = parser.parse_args(line_args)