Add tag2distrepo plugin to hub
Fixes: https://pagure.io/koji/issue/2820
This commit is contained in:
parent
d96cc0c015
commit
7785be7758
2 changed files with 150 additions and 2 deletions
61
plugins/hub/tag2distrepo.py
Normal file
61
plugins/hub/tag2distrepo.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# Koji tag2distrepo hub plugin
|
||||
# Copyright (c) 2019 Red Hat, Inc.
|
||||
# This callback automatically schedules distrepo tasks based on a tags config
|
||||
#
|
||||
# Authors:
|
||||
# Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
|
||||
from __future__ import absolute_import
|
||||
from koji.plugin import callback
|
||||
from kojihub import dist_repo_init, make_task, readTaggedRPMS, write_signed_rpm
|
||||
import logging
|
||||
|
||||
|
||||
@callback('postTag', 'postUntag')
|
||||
def tag2distrepo(cbtype, tag, build, user, force=False, strict=True):
|
||||
logger = logging.getLogger('koji.plugin.tag2distrepo')
|
||||
|
||||
if not tag['extra'].get("tag2distrepo.enabled"):
|
||||
logger.debug("No tag2distrepo enabled for tag %s" % tag['name'])
|
||||
return
|
||||
if not tag['arches']:
|
||||
raise ValueError(
|
||||
"Tag %s has no arches configured but tag2distrepo is enabled" % tag['name'])
|
||||
|
||||
keys = tag['extra'].get("tag2distrepo.keys", '').split()
|
||||
|
||||
if keys:
|
||||
logger.debug("Ensuring signed RPMs are written out")
|
||||
[rpms, _] = readTaggedRPMS(tag['id'], rpmsigs=True)
|
||||
for rpm in rpms:
|
||||
for key in keys:
|
||||
if rpm['sigkey'] == key:
|
||||
write_signed_rpm(rpm['id'], key, False)
|
||||
|
||||
task_opts = {
|
||||
'arch': tag['arches'].split(),
|
||||
'comp': None,
|
||||
'delta': [],
|
||||
'event': None,
|
||||
'inherit': False,
|
||||
'latest': False,
|
||||
'multilib': False,
|
||||
'split_debuginfo': False,
|
||||
'skip_missing_signatures': False,
|
||||
'allow_missing_signatures': not keys,
|
||||
}
|
||||
logger.debug(
|
||||
"Scheduling distRepo for tag %s, keys %s",
|
||||
tag['name'],
|
||||
keys,
|
||||
)
|
||||
|
||||
repo_id, event_id = dist_repo_init(tag['name'], keys, task_opts)
|
||||
task_opts['event'] = event_id
|
||||
task_id = make_task(
|
||||
'distRepo',
|
||||
[tag['name'], repo_id, keys, task_opts],
|
||||
priority=15,
|
||||
channel='createrepo',
|
||||
)
|
||||
logger.info("distRepo task %d scheduled for tag %s" % (task_id, tag['name']))
|
||||
Loading…
Add table
Add a link
Reference in a new issue