From 6ad2bccec3952139ef65824ab403abcd5f4baf19 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 04 2021 09:44:21 +0000 Subject: [PATCH 1/2] plugin hooks for repo modification Fixes: https://pagure.io/koji/issue/2636 --- diff --git a/builder/kojid b/builder/kojid index 513f8dc..9e1da91 100755 --- a/builder/kojid +++ b/builder/kojid @@ -5458,6 +5458,10 @@ class CreaterepoTask(BaseTaskHandler): with open(os.path.join(self.datadir, "EMPTY_REPO"), 'wt') as fo: fo.write("This repo is empty because its tag has no content for this arch\n") + tag = self.session.getTag(rinfo['tag_id'], event=rinfo['create_event'], strict=True)['name'] + self.run_callbacks('postCreateRepo', tag=tag, repodir=self.outdir, + repo_id=self.repo_id, arch=arch) + uploadpath = self.getUploadDir() files = [] for f in os.listdir(self.datadir): @@ -5758,6 +5762,9 @@ class createDistRepoTask(BaseTaskHandler): fp.write("This repo is empty because its tag has no content " "for this arch\n") + self.run_callbacks('postCreateDistRepo', tag=tag, repodir=self.repodir, + repo_id=repo_id, arch=arch, keys=keys, opts=opts) + # upload repo files self.upload_repo() self.upload_repo_manifest() diff --git a/docs/source/writing_a_plugin.rst b/docs/source/writing_a_plugin.rst index aabc186..400d9e9 100644 --- a/docs/source/writing_a_plugin.rst +++ b/docs/source/writing_a_plugin.rst @@ -216,6 +216,8 @@ builder: - preSCMCheckout - postSCMCheckout +- postCreateDistRepo +- postCreateRepo .. _plugin-cli-command: diff --git a/koji/plugin.py b/koji/plugin.py index a3022e3..4d2e9b6 100644 --- a/koji/plugin.py +++ b/koji/plugin.py @@ -34,6 +34,7 @@ from koji.util import encode_datetime_recurse # the available callback hooks and a list # of functions to be called for each event callbacks = { + # hub 'prePackageListChange': [], 'postPackageListChange': [], 'preTaskStateChange': [], @@ -54,8 +55,11 @@ callbacks = { 'postRepoDone': [], 'preCommit': [], 'postCommit': [], + # builder 'preSCMCheckout': [], 'postSCMCheckout': [], + 'postCreateDistRepo': [], + 'postCreateRepo': [], } From 90a2697fa77d0f5103508589e5ca0a84ddcdf90f Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 04 2021 09:44:21 +0000 Subject: [PATCH 2/2] rename local variable --- diff --git a/builder/kojid b/builder/kojid index 9e1da91..7e239b3 100755 --- a/builder/kojid +++ b/builder/kojid @@ -5712,13 +5712,13 @@ class createDistRepoTask(BaseTaskHandler): oldpkgs = [] if opts.get('delta'): # should be a list of repo ids to delta against - for repo_id in opts['delta']: - oldrepo = self.session.repoInfo(repo_id, strict=True) + for delta_repo_id in opts['delta']: + oldrepo = self.session.repoInfo(delta_repo_id, strict=True) if not oldrepo['dist']: raise koji.GenericError("Base repo for deltas must also " "be a dist repo") # regular repos don't actually have rpms, just pkglist - path = koji.pathinfo.distrepo(repo_id, oldrepo['tag_name']) + path = koji.pathinfo.distrepo(delta_repo_id, oldrepo['tag_name']) if not os.path.exists(path): raise koji.GenericError('Base drpm repo missing: %s' % path) # note: since we're using the top level dir, this will handle