From 99dd411cb051db8ba4913f0df02cac300c635433 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 1 Aug 2013 15:16:52 -0400 Subject: Feature: %globals script section added. Anything in this section will be prepended to the resulting script. Easier than coding a macro subsystem. --- ipsutils/tasks.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ipsutils/tasks.py') 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 -- cgit