From 919a4fc61913615f441a92b3d5f2b99a93eeea90 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Fri, 24 Apr 2015 14:04:10 -0500 Subject: [PATCH 1/2] Added params needed for Atomic compose to LoraxWrapper Add add_template, add_template_var, add_arch_template, and add_arch_template_var to the call for lorax.get_lorax_cmd for the Atomic ISO composes. Remove duplicate if statement for add_template_var in lorax wrapper --- pungi/phases/buildinstall.py | 8 ++++- pungi/wrappers/lorax.py | 61 +++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index 783ba60c..e6d94585 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -87,6 +87,12 @@ class BuildinstallPhase(PhaseBase): noupgrade = not self.compose.conf.get("buildinstall_upgrade_image", False) buildinstall_method = self.compose.conf["buildinstall_method"] + # These were added for the Atomic ISO Lorax compose + add_template = self.compose.conf.get("add_template", None) + add_template_var = self.compose.conf.get("add_template_var", None) + add_arch_template = self.compose.conf.get("add_arch_template", None) + add_arch_template_var = self.compose.conf.get("add_arch_template_var", None) + for arch in self.compose.get_arches(): repo_baseurl = self.compose.paths.work.arch_repo(arch) output_dir = self.compose.paths.work.buildinstall_dir(arch) @@ -94,7 +100,7 @@ class BuildinstallPhase(PhaseBase): buildarch = get_valid_arches(arch)[0] if buildinstall_method == "lorax": - cmd = lorax.get_lorax_cmd(product, version, release, repo_baseurl, output_dir, is_final=self.compose.supported, buildarch=buildarch, volid=volid, nomacboot=True, noupgrade=noupgrade) + cmd = lorax.get_lorax_cmd(product, version, release, repo_baseurl, output_dir, is_final=self.compose.supported, buildarch=buildarch, volid=volid, nomacboot=True, noupgrade=noupgrade, add_template=add_template, add_template_var=add_template_var, add_arch_template=add_arch_template, add_template_var=add_template_var) elif buildinstall_method == "buildinstall": cmd = lorax.get_buildinstall_cmd(product, version, release, repo_baseurl, output_dir, is_final=self.compose.supported, buildarch=buildarch, volid=volid) else: diff --git a/pungi/wrappers/lorax.py b/pungi/wrappers/lorax.py index 80d7f9f8..724ddc32 100644 --- a/pungi/wrappers/lorax.py +++ b/pungi/wrappers/lorax.py @@ -21,7 +21,40 @@ from kobo.shortcuts import force_list class LoraxWrapper(object): - def get_lorax_cmd(self, product, version, release, repo_baseurl, output_dir, variant=None, bugurl=None, nomacboot=False, noupgrade=False, is_final=False, buildarch=None, volid=None): + def _handle_optional_arg_type(self, f_arg, c_arg): + """ + _handle_optional_arg_type + private function to handle arguments to LoraxWrapper get_*_cmd + functions that can optionally be different types (such as string + or list). This effectively allows to repeat args to the commands + wrapped by LoraxWrapper. + + @param uknown type : f_arg + - Function argument that is passed to the get_*_cmd function. + + @param string: c_arg + - Command line argument to append to cmd + + @return list + - returns a list of strings to join with the cmd list in the get_*_cmd + functions + """ + + cmd_args = [] + + if type(f_arg) is list: + for item in f_arg: + cmd_args.append("%s=%s" % (c_arg, item)) + if type(f_arg) is str: + cmd_args.append("%s=%s" % (c_arg, item)) + else: + raise Exception( + f_arg, + "Incorrect type passed to LoraxWrapper for " % c_arg + ) + return cmd_args + + def get_lorax_cmd(self, product, version, release, repo_baseurl, output_dir, variant=None, bugurl=None, nomacboot=False, noupgrade=False, is_final=False, buildarch=None, volid=None, add_template=None, add_template_var=None, add_arch_template=None, add_arch_template_var=None): cmd = ["lorax"] cmd.append("--product=%s" % product) cmd.append("--version=%s" % version) @@ -53,6 +86,32 @@ class LoraxWrapper(object): if volid: cmd.append("--volid=%s" % volid) + if add_template: + cmd.extend( + self._handle_optional_arg_type(add_template, "--add-template") + ) + + if add_template_var: + cmd.extend( + self._handle_optional_arg_type( + add_template_var, "--add-template-var" + ) + ) + + if add_arch_template: + cmd.extend( + self._handle_optional_arg_type( + add_arch_template, "--add-arch-template" + ) + ) + + if add_arch_template_var: + cmd.extend( + self._handle_optional_arg_type( + add_arch_template_var, "--add-arch-template-var" + ) + ) + output_dir = os.path.abspath(output_dir) cmd.append(output_dir) From 1373fe5178c402b80de1c55e5e47cce71cc36749 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Tue, 18 Aug 2015 15:50:16 -0500 Subject: [PATCH 2/2] fix up if/elif in _handle_optional_arg_type --- pungi/wrappers/lorax.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pungi/wrappers/lorax.py b/pungi/wrappers/lorax.py index 724ddc32..94ac9e26 100644 --- a/pungi/wrappers/lorax.py +++ b/pungi/wrappers/lorax.py @@ -45,7 +45,7 @@ class LoraxWrapper(object): if type(f_arg) is list: for item in f_arg: cmd_args.append("%s=%s" % (c_arg, item)) - if type(f_arg) is str: + elif type(f_arg) is str: cmd_args.append("%s=%s" % (c_arg, item)) else: raise Exception(