diff options
-rw-r--r-- | scripts/lib/wic/ksparser.py | 17 |
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 @@ | |||
28 | import os | 28 | import os |
29 | import shlex | 29 | import shlex |
30 | import logging | 30 | import logging |
31 | import re | ||
31 | 32 | ||
32 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError | 33 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError |
33 | 34 | ||
34 | from wic.engine import find_canned | 35 | from wic.engine import find_canned |
35 | from wic.partition import Partition | 36 | from wic.partition import Partition |
37 | from wic.misc import get_bitbake_var | ||
36 | 38 | ||
37 | logger = logging.getLogger('wic') | 39 | logger = logging.getLogger('wic') |
38 | 40 | ||
41 | __expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}") | ||
42 | |||
43 | def 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 | |||
39 | class KickStartError(Exception): | 55 | class 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) |