PATCH - First attempt to enable Atomic ISO compose in pungi-koj
Adam Miller
maxamillion at fedoraproject.org
Mon May 4 17:39:25 UTC 2015
On Mon, Apr 27, 2015 at 8:10 AM, Adam Miller
<maxamillion at fedoraproject.org> wrote:
> On Fri, Apr 24, 2015 at 5:29 PM, Adam Miller
> <maxamillion at fedoraproject.org> wrote:
>> I've added a handful of parameters here to mirror the command that's
>> currently being done run-pungi.sh[0]
>>
>> The options can either be strings for single elements or lists for
>> multiples in the pungi-koji config.
>>
>> ====== BEGIN Example config
>> add_template = "/srv/pungi/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"
>> add_template_var = [
>> "ostree_osname=Fedora-Cloud_Atomic",
>> "ostree_ref=fedora-atomic/f22/x86_64/docker-host",
>> ]
>> add_arch_template =
>> "/srv/pungi/spin-kickstarts/atomic-installer/lorax-embed-repo.tmpl"
>> add_arch_template_var = [
>> "ostree_repo=http://compose-x86-01.phx2.fedoraproject.org/compose/atomic/",
>> "ostree_osname=Fedora-Cloud_Atomic",
>> "ostree_ref=fedora-atomic/f22/x86_64/docker-host",
>> ]
>> ===== END Example config
>>
>> I look forward to feedback.
>>
>> -AdamM
>>
>> [0] - https://git.fedorahosted.org/cgit/releng/tree/scripts/run-pungi#n67
>>
>> diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py
>> index 1a60607..cf32658 100644
>> --- a/pungi/phases/buildinstall.py
>> +++ b/pungi/phases/buildinstall.py
>> @@ -86,13 +86,19 @@ 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)
>> volid = get_volid(self.compose, arch)
>>
>> if buildinstall_method == "lorax":
>> - cmd = lorax.get_lorax_cmd(product, version, release,
>> repo_baseurl, output_dir, is_final=self.compose.supported,
>> buildarch=arch, volid=volid, nomacboot=True, noupgrade=noupgrade)
>> + cmd = lorax.get_lorax_cmd(product, version, release,
>> repo_baseurl, output_dir, is_final=self.compose.supported,
>> buildarch=arch, 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=arch, volid=volid)
>> else:
>> diff --git a/pungi/wrappers/lorax.py b/pungi/wrappers/lorax.py
>> index 80d7f9f..c462f7b 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,39 @@ 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_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)
>
>
> Paul Frields (stickster) pointed out to me on IRC that I duplicated
> the add_template_var if statement which was just a bad oversight on my
> part.... fixed patch below:
>
> -AdamM
>
> diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py
> index 1a60607..cf32658 100644
> --- a/pungi/phases/buildinstall.py
> +++ b/pungi/phases/buildinstall.py
> @@ -86,13 +86,19 @@ 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)
> volid = get_volid(self.compose, arch)
>
> if buildinstall_method == "lorax":
> - cmd = lorax.get_lorax_cmd(product, version, release,
> repo_baseurl, output_dir, is_final=self.compose.supported,
> buildarch=arch, volid=volid, nomacboot=True, noupgrade=noupgrade)
> + cmd = lorax.get_lorax_cmd(product, version, release,
> repo_baseurl, output_dir, is_final=self.compose.supported,
> buildarch=arch, 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=arch, volid=volid)
> else:
> diff --git a/pungi/wrappers/lorax.py b/pungi/wrappers/lorax.py
> index 80d7f9f..724ddc3 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)
bump? Anyone had a chance to look at this?
-AdamM
More information about the rel-eng
mailing list