Allow generating separate src repo for build repos

Fixes #1266
This commit is contained in:
Mikolaj Izdebski 2019-02-20 23:03:50 +01:00 committed by Mike McLean
parent bcece35a21
commit 3d058c50db
6 changed files with 35 additions and 17 deletions

View file

@ -5011,13 +5011,15 @@ class NewRepoTask(BaseTaskHandler):
Methods = ['newRepo']
_taskWeight = 0.1
def handler(self, tag, event=None, src=False, debuginfo=False):
def handler(self, tag, event=None, src=False, debuginfo=False, separate_src=False):
tinfo = self.session.getTag(tag, strict=True, event=event)
kwargs = {}
if event is not None:
kwargs['event'] = event
if src:
kwargs['with_src'] = True
if separate_src:
kwargs['with_separate_src'] = True
if debuginfo:
kwargs['with_debuginfo'] = True
repo_id, event_id = self.session.host.repoInit(tinfo['id'], **kwargs)

View file

@ -7051,7 +7051,8 @@ def handle_regen_repo(options, session, args):
parser.add_option("--target", action="store_true", help=_("Interpret the argument as a build target name"))
parser.add_option("--nowait", action="store_true", help=_("Don't wait on for regen to finish"))
parser.add_option("--debuginfo", action="store_true", help=_("Include debuginfo rpms in repo"))
parser.add_option("--source", "--src", action="store_true", help=_("Include source rpms in the repo"))
parser.add_option("--source", "--src", action="store_true", help=_("Include source rpms in each of repos"))
parser.add_option("--separate-source", "--separate-src", action="store_true", help=_("Include source rpms in separate src repo"))
(suboptions, args) = parser.parse_args(args)
if len(args) == 0:
parser.error(_("A tag name must be specified"))
@ -7087,6 +7088,8 @@ def handle_regen_repo(options, session, args):
repo_opts['debuginfo'] = True
if suboptions.source:
repo_opts['src'] = True
if suboptions.separate_source:
repo_opts['separate_src'] = True
task_id = session.newRepo(tag, **repo_opts)
print("Regenerating repo for tag: %s" % tag)
print("Created task: %d" % task_id)

View file

