add a regen-repo command, useful for when an external repo is updated and the internal copy is out of date
This commit is contained in:
parent
46d8262ff4
commit
0998d39f8e
2 changed files with 48 additions and 3 deletions
39
cli/koji
39
cli/koji
|
|
@ -4324,6 +4324,45 @@ def anon_handle_wait_repo(options, session, args):
|
|||
|
||||
_search_types = ('package', 'build', 'tag', 'target', 'user', 'host', 'rpm', 'file')
|
||||
|
||||
def handle_regen_repo(options, session, args):
|
||||
"[admin] Force a repo to be regenerated"
|
||||
usage = _("usage: %prog regen-repo [options] <tag>")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
parser = OptionParser(usage=usage)
|
||||
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"))
|
||||
(suboptions, args) = parser.parse_args(args)
|
||||
if len(args) == 0:
|
||||
parser.error(_("A tag name must be specified"))
|
||||
assert False
|
||||
elif len(args) > 1:
|
||||
if suboptions.target:
|
||||
parser.error(_("Only a single target may be specified"))
|
||||
else:
|
||||
parser.error(_("Only a single tag name may be specified"))
|
||||
assert False
|
||||
activate_session(session)
|
||||
tag = args[0]
|
||||
if suboptions.target:
|
||||
info = session.getBuildTarget(tag)
|
||||
if not info:
|
||||
parser.error(_("No matching build target: " + tag))
|
||||
assert False
|
||||
tag = info['build_tag_name']
|
||||
else:
|
||||
info = session.getTag(tag)
|
||||
if not info:
|
||||
parser.error(_("No matching tag: " + tag))
|
||||
assert False
|
||||
tag = info['name']
|
||||
task_id = session.newRepo(tag)
|
||||
print "Regenerating repo for tag " + tag
|
||||
if _running_in_bg() or suboptions.nowait:
|
||||
return
|
||||
else:
|
||||
session.logout()
|
||||
return watch_tasks(session, [task_id])
|
||||
|
||||
def anon_handle_search(options, session, args):
|
||||
"Search koji"
|
||||
usage = _("usage: %prog sync [options] search_type pattern")
|
||||
|
|
|
|||
|
|
@ -5853,7 +5853,10 @@ class RootExports(object):
|
|||
|
||||
def newRepo(self, tag, event=None, src=False, debuginfo=False):
|
||||
"""Create a newRepo task. returns task id"""
|
||||
context.session.assertPerm('repo')
|
||||
if context.session.hasPerm('regen-repo'):
|
||||
pass
|
||||
else:
|
||||
context.session.assertPerm('repo')
|
||||
opts = {}
|
||||
if event is not None:
|
||||
opts['event'] = event
|
||||
|
|
@ -5900,14 +5903,17 @@ class RootExports(object):
|
|||
deleteBuildTarget = staticmethod(delete_build_target)
|
||||
getBuildTargets = staticmethod(get_build_targets)
|
||||
|
||||
def getBuildTarget(self, info, event=None):
|
||||
def getBuildTarget(self, info, event=None, strict=False):
|
||||
"""Return the build target with the given name or ID.
|
||||
If there is no matching build target, return None."""
|
||||
targets = get_build_targets(info=info, event=event)
|
||||
if len(targets) == 1:
|
||||
return targets[0]
|
||||
else:
|
||||
return None
|
||||
if strict:
|
||||
raise koji.GenericError, 'No matching build target found: %s' % info
|
||||
else:
|
||||
return None
|
||||
|
||||
def taskFinished(self,taskId):
|
||||
task = Task(taskId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue