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
**************
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
=====
......@@ -11,4 +18,4 @@ Change History
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``
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
======================
......
......@@ -24,8 +24,18 @@ class Recipe:
buildout['buildout']['parts-directory'],
self.name)
options['prefix'] = options['location']
options['url'] = options['url']
options['compile-directory'] = '%s__compile__' % options['location']
options['url'] = options.get('url', '').strip()
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):
pass
......@@ -60,18 +70,22 @@ class Recipe:
patch_options = ' '.join(self.options.get('patch-options', '-p0').split())
patches = self.options.get('patches', '').split()
compile_dir = self.options['compile-directory']
os.mkdir(compile_dir)
# Download the source using hexagonit.recipe.download
try:
opt = self.options.copy()
opt['destination'] = compile_dir
hexagonit.recipe.download.Recipe(
self.buildout, self.name, opt).install()
except:
shutil.rmtree(compile_dir)
raise
if self.options['url']:
compile_dir = self.options['compile-directory']
os.mkdir(compile_dir)
try:
opt = self.options.copy()
opt['destination'] = compile_dir
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.chdir(compile_dir)
......@@ -112,14 +126,15 @@ class Recipe:
'you can inspect what went wrong' % os.getcwd())
raise
if self.options.get('keep-compile-dir', '').lower() in ('true', 'yes', '1', 'on'):
# If we're keeping the compile directory around, add it to
# the parts so that it's also removed when this recipe is
# uninstalled.
parts.append(self.options['compile-directory'])
else:
shutil.rmtree(compile_dir)
del self.options['compile-directory']
if self.options['url']:
if self.options.get('keep-compile-dir', '').lower() in ('true', 'yes', '1', 'on'):
# If we're keeping the compile directory around, add it to
# the parts so that it's also removed when this recipe is
# uninstalled.
parts.append(self.options['compile-directory'])
else:
shutil.rmtree(compile_dir)
del self.options['compile-directory']
parts.append(self.options['location'])
return parts
......@@ -26,6 +26,7 @@ def test_suite():
'--prefix=/sample_buildout'),
(re.compile('\s/\S+sample-buildout'),
' /sample_buildout'),
zc.buildout.testing.normalize_path,
]),
),
))
......
from setuptools import setup, find_packages
import os
version = '1.0.1'
version = '1.1.0'
name = 'hexagonit.recipe.cmmi'
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