[Checkins] SVN: zc.recipe.cmmi/trunk/ Add support to autogen
configure files.
Bernd Roessl
bernd.roessl at lovelysystems.com
Mon Jun 23 12:21:18 EDT 2008
Log message for revision 87673:
Add support to autogen configure files.
Changed:
U zc.recipe.cmmi/trunk/CHANGES.txt
U zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt
U zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py
U zc.recipe.cmmi/trunk/zc/recipe/cmmi/downloadcache.txt
U zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py
-=-
Modified: zc.recipe.cmmi/trunk/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/trunk/CHANGES.txt 2008-06-23 14:17:12 UTC (rev 87672)
+++ zc.recipe.cmmi/trunk/CHANGES.txt 2008-06-23 16:21:16 UTC (rev 87673)
@@ -1,11 +1,12 @@
Release History
***************
+
1.1.4 (unreleased)
==================
+Add support to autogen configure files.
-
1.1.3 (2008-06-03)
==================
Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt 2008-06-23 14:17:12 UTC (rev 87672)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt 2008-06-23 16:21:16 UTC (rev 87673)
@@ -1,6 +1,7 @@
We have an archive with a demo foo tar ball:
>>> ls(distros)
+ - bar.tgz
- foo.tgz
Let's update a sample buildout to installs it:
@@ -75,10 +76,10 @@
parts = foo
<BLANKLINE>
[foo]
- __buildout_installed__ = /sample-buildout/parts/foo
+ __buildout_installed__ = /sample_buildout/parts/foo
...
extra_options = -a -b c
- location = /sample-buildout/parts/foo
+ location = /sample_buildout/parts/foo
...
It may be necessary to set some environment variables when running configure
@@ -116,7 +117,7 @@
>>> import sys
>>> mkdir('patches')
- >>> write('patches/config.patch',
+ >>> write('patches/config.patch',
... """--- configure
... +++ /dev/null
... @@ -1,13 +1,13 @@
@@ -124,22 +125,22 @@
... import sys
... -print "configuring foo", ' '.join(sys.argv[1:])
... +print "configuring foo patched", ' '.join(sys.argv[1:])
- ...
+ ...
... Makefile_template = '''
... all:
... -\techo building foo
... +\techo building foo patched
- ...
+ ...
... install:
... -\techo installing foo
... +\techo installing foo patched
... '''
- ...
+ ...
... open('Makefile', 'w').write(Makefile_template)
- ...
+ ...
... """ % sys.executable)
-Now let's create a buildout.cfg file. Note: If no patch option is beeing
+Now let's create a buildout.cfg file. Note: If no patch option is beeing
passed, -p0 is appended by default.
>>> write('buildout.cfg',
@@ -165,4 +166,28 @@
building foo patched
echo installing foo patched
installing foo patched
-
+
+It is possible to autogenerate the configure files:
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = foo
+ ...
+ ... [foo]
+ ... recipe = zc.recipe.cmmi
+ ... url = file://%s/bar.tgz
+ ... autogen = autogen.sh
+ ... """ % distros)
+
+ >>> print system('bin/buildout'),
+ Uninstalling foo.
+ Installing foo.
+ foo: Downloading .../distros/bar.tgz
+ foo: Unpacking and configuring
+ foo: auto generating configure files
+ configuring foo --prefix=/sample_buildout/parts/foo
+ echo building foo
+ building foo
+ echo installing foo
+ installing foo
Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py 2008-06-23 14:17:12 UTC (rev 87672)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py 2008-06-23 16:21:16 UTC (rev 87673)
@@ -42,7 +42,7 @@
# we assume that install_from_cache and download_cache values
# are correctly set, and that the download_cache directory has
# been created: this is done by the main zc.buildout anyway
-
+
location = options.get(
'location', buildout['buildout']['parts-directory'])
options['location'] = os.path.join(location, name)
@@ -56,17 +56,20 @@
# get rid of any newlines that may be in the options so they
# do not get passed through to the commandline
extra_options = ' '.join(extra_options.split())
+
+ autogen = self.options.get('autogen', '')
+
patch = self.options.get('patch', '')
patch_options = self.options.get('patch_options', '-p0')
fname = getFromCache(
url, self.name, self.download_cache, self.install_from_cache)
-
+
# now unpack and work as normal
tmp = tempfile.mkdtemp('buildout-'+self.name)
logger.info('Unpacking and configuring')
setuptools.archive_util.unpack_archive(fname, tmp)
-
+
here = os.getcwd()
if not os.path.exists(dest):
os.mkdir(dest)
@@ -81,12 +84,11 @@
try:
os.chdir(tmp)
try:
- if not os.path.exists('configure'):
+ if not (os.path.exists('configure') or
+ os.path.exists(autogen)):
entries = os.listdir(tmp)
if len(entries) == 1:
os.chdir(entries[0])
- else:
- raise ValueError("Couldn't find configure")
if patch is not '':
# patch may be a filesystem path or url
# url patches can go through the cache
@@ -97,6 +99,15 @@
, self.install_from_cache
)
system("patch %s < %s" % (patch_options, patch))
+ if autogen is not '':
+ logger.info('auto generating configure files')
+ system("%s" % autogen)
+ if not os.path.exists('configure'):
+ entries = os.listdir(tmp)
+ if len(entries) == 1:
+ os.chdir(entries[0])
+ else:
+ raise ValueError("Couldn't find configure")
system("./configure --prefix=%s %s" %
(dest, extra_options))
system("make")
Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/downloadcache.txt
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/downloadcache.txt 2008-06-23 14:17:12 UTC (rev 87672)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/downloadcache.txt 2008-06-23 16:21:16 UTC (rev 87673)
@@ -17,6 +17,7 @@
We have an archive with a demo foo tar ball:
>>> ls(distros)
+ - bar.tgz
- foo.tgz
Let's update a sample buildout to install it:
Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py 2008-06-23 14:17:12 UTC (rev 87672)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py 2008-06-23 16:21:16 UTC (rev 87673)
@@ -34,6 +34,19 @@
info.mode = 0755
tar.addfile(info, StringIO.StringIO(configure))
+ tarpath = os.path.join(distros, 'bar.tgz')
+ tar = tarfile.open(tarpath, 'w:gz')
+ configure = configure_template % sys.executable
+ info = tarfile.TarInfo('configure.in')
+ info.size = len(configure)
+ info.mode = 0755
+ tar.addfile(info, StringIO.StringIO(configure))
+ autogen = autogen_template
+ info = tarfile.TarInfo('autogen.sh')
+ info.size = len(autogen)
+ info.mode = 0755
+ tar.addfile(info, StringIO.StringIO(autogen))
+
def add(tar, name, src, mode=None):
info.size = len(src)
if mode is not None:
@@ -54,8 +67,13 @@
open('Makefile', 'w').write(Makefile_template)
-"""
+"""
+autogen_template = """#!/bin/sh
+mv configure.in configure
+"""
+
+
def test_suite():
return unittest.TestSuite((
#doctest.DocTestSuite(),
@@ -70,7 +88,7 @@
]),
optionflags = doctest.ELLIPSIS
),
-
+
doctest.DocFileSuite(
'patching.txt',
setUp=setUp,
@@ -100,7 +118,7 @@
]),
optionflags = doctest.ELLIPSIS
),
-
+
doctest.DocFileSuite(
'misc.txt',
setUp=setUp,
More information about the Checkins
mailing list