PR#4063: kiwi: Only add buildroot repo if user repositories are not defined

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

Fixes #4062
Related: https://pagure.io/koji/issue/4062
This commit is contained in:
Tomas Kopecek 2024-08-26 14:34:18 +02:00
commit e18e4006cc
3 changed files with 22 additions and 7 deletions

View file

@ -351,12 +351,12 @@ 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)
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)
self.logger.debug('BASEURL: %s' % baseurl)
repos.append(baseurl)
base_path = os.path.dirname(desc_path)
if opts.get('make_prep'):

View file

@ -7,6 +7,7 @@ from koji_cli.lib import (
_running_in_bg,
activate_session,
watch_tasks,
warn,
)
@ -34,6 +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_true",
dest="use_buildroot_repo", default=False,
help="Add buildroot repo to installation sources. This is off by default, "
"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 "
@ -81,6 +86,14 @@ def handle_kiwi_build(goptions, session, args):
if options.repo:
kwargs['repos'] = options.repo
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)
if not goptions.quiet:

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, 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 use_buildroot_repo:
opts['use_buildroot_repo'] = True
if type_attr:
opts['type_attr'] = type_attr
if result_bundle_name_format: