summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)