Commit 1aea9672 authored by Kai Lautaportti's avatar Kai Lautaportti

Added new feature for building local source trees.


git-svn-id: https://svn.hexagonit.fi/hexagonit.recipe.cmmi/trunk@4582 b96f28ea-bbdf-0310-b3b3-e15a02b9f88d
parent 56c9d23c
Change History Change History
************** **************
1.1.0
=====
- Added new option ``path`` to allow building and installing local
source trees. The ``path`` option is mutually exclusive with
``url``.
1.0.1 1.0.1
===== =====
...@@ -11,4 +18,4 @@ Change History ...@@ -11,4 +18,4 @@ Change History
1.0.0 1.0.0
===== =====
Initial public release. - Initial public release.
...@@ -128,6 +128,53 @@ As we can see the configure script was called with the ``--prefix`` ...@@ -128,6 +128,53 @@ As we can see the configure script was called with the ``--prefix``
option by default followed by calls to ``make`` and ``make install``. option by default followed by calls to ``make`` and ``make install``.
Installing checkouts
====================
Sometimes instead of downloading and building an existing tarball we
need to work with code that is already available on the filesystem,
for example an SVN checkout.
Instead of providing the ``url`` option we will provide a ``path``
option to the directory containing the source code.
Let's demonstrate this by first unpacking our test package to the
filesystem and building that.
>>> checkout_dir = tmpdir('checkout')
>>> import setuptools.archive_util
>>> setuptools.archive_util.unpack_archive('%s/package-0.0.0.tar.gz' % src,
... checkout_dir)
>>> ls(checkout_dir)
d package-0.0.0
>>> write('buildout.cfg',
... """
... [buildout]
... parts = package
...
... [package]
... recipe = hexagonit.recipe.cmmi
... path = %s/package-0.0.0
... """ % checkout_dir)
>>> print system(buildout)
Uninstalling package.
Installing package.
package: Using local source directory: /checkout/package-0.0.0
configure --prefix=/sample_buildout/parts/package
building package
installing package
Since using the ``path`` implies that the source code has been
acquired outside of the control of the recipe also the responsibility
of managing it is outside of the recipe.
Depending on the software you may need to manually run ``make clean``
etc. between buildout runs if you make changes to the code. Also, the
``keep-compile-dir`` has no effect when ``path`` is used.
Advanced configuration Advanced configuration
====================== ======================
......
...@@ -24,8 +24,18 @@ class Recipe: ...@@ -24,8 +24,18 @@ class Recipe:
buildout['buildout']['parts-directory'], buildout['buildout']['parts-directory'],
self.name) self.name)
options['prefix'] = options['location'] options['prefix'] = options['location']
options['url'] = options['url'] options['url'] = options.get('url', '').strip()
options['compile-directory'] = '%s__compile__' % options['location'] options['path'] = options.get('path', '').strip()
if options['url'] and options['path']:
raise zc.buildout.UserError('You must use either "url" or "path", not both!')
if not (options['url'] or options['path']):
raise zc.buildout.UserError('You must provide either "url" or "path".')
if options['url']:
options['compile-directory'] = '%s__compile__' % options['location']
else:
options['compile-directory'] = options['path']
def update(self): def update(self):
pass pass
...@@ -60,18 +70,22 @@ class Recipe: ...@@ -60,18 +70,22 @@ class Recipe:
patch_options = ' '.join(self.options.get('patch-options', '-p0').split()) patch_options = ' '.join(self.options.get('patch-options', '-p0').split())
patches = self.options.get('patches', '').split() patches = self.options.get('patches', '').split()
compile_dir = self.options['compile-directory']
os.mkdir(compile_dir)
# Download the source using hexagonit.recipe.download # Download the source using hexagonit.recipe.download
try: if self.options['url']:
opt = self.options.copy() compile_dir = self.options['compile-directory']
opt['destination'] = compile_dir os.mkdir(compile_dir)
hexagonit.recipe.download.Recipe(
self.buildout, self.name, opt).install() try:
except: opt = self.options.copy()
shutil.rmtree(compile_dir) opt['destination'] = compile_dir
raise hexagonit.recipe.download.Recipe(
self.buildout, self.name, opt).install()
except:
shutil.rmtree(compile_dir)
raise
else:
log.info('Using local source directory: %s' % self.options['path'])
compile_dir = self.options['path']
os.mkdir(self.options['location']) os.mkdir(self.options['location'])
os.chdir(compile_dir) os.chdir(compile_dir)
...@@ -112,14 +126,15 @@ class Recipe: ...@@ -112,14 +126,15 @@ class Recipe:
'you can inspect what went wrong' % os.getcwd()) 'you can inspect what went wrong' % os.getcwd())
raise raise
if self.options.get('keep-compile-dir', '').lower() in ('true', 'yes', '1', 'on'): if self.options['url']:
# If we're keeping the compile directory around, add it to if self.options.get('keep-compile-dir', '').lower() in ('true', 'yes', '1', 'on'):
# the parts so that it's also removed when this recipe is # If we're keeping the compile directory around, add it to
# uninstalled. # the parts so that it's also removed when this recipe is
parts.append(self.options['compile-directory']) # uninstalled.
else: parts.append(self.options['compile-directory'])
shutil.rmtree(compile_dir) else:
del self.options['compile-directory'] shutil.rmtree(compile_dir)
del self.options['compile-directory']
parts.append(self.options['location']) parts.append(self.options['location'])
return parts return parts
...@@ -26,6 +26,7 @@ def test_suite(): ...@@ -26,6 +26,7 @@ def test_suite():
'--prefix=/sample_buildout'), '--prefix=/sample_buildout'),
(re.compile('\s/\S+sample-buildout'), (re.compile('\s/\S+sample-buildout'),
' /sample_buildout'), ' /sample_buildout'),
zc.buildout.testing.normalize_path,
]), ]),
), ),
)) ))
......
from setuptools import setup, find_packages from setuptools import setup, find_packages
import os import os
version = '1.0.1' version = '1.1.0'
name = 'hexagonit.recipe.cmmi' name = 'hexagonit.recipe.cmmi'
def read(*rnames): def read(*rnames):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment