aboutsummaryrefslogtreecommitdiff
path: root/ipsutils/tasks.py
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2013-08-01 15:16:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2013-08-01 15:16:52 -0400
commit99dd411cb051db8ba4913f0df02cac300c635433 (patch)
tree435c6b9c8e773e20dc51d3a11faab0c9f2ac7fe2 /ipsutils/tasks.py
parent6e6fcb8788f10d81b214be1ed79f48f9387c74be (diff)
downloadipsutils-99dd411cb051db8ba4913f0df02cac300c635433.tar.gz
Feature: %globals script section added. Anything in this section will be prepended to the resulting script. Easier than coding a macro subsystem.
Diffstat (limited to 'ipsutils/tasks.py')
-rw-r--r--ipsutils/tasks.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ipsutils/tasks.py b/ipsutils/tasks.py
index c7c0fc6..ec69814 100644
--- a/ipsutils/tasks.py
+++ b/ipsutils/tasks.py
@@ -340,6 +340,21 @@ class Script(task.Task):
fp_tempfile = tempfile.NamedTemporaryFile('w+', prefix='ipsutils_', suffix='.sh', delete=True)
os.chdir(self.cls.env_pkg['BUILD'])
fp_tempfile.write(shebang)
+
+ if(self.cls.script_dict['globals']):
+ for line in self.cls.script_dict['globals']:
+ if not line:
+ continue
+ # Variable expansion occurs here. Unfortunately, env_pkg is NOT available
+ # from within the configuration class
+ t = string.Template(string.join(line))
+ line = t.safe_substitute(self.cls.env_pkg)
+ fp_tempfile.writelines(line)
+ fp_tempfile.writelines('\n')
+ if self.cls.options.verbose:
+ print(">>> {0:s}".format(line))
+ fp_tempfile.flush()
+
for line in self.script:
if not line:
continue