#1740 Kiwi: translate virtualbox and azure productmd formats
Merged a year ago by lsedlar. Opened a year ago by adamwill.
adamwill/pungi kiwi-format-translate  into  master

file modified
+3 -3
@@ -34,12 +34,12 @@ 

      "rhevm-ova": ["rhevm.ova"],

      "tar-gz": ["tar.gz"],

      "vagrant-hyperv": ["vagrant-hyperv.box"],

-     "vagrant-libvirt": ["vagrant-libvirt.box", "vagrant.libvirt.box"],

-     "vagrant-virtualbox": ["vagrant-virtualbox.box", "vagrant.virtualbox.box"],

+     "vagrant-libvirt": ["vagrant-libvirt.box"],

+     "vagrant-virtualbox": ["vagrant-virtualbox.box"],

      "vagrant-vmware-fusion": ["vagrant-vmware-fusion.box"],

      "vdi": ["vdi"],

      "vmdk": ["vmdk"],

-     "vpc": ["vhd", "vhdfixed"],

+     "vpc": ["vhd"],

      "vhd-compressed": ["vhd.gz", "vhd.xz"],

      "vsphere-ova": ["vsphere.ova"],

  }

file modified
+16 -5
@@ -11,6 +11,12 @@ 

  from ..wrappers import kojiwrapper

  from .image_build import EXTENSIONS

  

+ KIWIEXTENSIONS = [

+     ("vhd-compressed", ["vhdfixed.xz"], "vhd.xz"),

+     ("vagrant-libvirt", ["vagrant.libvirt.box"], "vagrant-libvirt.box"),

+     ("vagrant-virtualbox", ["vagrant.virtualbox.box"], "vagrant-virtualbox.box"),

+ ]

+ 

  

  class KiwiBuildPhase(

      base.PhaseLoggerMixin, base.ImageConfigMixin, base.ConfigGuardedPhase
@@ -175,9 +181,9 @@ 

  

          for arch, paths in paths.items():

              for path in paths:

-                 type_, suffix = _find_suffix(path)

-                 if not suffix:

-                     # Path doesn't match any know type.

+                 type_, format_ = _find_type_and_format(path)

+                 if not format_:

+                     # Path doesn't match any known type.

                      continue

  

                  # image_dir is absolute path to which the image should be copied.
@@ -203,7 +209,7 @@ 

                  # Get the manifest type from the config if supplied, otherwise we

                  # determine the manifest type based on the koji output

                  img.type = type_

-                 img.format = suffix

+                 img.format = format_

                  img.path = os.path.join(rel_image_dir, filename)

                  img.mtime = util.get_mtime(image_dest)

                  img.size = util.get_file_size(image_dest)
@@ -219,9 +225,14 @@ 

          self.pool.log_info("[DONE ] %s (task id: %s)" % (msg, task_id))

  

  

- def _find_suffix(path):

+ def _find_type_and_format(path):

      for type_, suffixes in EXTENSIONS.items():

          for suffix in suffixes:

              if path.endswith(suffix):

                  return type_, suffix

+     # these are our kiwi-exclusive mappings for images whose extensions

+     # aren't quite the same as imagefactory

+     for type_, suffixes, format_ in KIWIEXTENSIONS:

+         if any(path.endswith(suffix) for suffix in suffixes):

+             return type_, format_

      return None, None

As discussed in
https://pagure.io/releng/failed-composes/issue/6047#comment-899622
the list of 'acceptable' types and formats (in productmd terms)
is locked down in productmd, we cannot just 'declare' new formats
in pungi as we kinda wound up doing by adding these Kiwi
extensions to the EXTENSIONS dict in image_build phase. So
instead, let's return the image_build phase to the way it was,
and add an additional layer of handling in kiwibuild phase for
these awkward cases, which 'translates' the file suffix to a
format productmd knows about already. This is actually how we
would rather behave anyway, because a Kiwi-produced
vagrant.libvirt.box file really is the same kind of thing as an
ImageFactory-produced vagrant-libvirt.box file; we want them to
have compatible metadata, we don't want them to look like
different things.

Signed-off-by: Adam Williamson awilliam@redhat.com

rebased onto e1aed1dfb92ce2ed435ee85b9042104f0032ac80

a year ago

rebased onto b653493

a year ago

I borrowed the tests from https://pagure.io/pungi/pull-request/1739 to test this, rebasing this on top of that PR, fixing up a couple of things (mentioned there), and then changing the test from having .qcow2 images to having .vagrant.libvirt.box images and expecting the appropriate type and format. It passed.

Commit 8fb694f fixes this pull-request

Pull-Request has been merged by lsedlar

a year ago