Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] wic: allow bitbake variables in kickstarter files
@ 2018-03-22 13:44 Rasmus Villemoes
  2018-04-10 12:11 ` Rasmus Villemoes
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Rasmus Villemoes @ 2018-03-22 13:44 UTC (permalink / raw)
  To: openembedded-core

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 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.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 scripts/lib/wic/ksparser.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index e590b2fe3c..3dc17d7fde 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -28,14 +28,30 @@
 import os
 import shlex
 import logging
+import re
 
 from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
 
 from wic.engine import find_canned
 from wic.partition import Partition
+from wic.misc import get_bitbake_var
 
 logger = logging.getLogger('wic')
 
+__expand_var_regexp__ = re.compile(r"\${[^{}@\n\t :]+}")
+
+def expand_line(line):
+    while True:
+        m = __expand_var_regexp__.search(line)
+        if not m:
+            return line
+        key = m.group()[2:-1]
+        val = get_bitbake_var(key)
+        if val is None:
+            logger.warning("cannot expand variable %s" % key)
+            return line
+        line = line[:m.start()] + val + line[m.end():]
+
 class KickStartError(Exception):
     """Custom exception."""
     pass
@@ -189,6 +205,7 @@ class KickStart():
                 line = line.strip()
                 lineno += 1
                 if line and line[0] != '#':
+                    line = expand_line(line)
                     try:
                         line_args = shlex.split(line)
                         parsed = parser.parse_args(line_args)
-- 
2.15.1



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-01-14 23:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-22 13:44 [PATCH] wic: allow bitbake variables in kickstarter files Rasmus Villemoes
2018-04-10 12:11 ` Rasmus Villemoes
2018-04-30 20:19 ` Rasmus Villemoes
2018-06-21 19:16 ` Martin Hundebøll
2018-07-03 12:54 ` [PATCH resend] " Rasmus Villemoes
2018-07-17  8:14   ` Rasmus Villemoes
2018-07-19  7:13     ` Sean Nyekjær
2018-12-29  0:06   ` [PATCH resend^2] " Rasmus Villemoes
2019-01-09  6:57     ` Rasmus Villemoes
2019-01-13 11:18     ` Rasmus Villemoes
2018-07-19 12:51 ` [PATCH] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox