[PATCH] Add new {pre,post}RPMSign plugin callbacks.

Ralph Bean rbean at redhat.com
Thu Nov 13 03:23:34 UTC 2014


I'd like to use these in Fedora Infrastructure for the fedmsg plugin so
we can see when rawhide rpms get signed by sigul.
---
 hub/kojihub.py | 6 ++++++
 koji/plugin.py | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/hub/kojihub.py b/hub/kojihub.py
index 3c7d5c1..1f8c0e2 100644
--- a/hub/kojihub.py
+++ b/hub/kojihub.py
@@ -24,6 +24,7 @@
 import base64
 import calendar
 import cgi
+import copy
 import koji
 import koji.auth
 import koji.db
@@ -5152,6 +5153,10 @@ def add_rpm_sig(an_rpm, sighdr):
         #TODO[?] - if sighash is the same, handle more gracefully
         nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % rinfo
         raise koji.GenericError, "Signature already exists for package %s, key %s" % (nvra, sigkey)
+    callback_info = copy.copy(rinfo)
+    callback_info['sigkey'] = sigkey
+    callback_info['sighash'] = sighash
+    koji.plugin.run_callbacks('preRPMSign', attribute='sighash', old=None, new=sighash, info=callback_info)
     insert = """INSERT INTO rpmsigs(rpm_id, sigkey, sighash)
     VALUES (%(rpm_id)s, %(sigkey)s, %(sighash)s)"""
     _dml(insert, locals())
@@ -5161,6 +5166,7 @@ def add_rpm_sig(an_rpm, sighdr):
     fo = file(sigpath, 'wb')
     fo.write(sighdr)
     fo.close()
+    koji.plugin.run_callbacks('postRPMSign', attribute='sighash', old=None, new=sighash, info=callback_info)
 
 def _scan_sighdr(sighdr, fn):
     """Splices sighdr with other headers from fn and queries (no payload)"""
diff --git a/koji/plugin.py b/koji/plugin.py
index ed51a5c..975b297 100644
--- a/koji/plugin.py
+++ b/koji/plugin.py
@@ -35,6 +35,8 @@ callbacks = {
     'postBuildStateChange':   [],
     'preImport':              [],
     'postImport':             [],
+    'preRPMSign':             [],
+    'postRPMSign':            [],
     'preTag':                 [],
     'postTag':                [],
     'preUntag':               [],
-- 
1.9.3



More information about the buildsys mailing list