summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Barinov <v.barinov@samsung.com>2018-10-17 09:28:03 +0300
committerXiao Jin <jin.xiao@samsung.com>2018-10-25 11:09:25 +0800
commitaa0aaadc4759d137cdf4d4a6ca6fe055ecd300f5 (patch)
tree6be31f787572b46bc802d23cd9c5563a48bfb128
parentdcd76d19482055e1fb678f1df0646396fa7de612 (diff)
downloadmic-aa0aaadc4759d137cdf4d4a6ca6fe055ecd300f5.tar.gz
mic-aa0aaadc4759d137cdf4d4a6ca6fe055ecd300f5.tar.bz2
mic-aa0aaadc4759d137cdf4d4a6ca6fe055ecd300f5.zip
Add %env section support
Kickstart file now may have section for environment variables setup. Section should look like %env VARIABLE1=0x1000 VARIABLE2="value" %end This environment is set up for mic process and propagated into child processes during firmware build. Change-Id: Ida45e768781faf277438e3fb591d9bd931a09a1f Signed-off-by: Slava Barinov <v.barinov@samsung.com>
-rw-r--r--mic/imager/baseimager.py4
-rwxr-xr-xmic/kickstart/__init__.py20
2 files changed, 24 insertions, 0 deletions
diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py
index f33138e..7df75cf 100644
--- a/mic/imager/baseimager.py
+++ b/mic/imager/baseimager.py
@@ -148,6 +148,10 @@ class BaseImageCreator(object):
# No ks provided when called by convertor, so skip the dependency check
if self.ks:
+ if hasattr(self.ks.handler, "env"):
+ for n, v in kickstart.get_env(self.ks):
+ msger.debug("Setting up envvar %s = %s" % (n, v))
+ os.environ[n] = v
# If we have btrfs partition we need to check necessary tools
for part in self.ks.handler.partition.partitions:
if part.fstype and part.fstype == "btrfs":
diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py
index 2eaa425..4cf9bd7 100755
--- a/mic/kickstart/__init__.py
+++ b/mic/kickstart/__init__.py
@@ -70,6 +70,22 @@ class AttachmentSection(kssections.Section):
def handleHeader(self, lineno, args):
kssections.Section.handleHeader(self, lineno, args)
+class EnvSection(kssections.Section):
+ sectionOpen = "%env"
+
+ def handleLine(self, line):
+ if not self.handler:
+ return
+
+ (h, s, t) = line.partition('#')
+ line = h.rstrip()
+ (n, s, v) = line.partition('=')
+ self.handler.env.append((n, v))
+
+ def handleHeader(self, lineno, args):
+ self.handler.env = []
+ kssections.Section.handleHeader(self, lineno, args)
+
def apply_wrapper(func):
def wrapper(*kargs, **kwargs):
try:
@@ -119,6 +135,7 @@ def read_kickstart(path):
ks = ksparser.KickstartParser(KSHandlers(), errorsAreFatal=False)
ks.registerSection(PrepackageSection(ks.handler))
ks.registerSection(AttachmentSection(ks.handler))
+ ks.registerSection(EnvSection(ks.handler))
try:
ks.readKickstart(path)
@@ -809,6 +826,9 @@ def convert_method_to_repo(ks):
def get_attachment(ks, required=()):
return ks.handler.attachment.packageList + list(required)
+def get_env(ks, required=()):
+ return ks.handler.env
+
def get_pre_packages(ks, required=()):
return ks.handler.prepackages.packageList + list(required)