Backport PRs 4063 and 4184 (more kiwi fixes)

epel9
Adam Williamson 6 months ago
parent b912ffd10e
commit fa7d0ee69f

@ -0,0 +1,39 @@
From 694ac4148301ef1efb69fbef0072190e1671a356 Mon Sep 17 00:00:00 2001
From: Neal Gompa <neal@gompa.dev>
Date: Wed, 20 Mar 2024 12:45:17 -0400
Subject: [PATCH 1/6] kiwi: Only add buildroot repo if user repositories are
not defined
In general, we assume that if the user is specifying repositories,
the built-in one should not be used.
---
plugins/builder/kiwi.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index 369071ef..d5d4fbdc 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -351,12 +351,13 @@ class KiwiCreateImageTask(BaseBuildTask):
# user repos
repos = self.opts.get('repos', [])
- # buildroot repo
- path_info = koji.PathInfo(topdir=self.options.topurl)
- repopath = path_info.repo(repo_info['id'], target_info['build_tag_name'])
- baseurl = '%s/%s' % (repopath, arch)
- self.logger.debug('BASEURL: %s' % baseurl)
- repos.append(baseurl)
+ # buildroot repo if user repos not defined
+ if repos == []:
+ path_info = koji.PathInfo(topdir=self.options.topurl)
+ repopath = path_info.repo(repo_info['id'], target_info['build_tag_name'])
+ baseurl = '%s/%s' % (repopath, arch)
+ self.logger.debug('BASEURL: %s' % baseurl)
+ repos.append(baseurl)
base_path = os.path.dirname(desc_path)
if opts.get('make_prep'):
--
2.46.0

@ -0,0 +1,75 @@
From b13d481d56059fd51a8f9109d0d64d3f11fcbccc Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Mon, 25 Mar 2024 11:33:41 +0100
Subject: [PATCH 2/6] kiwi: option for not using buildroot repo
Related: https://pagure.io/koji/issue/4062
---
plugins/builder/kiwi.py | 3 +--
plugins/cli/kiwi.py | 6 ++++++
plugins/hub/kiwi.py | 4 +++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index d5d4fbdc..a878ad56 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -351,8 +351,7 @@ class KiwiCreateImageTask(BaseBuildTask):
# user repos
repos = self.opts.get('repos', [])
- # buildroot repo if user repos not defined
- if repos == []:
+ if self.opts.get('use_buildroot_repo', True):
path_info = koji.PathInfo(topdir=self.options.topurl)
repopath = path_info.repo(repo_info['id'], target_info['build_tag_name'])
baseurl = '%s/%s' % (repopath, arch)
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index f0172575..6611df73 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -34,6 +34,10 @@ def handle_kiwi_build(goptions, session, args):
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("--no-buildroot-repo", action="store_false",
+ dest="use_buildroot_repo", default=True,
+ help="Don't add buildroot repo to installation sources, "
+ "use only those provided by --repo option.")
parser.add_option("--can-fail", action="store", dest="optional_arches",
metavar="ARCH1,ARCH2,...", default="",
help="List of archs which are not blocking for build "
@@ -80,6 +84,8 @@ def handle_kiwi_build(goptions, session, args):
kwargs['arches'] = [canonArch(arch) for arch in options.arches]
if options.repo:
kwargs['repos'] = options.repo
+ if not options.use_buildroot_repo:
+ kwargs['use_buildroot_repo'] = False
task_id = session.kiwiBuild(**kwargs)
diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py
index 15f352cc..cd03ab42 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, result_bundle_name_format=None):
+ type=None, type_attr=None, result_bundle_name_format=None, use_buildroot_repo=True):
context.session.assertPerm('image')
for i in [desc_url, desc_path, profile, release]:
if i is not None:
@@ -62,6 +62,8 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
opts['make_prep'] = True
if type:
opts['type'] = type
+ if not use_buildroot_repo:
+ opts['use_buildroot_repo'] = False
if type_attr:
opts['type_attr'] = type_attr
if result_bundle_name_format:
--
2.46.0

