support --latest for mock-config command
This commit is contained in:
parent
257dd238f8
commit
3576b2ddb1
2 changed files with 20 additions and 9 deletions
24
cli/koji
24
cli/koji
|
|
@ -1221,6 +1221,7 @@ def anon_handle_mock_config(options, session, args):
|
|||
parser.add_option("--arch", help=_("Specify the arch"))
|
||||
parser.add_option("--tag", help=_("Create a mock config for a tag"))
|
||||
parser.add_option("--task", help=_("Duplicate the mock config of a previous task"))
|
||||
parser.add_option("--latest", action="store_true", help=_("use the latest redirect url"))
|
||||
parser.add_option("--buildroot", help=_("Duplicate the mock config for the specified buildroot id"))
|
||||
parser.add_option("--mockdir", default="/var/lib/mock", metavar="DIR",
|
||||
help=_("Specify mockdir"))
|
||||
|
|
@ -1249,7 +1250,10 @@ def anon_handle_mock_config(options, session, args):
|
|||
except ValueError:
|
||||
parser.error(_("Buildroot id must be an integer"))
|
||||
brootinfo = session.getBuildroot(br_id)
|
||||
opts['repoid'] = brootinfo['repo_id']
|
||||
if options.latest:
|
||||
opts['repoid'] = 'latest'
|
||||
else:
|
||||
opts['repoid'] = brootinfo['repo_id']
|
||||
opts['tag_name'] = brootinfo['tag_name']
|
||||
arch = brootinfo['arch']
|
||||
elif options.task:
|
||||
|
|
@ -1264,7 +1268,10 @@ def anon_handle_mock_config(options, session, args):
|
|||
if len(broots) > 1:
|
||||
print _("Multiple buildroots found: %s" % [br['id'] for br in broots])
|
||||
brootinfo = broots[-1]
|
||||
opts['repoid'] = brootinfo['repo_id']
|
||||
if options.latest:
|
||||
opts['repoid'] = 'latest'
|
||||
else:
|
||||
opts['repoid'] = brootinfo['repo_id']
|
||||
opts['tag_name'] = brootinfo['tag_name']
|
||||
arch = brootinfo['arch']
|
||||
elif options.tag:
|
||||
|
|
@ -1280,11 +1287,14 @@ def anon_handle_mock_config(options, session, args):
|
|||
print _("Could not get config info for tag: %(name)s") % tag
|
||||
return 1
|
||||
opts['tag_name'] = tag['name']
|
||||
repo = session.getRepo(config['id'])
|
||||
if not repo:
|
||||
print _("Could not get a repo for tag: %(name)s") % tag
|
||||
return 1
|
||||
opts['repoid'] = repo['id']
|
||||
if options.latest:
|
||||
opts['repoid'] = 'latest'
|
||||
else:
|
||||
repo = session.getRepo(config['id'])
|
||||
if not repo:
|
||||
print _("Could not get a repo for tag: %(name)s") % tag
|
||||
return 1
|
||||
opts['repoid'] = repo['id']
|
||||
else:
|
||||
parser.error(_("Please specify one of: --tag, --task, --buildroot"))
|
||||
assert False
|
||||
|
|
|
|||
|
|
@ -1245,11 +1245,12 @@ def genMockConfig(name, arch, managed=False, repoid=None, tag_name=None, **opts)
|
|||
"""
|
||||
mockdir = opts.get('mockdir', '/var/lib/mock')
|
||||
if 'url' in opts:
|
||||
# XXX does anything still use this opt?
|
||||
from warnings import warn
|
||||
warn('The url option for genMockConfig is deprecated', DeprecationWarning)
|
||||
urls = [opts['url']]
|
||||
else:
|
||||
if not (repoid and tag_name):
|
||||
raise GenericError, "please provide a url or repo/tag"
|
||||
raise GenericError, "please provide a repo and tag"
|
||||
topurls = opts.get('topurls')
|
||||
if not topurls:
|
||||
#cli command still passes plain topurl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue