#4157 kiwi: Add support for overriding kiwi image file name format
Merged 8 months ago by tkopecek. Opened 8 months ago by ngompa.
ngompa/koji kiwi-bundle-format  into  master

file modified
+4
@@ -389,6 +389,8 @@ 

              '--description', os.path.join(os.path.basename(scmsrcdir), base_path),

              '--target-dir', target_dir,

          ])

+         for typeattr in self.opts.get('type_attr', [])::

+             cmd.extend(['--set-type-attr', typeattr])

          rv = broot.mock(['--cwd', broot.tmpdir(within=True), '--chroot', '--'] + cmd)

          if rv:

              raise koji.GenericError("Kiwi failed")
@@ -406,6 +408,8 @@ 

                 '--target-dir', target_dir,

                 '--bundle-dir', bundle_dir,

                 '--id', release]

+         if self.opts.get('result_bundle_name_format'):

+             cmd.extend(['--bundle-format', self.opts['result_bundle_name_format']])

          rv = broot.mock(['--cwd', broot.tmpdir(within=True), '--chroot', '--'] + cmd)

          if rv:

              raise koji.GenericError("Kiwi failed")

file modified
+8
@@ -28,6 +28,10 @@ 

      parser.add_option("--kiwi-profile", action="store", default=None,

                        help="Select profile from description file")

      parser.add_option("--type", help="Override default build type from description")

+     parser.add_option("--type-attr", action="append", default=[],

+                       help="Override default attributes for the build type from description. "

+                            "May be used multiple times.")

+     parser.add_option("--result-bundle-name-format", help="Override default bundle name format")

      parser.add_option("--make-prep", action="store_true", default=False,

                        help="Run 'make prep' in checkout before starting the build")

      parser.add_option("--can-fail", action="store", dest="optional_arches",
@@ -68,6 +72,10 @@ 

          kwargs['make_prep'] = True

      if options.type:

          kwargs['type'] = options.type

+     if options.type_attr:

+         kwargs['type_attr'] = options.type_attr

+     if options.result_bundle_name_format:

+         kwargs['result_bundle_name_format'] = options.result_bundle_name_format

      if options.arches:

          kwargs['arches'] = [canonArch(arch) for arch in options.arches]

      if options.repo:

file modified
+9 -1
@@ -17,13 +17,17 @@ 

  @export

  def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile=None,

                scratch=False, priority=None, make_prep=False, repos=None, release=None,

-               type=None):

+               type=None, type_attr=None, result_bundle_name_format=None):

      context.session.assertPerm('image')

      for i in [desc_url, desc_path, profile, release]:

          if i is not None:

              kojihub.convert_value(i, cast=str, check_only=True)

      if repos:

          kojihub.convert_value(repos, cast=list, check_only=True)

+     if type_attr:

+         kojihub.convert_value(type_attr, cast=list, check_only=True)

+     if result_bundle_name_format:

+         kojihub.convert_value(result_bundle_name_format, cast=str, check_only=True)

      kojihub.get_build_target(target, strict=True)

      if isinstance(arches, list):

          arches = " ".join(arches)
@@ -58,6 +62,10 @@ 

          opts['make_prep'] = True

      if type:

          opts['type'] = type

+     if type_attr:

+         opts['type_attr'] = type_attr

+     if result_bundle_name_format:

+         opts['result_bundle_name_format'] = result_bundle_name_format

      return kojihub.make_task('kiwiBuild',

                               [target, arches, desc_url, desc_path, opts],

                               **taskOpts)

In order to be able to support workflows where the exact structure
of the image filenames matter (e.g. for Linux distribution artifacts),
support optionally overriding the image file name structure.

This is on top of #4156, so once that's merged, this can be rebased on top.

This also fixes https://pagure.io/cloud-sig/issue/424

FYI: @adamwill, @kevin, @dcavalca, @davdunc, @tdawson

Both of these seem fine overall. Is there a point to keeping them separate?

Minor note. The type_attr case in the builder could be a touch simpler

if self.opts.get('type_attr'):
    for typeattr in self.opts.get('type_attr'):
        cmd.extend(['--set-type-attr', typeattr])

Using get when you've just checked for the key reads oddly. Plus, you could just have:

for typeattr in self.opts.get('type_attr', []):
    cmd.extend(['--set-type-attr', typeattr])

Breadcrumbs for eventual relnote:

In the hub plugin, the other options are type checked with kojihub.convert_value. These new ones should be also.

Both of these seem fine overall. Is there a point to keeping them separate?

I implemented them separately for different users, mainly. Makes it easy to cherry-pick selectively. :sweat_smile:

rebased onto 8a6857f

8 months ago

rebased onto 8a6857f

8 months ago

@mikem: I've addressed your feedback, could you please take a look now?

Looks fine to me also. Can we merge this so we can try and get properly-named Kiwi-built ISOs for F41 Beta?

Metadata Update from @tkopecek:
- Pull-request tagged with: no_qe

8 months ago

Commit 6ac3fef fixes this pull-request

Pull-Request has been merged by tkopecek

8 months ago

There is actually an obvious typo in this which was caught when building an RPM with the patch backported. I'll send a follow-up PR, but I guess it'd be nice if Koji at least had sanity-check CI...