Skip to content
This repository has been archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
zerok committed Oct 6, 2008
0 parents commit 09e554d
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,25 @@
Copyright (c) 2008, Horst Gutmann <zerok@zerokspot.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 12 additions & 0 deletions setup.py
@@ -0,0 +1,12 @@
from setuptools import setup, find_packages

setup(
name='zerokspot.recipe.git',
author='Horst Gutmann',
author_email='zerok@zerokspot.com',
version = '0.1',
install_requires = ['setuptools', 'zc.buildout'],
namespace_packages = ['zerokspot'],
packages = find_packages(exclude=['ez_setup']),
entry_points = {'zc.buildout': ['default = zerokspot.recipe.git:Recipe']}
)
1 change: 1 addition & 0 deletions zerokspot/__init__.py
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace('zerokspot')
1 change: 1 addition & 0 deletions zerokspot/recipe/__init__.py
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace('zerokspot.recipe')
52 changes: 52 additions & 0 deletions zerokspot/recipe/git/__init__.py
@@ -0,0 +1,52 @@
import subprocess
import os.path
import zc.buildout

class Recipe(object):
"""
This recipe supports following options:
repository
Path to the repository that should be cloned
branch
Which branch should be cloned. If none is given, "master" is used by
default.
rev
Revision that should be used. This is useful if you want to freeze
the source at a given revision. If this is used, an update won't do
all that much when executed.
"""
def __init__(self, buildout, name, options):
self.buildout, self.name, self.options = buildout, name, options
self.repository = options['repository']
self.branch = options.get('branch', 'master')
self.rev = options.get('rev', None)
self.target = os.path.join(buildout['buildout']['directory'],
'parts', name)

def install(self):
ec = subprocess.call(r'git clone "%s" "%s"' %
(self.repository, self.target), shell=True)
if ec != 0:
raise zc.buildout.UserError("Failed to clone repository")
try:
os.chdir(self.target)

ec = subprocess.call(r'git checkout "%s"' % (self.branch,),
shell=True)
if ec != 0:
raise zc.buildout.UserError("Failed to switch branch")

if self.rev is not None:
ec = subprocess.call(r'git checkout "%s"' % (self.rev,),
shell=True)
if ec != 0:
raise zc.buildout.UserError("Failed to checkout revision")
finally:
os.chdir(self.buildout['buildout']['directory'])
return self.target

def update(self):
pass

0 comments on commit 09e554d

Please sign in to comment.