@ -0,0 +1,72 @@
From dd594826f21a5b6b493ffd360745dc3b4af5c978 Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Thu, 9 May 2024 12:04:33 +0200
Subject: [PATCH 3/6] Don't use buildroot repo by default
---
plugins/builder/kiwi.py | 2 +-
plugins/cli/kiwi.py | 12 ++++++------
plugins/hub/kiwi.py | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index a878ad56..2ac5cb3b 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -351,7 +351,7 @@ class KiwiCreateImageTask(BaseBuildTask):
# user repos
repos = self.opts.get('repos', [])
- if self.opts.get('use_buildroot_repo', True):
+ if self.opts.get('use_buildroot_repo', False):
path_info = koji.PathInfo(topdir=self.options.topurl)
repopath = path_info.repo(repo_info['id'], target_info['build_tag_name'])
baseurl = '%s/%s' % (repopath, arch)
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 6611df73..840e7539 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -34,10 +34,10 @@ def handle_kiwi_build(goptions, session, args):
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("--no-buildroot-repo", action="store_false",
- dest="use_buildroot_repo", default=True,
- help="Don't add buildroot repo to installation sources, "
- "use only those provided by --repo option.")
+ parser.add_option("--buildroot-repo", action="store_false",
+ dest="use_buildroot_repo", default=False,
+ help="Add buildroot repo to installation sources. This is off by default, "
+ "but uf there is no --repo used, it will be turned on automatically.")
parser.add_option("--can-fail", action="store", dest="optional_arches",
metavar="ARCH1,ARCH2,...", default="",
help="List of archs which are not blocking for build "
@@ -84,8 +84,8 @@ def handle_kiwi_build(goptions, session, args):
kwargs['arches'] = [canonArch(arch) for arch in options.arches]
if options.repo:
kwargs['repos'] = options.repo
- if not options.use_buildroot_repo:
- kwargs['use_buildroot_repo'] = False
+ if options.use_buildroot_repo or not options.repo:
+ kwargs['use_buildroot_repo'] = True
task_id = session.kiwiBuild(**kwargs)
diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py
index cd03ab42..81852e52 100644
--- a/plugins/hub/kiwi.py
+++ b/plugins/hub/kiwi.py
@@ -62,8 +62,8 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
opts['make_prep'] = True
if type:
opts['type'] = type
- if not use_buildroot_repo:
- opts['use_buildroot_repo'] = False
+ if use_buildroot_repo:
+ opts['use_buildroot_repo'] = True
if type_attr:
opts['type_attr'] = type_attr
if result_bundle_name_format:
--
2.46.0

@ -0,0 +1,53 @@
From 810836944ad9aaf28c935e14db4405b96201ed55 Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Mon, 13 May 2024 11:02:53 +0200
Subject: [PATCH 4/6] version check + typo fixes
---
plugins/cli/kiwi.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 840e7539..8f8addaf 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -7,6 +7,7 @@ from koji_cli.lib import (
_running_in_bg,
activate_session,
watch_tasks,
+ warn,
)
@@ -34,10 +35,10 @@ def handle_kiwi_build(goptions, session, args):
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("--buildroot-repo", action="store_false",
+ parser.add_option("--buildroot-repo", action="store_true",
dest="use_buildroot_repo", default=False,
help="Add buildroot repo to installation sources. This is off by default, "
- "but uf there is no --repo used, it will be turned on automatically.")
+ "but if there is no --repo used, it will be turned on automatically.")
parser.add_option("--can-fail", action="store", dest="optional_arches",
metavar="ARCH1,ARCH2,...", default="",
help="List of archs which are not blocking for build "
@@ -85,7 +86,14 @@ def handle_kiwi_build(goptions, session, args):
if options.repo:
kwargs['repos'] = options.repo
if options.use_buildroot_repo or not options.repo:
- kwargs['use_buildroot_repo'] = True
+ if not options.repo:
+ warn("no repos given, using buildroot repo")
+ if session.hub_version >= (1, 35, 0):
+ # for older plugin versions it is the default behaviour
+ # and option doesn't exist
+ kwargs['use_buildroot_repo'] = True
+ if session.hub_version < (1, 35, 0):
+ warn("hub version is < 1.35, buildroot repo is always used in addition to specified repos")
task_id = session.kiwiBuild(**kwargs)
--
2.46.0

@ -0,0 +1,38 @@
From 0e43634af51842f92da3911899d0d10f4b544a51 Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Wed, 15 May 2024 09:26:36 +0200
Subject: [PATCH 5/6] improve warnings for older hub
---
plugins/cli/kiwi.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 8f8addaf..02958373 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -85,15 +85,14 @@ def handle_kiwi_build(goptions, session, args):
kwargs['arches'] = [canonArch(arch) for arch in options.arches]
if options.repo:
kwargs['repos'] = options.repo
- if options.use_buildroot_repo or not options.repo:
- if not options.repo:
- warn("no repos given, using buildroot repo")
- if session.hub_version >= (1, 35, 0):
- # for older plugin versions it is the default behaviour
- # and option doesn't exist
- kwargs['use_buildroot_repo'] = True
+
if session.hub_version < (1, 35, 0):
warn("hub version is < 1.35, buildroot repo is always used in addition to specified repos")
+ elif options.use_buildroot_repo:
+ kwargs['use_buildroot_repo'] = True
+ elif not options.repo:
+ warn("no repos given, using buildroot repo")
+ kwargs['use_buildroot_repo'] = True
task_id = session.kiwiBuild(**kwargs)
--
2.46.0

@ -0,0 +1,146 @@
From a5dd7950434e4ff8dc37d77803f23dcb480aaa4b Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@velocitylimitless.com>
Date: Mon, 26 Aug 2024 10:02:43 -0400
Subject: [PATCH 6/6] kiwi: Add support for overriding version and releasever
This allows for kiwi descriptions that are compatible across
multiple targets to be easily used without needless modifications.
Additionally, it allows for custom values when preparing milestone
releases without needlessly modifying the descriptions.
---
plugins/builder/kiwi.py | 15 +++++++++++----
plugins/cli/kiwi.py | 6 ++++++
plugins/hub/kiwi.py | 9 +++++++--
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index 2ac5cb3b..f222dec1 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -103,6 +103,8 @@ class KiwiBuildTask(BuildImageTask):
name = "%s-%s" % (name, opts.get('profile', default_profile))
bld_info = {}
+ if opts.get('version'):
+ version = opts['version']
if opts.get('release'):
release = opts['release']
else:
@@ -188,7 +190,7 @@ class KiwiCreateImageTask(BaseBuildTask):
Methods = ['createKiwiImage']
_taskWeight = 2.0
- def prepareDescription(self, desc_path, name, version, repos, arch):
+ def prepareDescription(self, desc_path, name, version, repos, repo_releasever, arch):
# XML errors should have already been caught by parent task
newxml = xml.dom.minidom.parse(desc_path) # nosec
image = newxml.getElementsByTagName('image')[0]
@@ -229,11 +231,15 @@ class KiwiCreateImageTask(BaseBuildTask):
image.setAttribute('name', name)
preferences = image.getElementsByTagName('preferences')[0]
+
+ # Handle version and release-version
+ preferences.getElementsByTagName('version')[0].childNodes[0].data = version
try:
- preferences.getElementsByTagName('release-version')[0].childNodes[0].data = version
+ preferences.getElementsByTagName('release-version')[0].childNodes[0].data \
+ = repo_releasever
except IndexError:
releasever_node = newxml.createElement('release-version')
- text = newxml.createTextNode(version)
+ text = newxml.createTextNode(repo_releasever)
releasever_node.appendChild(text)
preferences.appendChild(releasever_node)
@@ -357,6 +363,7 @@ class KiwiCreateImageTask(BaseBuildTask):
baseurl = '%s/%s' % (repopath, arch)
self.logger.debug('BASEURL: %s' % baseurl)
repos.append(baseurl)
+ repo_releasever = self.opts.get('repo_releasever', version)
base_path = os.path.dirname(desc_path)
if opts.get('make_prep'):
@@ -368,7 +375,7 @@ class KiwiCreateImageTask(BaseBuildTask):
raise koji.GenericError("Preparation step failed")
path = os.path.join(scmsrcdir, desc_path)
- desc, types = self.prepareDescription(path, name, version, repos, arch)
+ desc, types = self.prepareDescription(path, name, version, repos, repo_releasever, arch)
self.uploadFile(desc)
target_dir = '/builddir/result/image'
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 02958373..9d177ac9 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -19,11 +19,13 @@ def handle_kiwi_build(goptions, session, args):
parser = OptionParser(usage=usage)
parser.add_option("--scratch", action="store_true", default=False,
help="Perform a scratch build")
+ parser.add_option("--version", help="Override default version of the output image")
parser.add_option("--release", help="Release of the output image")
parser.add_option("--repo", action="append",
help="Specify a repo that will override the repo used to install "
"RPMs in the image. May be used multiple times. The "
"build tag repo associated with the target is the default.")
+ parser.add_option("--repo-releasever", help="Override default releasever of the output image")
parser.add_option("--noprogress", action="store_true",
help="Do not display progress of the upload")
parser.add_option("--kiwi-profile", action="store", default=None,
@@ -71,6 +73,8 @@ def handle_kiwi_build(goptions, session, args):
if arch]
if options.kiwi_profile:
kwargs['profile'] = options.kiwi_profile
+ if options.version:
+ kwargs['version'] = options.version
if options.release:
kwargs['release'] = options.release
if options.make_prep:
@@ -85,6 +89,8 @@ def handle_kiwi_build(goptions, session, args):
kwargs['arches'] = [canonArch(arch) for arch in options.arches]
if options.repo:
kwargs['repos'] = options.repo
+ if options.repo_releasever:
+ kwargs['repo_releasever'] = options.repo_releasever
if session.hub_version < (1, 35, 0):
warn("hub version is < 1.35, buildroot repo is always used in addition to specified repos")
diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py
index 81852e52..4aeb1048 100644
--- a/plugins/hub/kiwi.py
+++ b/plugins/hub/kiwi.py
@@ -17,9 +17,10 @@ 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, result_bundle_name_format=None, use_buildroot_repo=True):
+ type=None, type_attr=None, result_bundle_name_format=None, use_buildroot_repo=True,
+ version=None, repo_releasever=None):
context.session.assertPerm('image')
- for i in [desc_url, desc_path, profile, release]:
+ for i in [desc_url, desc_path, profile, version, release, repo_releasever]:
if i is not None:
kojihub.convert_value(i, cast=str, check_only=True)
if repos:
@@ -52,12 +53,16 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
opts['scratch'] = True
if profile:
opts['profile'] = profile
+ if version:
+ opts['version'] = version
if release:
opts['release'] = release
if optional_arches:
opts['optional_arches'] = optional_arches
if repos:
opts['repos'] = repos
+ if repo_releasever:
+ opts['repo_releasever'] = repo_releasever
if make_prep:
opts['make_prep'] = True
if type:
--
2.46.0

