Backport more fixes for kiwibuild command for CBS

epel9
Neal Gompa 2 years ago
parent 5e3c5b5b72
commit 6292e1b4de

@ -0,0 +1,35 @@
From 18bbb5b21d4da8120fb9f3193248dd6faa915222 Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Oct 17 2022 12:39:48 +0000
Subject: fix include path
Related: https://pagure.io/koji/issue/3553
---
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index 42aa707..abb5511 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -197,16 +197,17 @@ class KiwiCreateImageTask(BaseBuildTask):
for inc_node in image.getElementsByTagName('include'):
path = inc_node.getAttribute('from')
if path.startswith('this://'):
- path = koji.util.joinpath(desc_path, path[7:])
+ path = koji.util.joinpath(os.path.dirname(desc_path), path[7:])
else:
# we want to reject other protocols, e.g. file://, https://
# reachingoutside of repo
raise koji.GenericError(f"Unhandled include protocol in include path: {path}.")
inc = xml.dom.minidom.parse(path) # nosec
# every included xml has image root element again
- for node in inc.getElementsByTagName('image').childNodes:
+ for node in list(inc.getElementsByTagName('image')[0].childNodes):
if node.nodeName != 'repository':
image.appendChild(node)
+ image.removeChild(inc_node)
# remove remaining old repos
for old_repo in image.getElementsByTagName('repository'):

@ -0,0 +1,155 @@
From e6a9553e9c5850c8c1b9361f84f2f9dbb426ef4c Mon Sep 17 00:00:00 2001
From: Tomas Kopecek <tkopecek@redhat.com>
Date: Oct 25 2022 10:25:49 +0000
Subject: kiwi: propagate --type option
Related: https://pagure.io/koji/issue/3556
---
diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py
index 42aa707..7d6f6e7 100644
--- a/plugins/builder/kiwi.py
+++ b/plugins/builder/kiwi.py
@@ -325,11 +325,11 @@ class KiwiCreateImageTask(BaseBuildTask):
'user_id': self.taskinfo['owner'],
'channel': self.session.getChannel(self.taskinfo['channel_id'],
strict=True)['name'],
- 'scratch': self.opts.get('scratch')
+ 'scratch': self.opts.get('scratch', False)
})
logfile = os.path.join(self.workdir, 'checkout-%s.log' % arch)
self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(),
- build_tag=build_tag, scratch=self.opts.get('scratch'))
+ build_tag=build_tag, scratch=self.opts.get('scratch', False))
scmdir = broot.tmpdir()
koji.ensuredir(scmdir)
scmsrcdir = scm.checkout(scmdir, self.session,
@@ -337,7 +337,7 @@ class KiwiCreateImageTask(BaseBuildTask):
self.run_callbacks("postSCMCheckout",
scminfo=scm.get_info(),
build_tag=build_tag,
- scratch=self.opts.get('scratch'),
+ scratch=self.opts.get('scratch', False),
srcdir=scmsrcdir)
# user repos
@@ -365,6 +365,8 @@ class KiwiCreateImageTask(BaseBuildTask):
cmd = ['kiwi-ng']
if self.opts.get('profile'):
cmd.extend(['--profile', self.opts['profile']])
+ if self.opts.get('type'):
+ cmd.extend(['--type', self.opts['type']])
target_dir = '/builddir/result/image'
cmd.extend([
'--kiwi-file', os.path.basename(desc), # global option for image/system commands
diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py
index 8786b13..07125d7 100644
--- a/plugins/cli/kiwi.py
+++ b/plugins/cli/kiwi.py
@@ -27,6 +27,7 @@ def handle_kiwi_build(goptions, session, args):
help="Do not display progress of the upload")
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("--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",
@@ -46,28 +47,33 @@ def handle_kiwi_build(goptions, session, args):
target, scm, path = args
activate_session(session, goptions)
-
kwargs = {
- 'scratch': options.scratch,
- 'optional_arches': [canonArch(arch)
- for arch in options.optional_arches.split(',')
- if arch],
- 'profile': options.kiwi_profile,
- 'release': options.release,
- 'make_prep': options.make_prep,
+ 'arches': [],
+ 'target': target,
+ 'desc_url': scm,
+ 'desc_path': path,
}
-
- arches = []
+ if options.scratch:
+ kwargs['scratch'] = True
+ if options.optional_arches:
+ kwargs['optional_arches'] = [
+ canonArch(arch)
+ for arch in options.optional_arches.split(',')
+ if arch]
+ if options.kiwi_profile:
+ kwargs['profile'] = options.kiwi_profile,
+ if options.release:
+ kwargs['release'] = options.release
+ if options.make_prep:
+ kwargs['make_prep'] = True
+ if options.type:
+ kwargs['type'] = options.type
if options.arches:
- arches = [canonArch(arch) for arch in options.arches]
+ kwargs['arches'] = [canonArch(arch) for arch in options.arches]
+ if options.repo:
+ kwargs['repos'] = options.repo
- task_id = session.kiwiBuild(
- target=target,
- arches=arches,
- desc_url=scm,
- desc_path=path,
- repos=options.repo,
- **kwargs)
+ task_id = session.kiwiBuild(**kwargs)
if not goptions.quiet:
print("Created task: %d" % task_id)
diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py
index 79da38a..17b8e8e 100644
--- a/plugins/hub/kiwi.py
+++ b/plugins/hub/kiwi.py
@@ -16,7 +16,8 @@ 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):
+ scratch=False, priority=None, make_prep=False, repos=None, release=None,
+ type=None):
context.session.assertPerm('image')
for i in [desc_url, desc_path, profile, release]:
if i is not None:
@@ -42,14 +43,21 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile
'only admins may create high-priority tasks')
taskOpts['priority'] = koji.PRIO_DEFAULT + priority
- opts = {
- 'optional_arches': optional_arches,
- 'profile': profile,
- 'scratch': bool(scratch),
- 'release': release,
- 'repos': repos or [],
- 'make_prep': bool(make_prep),
- }
+ opts = {}
+ if scratch:
+ opts['scratch'] = True
+ if profile:
+ opts['profile'] = profile
+ if release:
+ opts['release'] = release
+ if optional_arches:
+ opts['optional_arches'] = optional_arches,
+ if repos:
+ opts['repos'] = repos
+ if make_prep:
+ opts['make_prep'] = True
+ if type:
+ opts['type'] = type
return kojihub.make_task('kiwiBuild',
[target, arches, desc_url, desc_path, opts],
**taskOpts)

