This commit is contained in:
Tomas Kopecek 2020-03-10 11:28:16 +01:00
parent fa4a4a6339
commit 40c02699a6
2 changed files with 16 additions and 15 deletions

View file

@ -10,7 +10,7 @@ from argparse import ArgumentParser
import koji
from koji.plugin import export_cli
from koji_cli.commands import anon_handle_wait_repo
from koji_cli.lib import _, activate_session
from koji_cli.lib import _, activate_session, arg_filter
@export_cli
@ -106,13 +106,13 @@ def handle_edit_sidetag(options, session, args):
help=_("Generate debuginfo repository"))
parser.add_argument("--no-debuginfo", action="store_false", dest="debuginfo")
parser.add_argument("--rpm-macro", action="append", default=[], metavar="key=value",
help=_("Set tag-specific rpm macros"))
dest="rpm_macros", help=_("Set tag-specific rpm macros"))
parser.add_argument("--remove-rpm-macro", action="append", default=[], metavar="key",
help=_("Remove rpm macros"))
dest="remove_rpm_macros", help=_("Remove rpm macros"))
opts = parser.parse_args(args)
if opts.debuginfo is None and not opts.add_rpm_macro and not opts.remove_rpm_macros:
if opts.debuginfo is None and not opts.rpm_macros and not opts.remove_rpm_macros:
parser.error("At least one option needs to be specified")
activate_session(session, options)
@ -121,9 +121,9 @@ def handle_edit_sidetag(options, session, args):
if opts.debuginfo is not None:
kwargs['debuginfo'] = opts.debuginfo
if options.add_rpm_macro:
rpm_macros = {]
for xopt in opts.add_rpm_macro:
if opts.rpm_macros:
rpm_macros = {}
for xopt in opts.rpm_macros:
key, value = xopt.split('=', 1)
value = arg_filter(value)
rpm_macros[key] = value

View file

@ -17,7 +17,7 @@ from kojihub import ( # noqa: F402
_edit_tag,
assert_policy,
get_build_target,
getInheritanceData,
readInheritanceData,
get_tag,
get_user,
nextval,
@ -234,25 +234,26 @@ def editSideTag(sidetag, debuginfo=None, rpm_macros=None, remove_rpm_macros=None
is_sidetag(sidetag, raise_error=True)
is_sidetag_owner(sidetag, user, raise_error=True)
parent_id = getInheritanceData(sidetag)[0]['parent_id']
parent_id = readInheritanceData(sidetag['id'])[0]['parent_id']
parent = get_tag(parent_id)
if debuginfo is not None and not parent['extra'].get('sidetag_debuginfo_allowed'):
raise koji.GenericError("Debuginfo setting is not allowed in parent tag.")
if ((rpm_macros is not None or remove_rpm_macros is not None)
and not parent['extra'].get('sidetag_rpm_macros_allowed')):
if (rpm_macros is not None or remove_rpm_macros is not None) \
and not parent['extra'].get('sidetag_rpm_macros_allowed'):
raise koji.GenericError("RPM macros change is not allowed in parent tag.")
kwargs = {'extra': {}}
if debuginfo is not None:
kwargs['extra']['with_debuginfo'] = bool(debuginfo)
for macro, value in rpm_macros.items():
kwargs['extra']['rpm.macro.%s' % macro] = value
if remove_rpm_macros:
if rpm_macros is not None:
for macro, value in rpm_macros.items():
kwargs['extra']['rpm.macro.%s' % macro] = value
if remove_rpm_macros is not None:
kwargs['remove_extra'] = ['rpm.macro.%s' % m for m in remove_rpm_macros]
_edit_tag(sidetag, **kwargs)
_edit_tag(sidetag['id'], **kwargs)
def handle_sidetag_untag(cbtype, *args, **kws):