Add option to use repos from kickstart for livemedia builds

Fixes: https://pagure.io/koji/issue/2260
This commit is contained in:
Brendan Reilly 2020-11-06 14:09:02 -05:00 committed by Tomas Kopecek
parent 6141a756af
commit b97813d6e2
3 changed files with 24 additions and 19 deletions

View file

@ -3023,25 +3023,26 @@ class ImageTask(BaseTaskHandler):
# in the kickstart file. If --repo wasn't specified, then we use the
# repo associated with the target passed in initially.
repo_class = kscontrol.dataMap[self.ks.version]['RepoData']
self.ks.handler.repo.repoList = [] # delete whatever the ks file told us
if opts.get('repo'):
user_repos = opts['repo']
if isinstance(user_repos, six.string_types):
user_repos = user_repos.split(',')
index = 0
for user_repo in user_repos:
if not opts.get('ksrepo'):
self.ks.handler.repo.repoList = [] # delete whatever the ks file told us
if opts.get('repo'):
user_repos = opts['repo']
if isinstance(user_repos, six.string_types):
user_repos = user_repos.split(',')
index = 0
for user_repo in user_repos:
self.ks.handler.repo.repoList.append(repo_class(
baseurl=user_repo, name='koji-override-%i' % index))
index += 1
else:
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)
self.ks.handler.repo.repoList.append(repo_class(
baseurl=user_repo, name='koji-override-%i' % index))
index += 1
else:
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)
self.ks.handler.repo.repoList.append(repo_class(
baseurl=baseurl, name='koji-%s-%i' % (target_info['build_tag_name'],
repo_info['id'])))
baseurl=baseurl, name='koji-%s-%i' % (target_info['build_tag_name'],
repo_info['id'])))
# inject url if provided
if opts.get('install_tree_url'):
self.ks.handler.url(url=opts['install_tree_url'])

View file

@ -5703,6 +5703,8 @@ def handle_spin_livemedia(options, session, args):
'default templates.'))
parser.add_option('--nomacboot', action="store_true",
help=_("Pass the nomacboot option to livemedia-creator"))
parser.add_option('--ksrepo', action="store_true",
help=_("Do not overwrite repos in the kickstart"))
(task_options, args) = parser.parse_args(args)
# Make sure the target and kickstart is specified.
@ -6085,7 +6087,7 @@ def _build_image(options, task_opts, session, args, img_type):
'format', 'install_tree_url', 'isoname', 'ksurl',
'ksversion', 'release', 'repo', 'scratch', 'skip_tag',
'specfile', 'vcpu', 'vmem', 'volid', 'optional_arches',
'lorax_dir', 'lorax_url', 'nomacboot',
'lorax_dir', 'lorax_url', 'nomacboot', 'ksrepo',
]
for opt in passthru_opts:
val = getattr(task_opts, opt, None)

View file

@ -38,6 +38,7 @@ LIVEMEDIA_OPTIONS = {
"lorax_dir": None,
"lorax_url": None,
"nomacboot": False,
"ksrepo": False,
"optional_arches": None,
"volid": None,
}
@ -424,6 +425,7 @@ Options:
templates that are to be used to override the default
templates.
--nomacboot Pass the nomacboot option to livemedia-creator
--ksrepo Do not overwrite repos in the kickstart
""" % (self.progname))