Hello please consider included patch which adds support for custom command to get the sources from SCM.
The reason why we needed something like this is the fact that in the Spacewalk project, we have multiple packages in one git repo, in different directories. To get .spec and .tar.gz for a particular package, a slightly different workflow is needed than koji generally supports. In our case, I wanted to be able to just use git format to get the .tar.gz from the remote repo (no local checkout needed (even if we might have one eventually to speed things up)), but before that a bit more work needs to be done to find out which subdirectory the package is in, similar to what the tito tool does (even if we do not use tito directly). Seeing that the allowed_scms already has fourth option to specify the alternative to make sources, and since we don't need to run the checkout at all, I've just added fifth option to specify custom script, which then does all the heavy lifting -- it checks if it already has the .spec and .tar.gz cached (as we build Spacewalk for four OSes from one source), it retrieves them from git.fedorahosted.org if it does not, and generally populates the sourcedir properly, short-cutting any checkout and make sources. I'd appreciate your comments about the patch, or inclusion of the patch to koji master as is. The patch has been in use at koji.spacewalkproject.org (albeit on top of koji 1.4, so in the /usr/sbin/kojid) for a week or so and it seems to achieve the goal properly. Thank you. >From 8e4072de758926a58c93226a44b08eda8b7ded87 Mon Sep 17 00:00:00 2001 From: Jan Pazdziora <[email protected]> Date: Wed, 8 Jun 2011 10:48:08 +0200 Subject: [PATCH] Support custom checkout command to populate sourcedir from SCM. The configuration is via the fifth part of the allowed_scms configuration value: allowed_scms=git.fedorahosted.org:/git/spacewalk.git:0::/usr/local/bin/get-tgz-from-git The custom script is passed the sourcedir, host, repository, and revision as parameters. --- koji/daemon.py | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/koji/daemon.py b/koji/daemon.py index b6f775a..07e1be7 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -192,6 +192,7 @@ class SCM(object): self.revision = fragment self.use_common = True self.source_cmd = ['make', 'sources'] + self.checkout_cmd = None for scmtype, schemes in SCM.types.items(): if self.scheme in schemes: @@ -275,6 +276,9 @@ class SCM(object): else: # there was nothing after the trailing :, so they don't want to run a source_cmd at all self.source_cmd = None + if len(scm_tuple) >= 5: + if scm_tuple[4]: + self.checkout_cmd = scm_tuple[4].split(',') break else: self.logger.warn('Ignoring incorrectly formatted SCM host:repository: %s' % allowed_scm) @@ -311,7 +315,10 @@ class SCM(object): raise koji.BuildError, 'Error running %s command "%s", see %s for details' % \ (self.scmtype, ' '.join(cmd), os.path.basename(logfile)) - if self.scmtype == 'CVS': + if self.checkout_cmd: + module_checkout_cmd = self.checkout_cmd + [sourcedir, self.host, self.repository, self.revision] + + elif self.scmtype == 'CVS': pserver = ':pserver:%s@%s:%s' % ((self.user or 'anonymous'), self.host, self.repository) module_checkout_cmd = ['cvs', '-d', pserver, 'checkout', '-r', self.revision, self.module] common_checkout_cmd = ['cvs', '-d', pserver, 'checkout', 'common'] -- 1.7.4.4 -- Jan Pazdziora Principal Software Engineer, Satellite Engineering, Red Hat -- buildsys mailing list [email protected] https://admin.fedoraproject.org/mailman/listinfo/buildsys
