Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Fedora Build System (http://www.linux-archive.org/fedora-build-system/)
-   -   Add support for custom checkout command (http://www.linux-archive.org/fedora-build-system/536727-add-support-custom-checkout-command.html)

Jan Pazdziora 06-08-2011 09:25 AM

Add support for custom checkout command
 
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 <jpazdziora@redhat.com>
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
buildsys@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/buildsys

Jan Pazdziora 07-20-2011 09:43 PM

Add support for custom checkout command
 
On Wed, Jun 08, 2011 at 11:25:50AM +0200, Jan Pazdziora wrote:
>
> Hello
>
> please consider included patch which adds support for custom command
> to get the sources from SCM.

Any change of getting the patch considered for inclusion in
koji upstream?

Thank you,

--
Jan Pazdziora
Principal Software Engineer, Satellite Engineering, Red Hat
--
buildsys mailing list
buildsys@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/buildsys


All times are GMT. The time now is 11:17 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.