From c41107ea51d6c532a261ad83b977baa1b6478947 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Oct 20 2016 20:46:32 +0000 Subject: [PATCH 1/2] pass build information consistently to the postImport callback Always pass the build infomation as the "build" argument to the postImport callback. For type='build' and type='image' imports, this change is additive, and so is unlikely to affect existing plugins. For type='cg' imports, this change makes the callback consistent with the other callback types, and the CG import mechanism is new enough that there is probably no code making use of it yet. --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 0b11a4a..6f3988d 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -4898,7 +4898,7 @@ class CG_Importer(object): self.import_metadata() koji.plugin.run_callbacks('postImport', type='cg', metadata=metadata, - directory=directory, buildinfo=self.buildinfo) + directory=directory, build=self.buildinfo) return self.buildinfo @@ -5450,7 +5450,7 @@ def import_build_in_place(build): WHERE id=%(build_id)i""" _dml(update, locals()) koji.plugin.run_callbacks('postBuildStateChange', attribute='state', old=buildinfo['state'], new=st_complete, info=buildinfo) - koji.plugin.run_callbacks('postImport', type='build', in_place=True, srpm=srpm, rpms=rpms) + koji.plugin.run_callbacks('postImport', type='build', in_place=True, build=buildinfo, srpm=srpm, rpms=rpms) return build_id def _import_wrapper(task_id, build_info, rpm_results): @@ -8183,7 +8183,7 @@ def importImageInternal(task_id, build_id, imgdata): _dml(q, {'archive_id': archive['id'], 'rpm_id': rpm_id}) koji.plugin.run_callbacks('postImport', type='image', image=imgdata, - fullpath=fullpath) + build=build_info, fullpath=fullpath) # # XMLRPC Methods From 238d1db03976b3e8fc3c3620834333fbc0dbf13f Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Oct 20 2016 20:48:07 +0000 Subject: [PATCH 2/2] provide more information to the pre/postRPMSign callback The existing pre/postRPMSign callback was following the format of the Task/BuildStateChange callbacks. This isn't necessary for a one-time operation. This change removes the attribute/old/new arguments, and replaces them with sigkey, sighash, build, and rpm arguments. This is more clear, and should make writing handlers for this callback simpler. --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 6f3988d..2750e6c 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -6100,10 +6100,7 @@ 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) + koji.plugin.run_callbacks('preRPMSign', sigkey=sigkey, sighash=sighash, build=binfo, rpm=rinfo) insert = """INSERT INTO rpmsigs(rpm_id, sigkey, sighash) VALUES (%(rpm_id)s, %(sigkey)s, %(sighash)s)""" _dml(insert, locals()) @@ -6113,7 +6110,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) + koji.plugin.run_callbacks('postRPMSign', sigkey=sigkey, sighash=sighash, build=binfo, rpm=rinfo) def _scan_sighdr(sighdr, fn): """Splices sighdr with other headers from fn and queries (no payload)"""