@ -9,13 +9,19 @@
Name: koji Name: koji
Version: 1.30.1 Version: 1.30.1
Release: 1%{?dist} Release: 2%{?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
URL: https://pagure.io/koji/ URL: https://pagure.io/koji/
Source0: https://releases.pagure.org/koji/koji-%{version}.tar.bz2 Source0: https://releases.pagure.org/koji/koji-%{version}.tar.bz2
# Proposed upstream
## From: https://pagure.io/koji/pull-request/3555
Patch1: 3555.patch
## From: https://pagure.io/koji/pull-request/3558
Patch2: 3558.patch
# Not upstreamable # Not upstreamable
Patch100: fedora-config.patch Patch100: fedora-config.patch
@ -347,6 +353,9 @@ done
%systemd_postun kojira.service %systemd_postun kojira.service
%changelog %changelog
* Tue Oct 25 2022 Neal Gompa <ngompa@fedoraproject.org> - 1.30.1-2
- Backport more fixes for kiwibuild command for CBS
* Wed Oct 12 2022 Kevin Fenzi <kevin@scrye.com> - 1.30.1-1 * Wed Oct 12 2022 Kevin Fenzi <kevin@scrye.com> - 1.30.1-1
- Update to 1.30.1. Fixed rhbz#2133004 - Update to 1.30.1. Fixed rhbz#2133004

Loading…
Cancel
Save