summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/ksparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/ksparser.py')
-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)