@ -9,7 +9,7 @@
Name: koji Name: koji
Version: 1.34.1 Version: 1.34.1
Release: 4%{?dist} Release: 5%{?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
@ -37,6 +37,16 @@ Patch106: 0002-kiwi-Add-support-for-overriding-kiwi-image-file-name.patch
# Fix a typo in the image-type-attribute patch # Fix a typo in the image-type-attribute patch
# https://pagure.io/koji/pull-request/4181 # https://pagure.io/koji/pull-request/4181
Patch107: 0001-Fix-a-typo-in-the-kiwi-image-type-attribute-override.patch Patch107: 0001-Fix-a-typo-in-the-kiwi-image-type-attribute-override.patch
# kiwi: only add buildroot repo if user repositories are not defined
# https://pagure.io/koji/pull-request/4063
Patch108: 0001-kiwi-Only-add-buildroot-repo-if-user-repositories-ar.patch
Patch109: 0002-kiwi-option-for-not-using-buildroot-repo.patch
Patch110: 0003-Don-t-use-buildroot-repo-by-default.patch
Patch111: 0004-version-check-typo-fixes.patch
Patch112: 0005-improve-warnings-for-older-hub.patch
# Allow overriding version and releasever for kiwi
# https://pagure.io/koji/pull-request/4184
Patch113: 0006-kiwi-Add-support-for-overriding-version-and-releasev.patch
BuildArch: noarch BuildArch: noarch
Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release} Requires: python%{python3_pkgversion}-%{name} = %{version}-%{release}
@ -369,6 +379,9 @@ done
%systemd_postun kojira.service %systemd_postun kojira.service
%changelog %changelog
* Mon Aug 26 2024 Adam Williamson <awilliam@redhat.com> - 1.34.1-5
- Backport PR #4184 to support overriding version and releasever for Kiwi
* Thu Aug 22 2024 Adam Williamson <awilliam@redhat.com> - 1.34.1-4 * Thu Aug 22 2024 Adam Williamson <awilliam@redhat.com> - 1.34.1-4
- Backport PR #4157 to support overriding Kiwi image file name format - Backport PR #4157 to support overriding Kiwi image file name format

Loading…
Cancel
Save