Backport PR #4157 to support overriding Kiwi image file name format

epel9
Adam Williamson 6 months ago
parent d784aa6a45
commit 487e6dcdc6

@ -0,0 +1,82 @@
From b22449c553b344fd3a1ee7cb49c769754ddfa347 Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@velocitylimitless.com>
Date: Sun, 11 Aug 2024 14:42:31 -0400
Subject: [PATCH 1/2] kiwi: Add support for overriding image type attributes
This allows setting things like the volume and application IDs
for ISO builds.
---
plugins/builder/kiwi.py | 2 ++
plugins/cli/kiwi.py | 5 +++++
plugins/hub/kiwi.py | 6 +++++-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index a9d63cf0..99737f7c 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -389,6 +389,8 @@ class KiwiCreateImageTask(BaseBuildTask):
'--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")
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 6e965c05..7e3e9771 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -28,6 +28,9 @@ def handle_kiwi_build(goptions, session, args):
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("--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 +71,8 @@ def handle_kiwi_build(goptions, session, args):
kwargs['make_prep'] = True
if options.type:
kwargs['type'] = options.type
+ if options.type_attr:
+ kwargs['type_attr'] = options.type_attr
if options.arches:
kwargs['arches'] = [canonArch(arch) for arch in options.arches]
if options.repo:
diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py
index 7b0c2f05..852cbad1 100644
--- a/plugins/hub/kiwi.py
+++ b/plugins/hub/kiwi.py
@@ -17,13 +17,15 @@ 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=None, type_attr=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)
kojihub.get_build_target(target, strict=True)
if isinstance(arches, list):
arches = " ".join(arches)
@@ -58,6 +60,8 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
opts['make_prep'] = True
if type:
opts['type'] = type
+ if type_attr:
+ opts['type_attr'] = type_attr
return kojihub.make_task('kiwiBuild',
[target, arches, desc_url, desc_path, opts],
**taskOpts)
--
2.46.0

@ -0,0 +1,83 @@
From 06840501bd7b52ee38a7a0c337cadfbf4512fc5d Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@velocitylimitless.com>
Date: Sun, 11 Aug 2024 15:11:51 -0400
Subject: [PATCH 2/2] kiwi: Add support for overriding kiwi image file name
format
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.
---
plugins/builder/kiwi.py | 2 ++
plugins/cli/kiwi.py | 3 +++
plugins/hub/kiwi.py | 6 +++++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index 99737f7c..1b4a9481 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -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")
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 7e3e9771..f0172575 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -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:
diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py
index 852cbad1..15f352cc 100644
--- a/plugins/hub/kiwi.py
+++ b/plugins/hub/kiwi.py
@@ -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)
--
2.46.0

@ -9,7 +9,7 @@
Name: koji Name: koji
Version: 1.34.1 Version: 1.34.1
Release: 3%{?dist} Release: 4%{?dist}
# the included arch lib from yum's rpmUtils is GPLv2+ # the included arch lib from yum's rpmUtils is GPLv2+
License: LGPLv2 and GPLv2+ License: LGPLv2 and GPLv2+
Summary: Build system tools Summary: Build system tools
@ -30,6 +30,10 @@ Patch102: https://pagure.io/koji/pull-request/4013.patch
Patch103: https://pagure.io/koji/pull-request/4026.patch Patch103: https://pagure.io/koji/pull-request/4026.patch
# setup.py: Fix version retrieval on Python 3.13+ # setup.py: Fix version retrieval on Python 3.13+
Patch104: https://pagure.io/koji/pull-request/4100.patch Patch104: https://pagure.io/koji/pull-request/4100.patch
# kiwi image name override support, upstream but not released yet
# https://pagure.io/koji/pull-request/4157
Patch105: 0001-kiwi-Add-support-for-overriding-image-type-attribute.patch
Patch106: 0002-kiwi-Add-support-for-overriding-kiwi-image-file-name.patch
BuildArch: noarch BuildArch: noarch
Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release}
@ -362,6 +366,9 @@ done
%systemd_postun kojira.service %systemd_postun kojira.service
%changelog %changelog
* Thu Aug 22 2024 Adam Williamson <awilliam@redhat.com> - 1.34.1-4
- Backport PR #4157 to support overriding Kiwi image file name format
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.34.1-3 * Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.34.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

Loading…
Cancel
Save