@ -2377,7 +2377,7 @@ def maven_tag_archives(tag_id, event_id=None, inherit=True):
yield archive
return _iter_archives()
def repo_init(tag, with_src=False, with_debuginfo=False, event=None):
def repo_init(tag, with_src=False, with_debuginfo=False, event=None, with_separate_src=False):
"""Create a new repo entry in the INIT state, return full repo data
Returns a dictionary containing
@ -2387,9 +2387,11 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None):
state = koji.REPO_INIT
tinfo = get_tag(tag, strict=True, event=event)
koji.plugin.run_callbacks('preRepoInit', tag=tinfo, with_src=with_src, with_debuginfo=with_debuginfo,
event=event, repo_id=None)
event=event, repo_id=None, with_separate_src=with_separate_src)
tag_id = tinfo['id']
repo_arches = {}
if with_separate_src:
repo_arches['src'] = 1
if tinfo['arches']:
for arch in tinfo['arches'].split():
arch = koji.canonArch(arch)
@ -2464,6 +2466,8 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None):
if with_src:
for repoarch in repo_arches:
pkglist[repoarch].write(relpath)
if with_separate_src:
pkglist[arch].write(relpath)
elif arch == 'noarch':
for repoarch in repo_arches:
pkglist[repoarch].write(relpath)
@ -2518,7 +2522,7 @@ def repo_init(tag, with_src=False, with_debuginfo=False, event=None):
_write_maven_repo_metadata(artifact_dir, artifacts)
koji.plugin.run_callbacks('postRepoInit', tag=tinfo, with_src=with_src, with_debuginfo=with_debuginfo,
event=event, repo_id=repo_id)
event=event, repo_id=repo_id, with_separate_src=with_separate_src)
return [repo_id, event_id]
def _write_maven_repo_metadata(destdir, artifacts):
@ -2566,7 +2570,8 @@ def dist_repo_init(tag, keys, task_opts):
# note: we need to match args from the other preRepoInit callback
koji.plugin.run_callbacks('preRepoInit', tag=tinfo, with_src=False,
with_debuginfo=False, event=event, repo_id=None,
dist=True, keys=keys, arches=arches, task_opts=task_opts)
dist=True, keys=keys, arches=arches, task_opts=task_opts,
with_separate_src=False)
if not event:
event = get_event()
repo_id = nextval('repo_id_seq')
@ -2604,7 +2609,7 @@ def dist_repo_init(tag, keys, task_opts):
koji.plugin.run_callbacks('postRepoInit', tag=tinfo, with_src=False,
with_debuginfo=False, event=event, repo_id=repo_id,
dist=True, keys=keys, arches=arches, task_opts=task_opts,
repodir=repodir)
repodir=repodir, with_reparate_src=False)
return repo_id, event
@ -10658,7 +10663,7 @@ class RootExports(object):
task_opts['event'] = event_id
return make_task('distRepo', [tag, repo_id, keys, task_opts], priority=15, channel='createrepo')
def newRepo(self, tag, event=None, src=False, debuginfo=False):
def newRepo(self, tag, event=None, src=False, debuginfo=False, separate_src=False):
"""Create a newRepo task. returns task id"""
if context.session.hasPerm('regen-repo'):
pass
@ -10669,6 +10674,8 @@ class RootExports(object):
opts['event'] = event
if src:
opts['src'] = True
if separate_src:
opts['separate_src'] = True
if debuginfo:
opts['debuginfo'] = True
args = koji.encode_args(tag, **opts)
@ -12855,11 +12862,11 @@ class HostExports(object):
return br.updateArchiveList(archives, project)
def repoInit(self, tag, with_src=False, with_debuginfo=False, event=None):
def repoInit(self, tag, with_src=False, with_debuginfo=False, event=None, with_separate_src=False):
"""Initialize a new repo for tag"""
host = Host()
host.verify()
return repo_init(tag, with_src=with_src, with_debuginfo=with_debuginfo, event=event)
return repo_init(tag, with_src=with_src, with_debuginfo=with_debuginfo, event=event, with_separate_src=with_separate_src)
def repoAddRPM(self, repo_id, path):
"""Add an uploaded rpm to a repo"""

View file

@ -200,7 +200,7 @@ LEGACY_SIGNATURES = {
[['builds', 'target', 'opts'], None, None, (None,)],
],
'newRepo' : [
[['tag', 'event', 'src', 'debuginfo'], None, None, (None, False, False)],
[['tag', 'event', 'src', 'debuginfo', 'separate_src'], None, None, (None, False, False, False)],
],
'createImage' : [
[['name', 'version', 'release', 'arch', 'target_info', 'build_tag', 'repo_info', 'inst_tree', 'opts'], None, None, (None,)],

View file

@ -168,11 +168,13 @@ class TestRegenRepo(utils.CliTestCase):
(Specify the --help global option for a list of other help options)
Options:
-h, --help show this help message and exit
--target Interpret the argument as a build target name
--nowait Don't wait on for regen to finish
--debuginfo Include debuginfo rpms in repo
--source, --src Include source rpms in the repo
-h, --help show this help message and exit
--target Interpret the argument as a build target name
--nowait Don't wait on for regen to finish
--debuginfo Include debuginfo rpms in repo
--source, --src Include source rpms in each of repos
--separate-source, --separate-src
Include source rpms in separate src repo
""" % self.progname)

View file

@ -739,6 +739,7 @@ class RepoManager(object):
debuginfo_pat = self.options.debuginfo_tags.split()
src_pat = self.options.source_tags.split()
separate_src_pat = self.options.separate_source_tags.split()
order = sorted(self.needed_tags.values(), key=lambda t: t['score'])
for tag in order:
if running_tasks >= self.options.max_repo_tasks:
@ -767,6 +768,8 @@ class RepoManager(object):
taskopts['debuginfo'] = True
if koji.util.multi_fnmatch(tagname, src_pat):
taskopts['src'] = True
if koji.util.multi_fnmatch(tagname, separate_src_pat):
taskopts['separate_src'] = True
maven = tag['taginfo']['maven_support']
if maven:
if running_tasks_maven >= self.options.max_repo_tasks_maven:
@ -901,6 +904,7 @@ def get_options():
defaults = {'with_src': False,
'debuginfo_tags': '',
'source_tags': '',
'separate_source_tags': '',
'ignore_tags': '',
'verbose': False,
'debug': False,
@ -941,7 +945,7 @@ def get_options():
'recent_tasks_lifetime')
str_opts = ('topdir', 'server', 'user', 'password', 'logfile', 'principal', 'keytab', 'krbservice',
'cert', 'ca', 'serverca', 'debuginfo_tags',
'source_tags', 'ignore_tags') # FIXME: remove ca here
'source_tags', 'separate_source_tags', 'ignore_tags') # FIXME: remove ca here
bool_opts = ('with_src','verbose','debug','ignore_stray_repos', 'offline_retry',
'krb_rdns', 'krb_canon_host', 'no_ssl_verify')
for name in config.options(section):