PR#4157: kiwi: Add support for overriding kiwi image file name format

Merges #4157
https://pagure.io/koji/pull-request/4157

Fixes #4177
https://pagure.io/koji/issue/4177
This commit is contained in:
Tomas Kopecek 2024-08-21 09:35:51 +02:00
commit 6ac3fefbe3
3 changed files with 10 additions and 1 deletions

View file

@ -408,6 +408,8 @@ class KiwiCreateImageTask(BaseBuildTask):
'--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")

View file

@ -31,6 +31,7 @@ def handle_kiwi_build(goptions, session, args):
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",
@ -73,6 +74,8 @@ def handle_kiwi_build(goptions, session, args):
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:

View file

@ -17,7 +17,7 @@ koji.tasks.LEGACY_SIGNATURES['createKiwiImage'] = [
@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_attr=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:
@ -26,6 +26,8 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
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)
@ -62,6 +64,8 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
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)