From e6a9553e9c5850c8c1b9361f84f2f9dbb426ef4c Mon Sep 17 00:00:00 2001 From: Tomas Kopecek 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)