[Checkins] SVN: zc.recipe.cmmi/branches/patricks-remove-tmpdir/ remove temporary build directory

Patrick Strawderman patrick at zope.com
Wed Nov 10 14:35:32 EST 2010


Log message for revision 118318:
  remove temporary build directory
  

Changed:
  A   zc.recipe.cmmi/branches/patricks-remove-tmpdir/
  U   zc.recipe.cmmi/branches/patricks-remove-tmpdir/CHANGES.txt
  U   zc.recipe.cmmi/branches/patricks-remove-tmpdir/setup.py
  U   zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/README.txt
  U   zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/__init__.py
  U   zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/shared.txt
  U   zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/tests.py

-=-
Modified: zc.recipe.cmmi/branches/patricks-remove-tmpdir/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/trunk/CHANGES.txt	2010-11-10 14:28:49 UTC (rev 118317)
+++ zc.recipe.cmmi/branches/patricks-remove-tmpdir/CHANGES.txt	2010-11-10 19:35:31 UTC (rev 118318)
@@ -6,7 +6,11 @@
 
 - Nothing changed yet.
 
+1.3.3 (2010-11-10)
+==================
 
+- Remove the temporary build directory when cmmi succeeds.
+
 1.3.2 (2010-08-09)
 ==================
 

Modified: zc.recipe.cmmi/branches/patricks-remove-tmpdir/setup.py
===================================================================
--- zc.recipe.cmmi/trunk/setup.py	2010-11-10 14:28:49 UTC (rev 118317)
+++ zc.recipe.cmmi/branches/patricks-remove-tmpdir/setup.py	2010-11-10 19:35:31 UTC (rev 118318)
@@ -60,7 +60,7 @@
     include_package_data = True,
     data_files = [('.', ['README.txt'])],
     namespace_packages = ['zc', 'zc.recipe'],
-    install_requires = ['zc.buildout >=1.4', 'setuptools'],
+    install_requires = ['zc.buildout >=1.4, <1.5.0b1', 'setuptools'],
     extras_require = dict(test=['zope.testing']),
     entry_points = {'zc.buildout':
                     ['default = %s:Recipe' % name]},

Modified: zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/README.txt
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/README.txt	2010-11-10 14:28:49 UTC (rev 118317)
+++ zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/README.txt	2010-11-10 19:35:31 UTC (rev 118318)
@@ -297,3 +297,79 @@
     While:
       Installing foo.
     Error: MD5 checksum mismatch for local resource at '/.../sample-buildout/patches/config.patch'.
+
+    >>> write('buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = foo
+    ...
+    ... [foo]
+    ... recipe = zc.recipe.cmmi
+    ... url = %sfoo.tgz
+    ... patch = ${buildout:directory}/patches/config.patch
+    ... """ % (distros_url))
+
+If the build fails, the temporary directory where the tarball was unpacked
+is logged to stdout, and left intact for debugging purposes.
+
+    >>> write('patches/config.patch', "dgdgdfgdfg")
+
+    >>> res =  system('bin/buildout')
+    >>> print res
+    Installing foo.
+    foo: Downloading http://localhost/foo.tgz
+    foo: Unpacking and configuring
+    patch unexpectedly ends in middle of line
+    foo: cmmi failed: /.../...buildout-foo
+    patch: **** Only garbage was found in the patch input.
+    While:
+      Installing foo.
+    <BLANKLINE>
+    An internal error occured due to a bug in either zc.buildout or in a
+    recipe being used:
+    ...
+    SystemError: ('Failed', 'patch -p0 < /.../patches/config.patch')
+    <BLANKLINE>
+
+    >>> import re
+    >>> import os.path
+    >>> import shutil
+    >>> path = re.search('foo: cmmi failed: (.*)', res).group(1)
+    >>> os.path.exists(path)
+    True
+    >>> shutil.rmtree(path)
+
+After a successful build, such temporary directories are removed.
+
+    >>> import fnmatch
+    >>> import os
+    >>> import tempfile
+
+    >>> match = lambda filename: fnmatch.fnmatch(filename, '*buildout-foo')
+    >>> dirs = len(map(match, os.listdir(tempfile.gettempdir())))
+
+    >>> write('buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = foo
+    ...
+    ... [foo]
+    ... recipe = zc.recipe.cmmi
+    ... url = %sfoo.tgz
+    ... """ % (distros_url,))
+
+    >>> print system("bin/buildout")
+    Installing foo.
+    foo: Downloading http://localhost:21445/foo.tgz
+    foo: Unpacking and configuring
+    configuring foo --prefix=/sample_buildout/parts/foo
+    echo building foo
+    building foo
+    echo installing foo
+    installing foo
+    <BLANKLINE>
+
+    >>> tmpdir = os.listdir(tempfile.gettempdir())
+    >>> new_dirs = len(map(match, os.listdir(tempfile.gettempdir())))
+    >>> dirs == new_dirs
+    True

Modified: zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py	2010-11-10 14:28:49 UTC (rev 118317)
+++ zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/__init__.py	2010-11-10 19:35:31 UTC (rev 118318)
@@ -143,8 +143,16 @@
                 if self.patch is not '':
                     # patch may be a filesystem path or url
                     # url patches can go through the cache
-                    self.patch, is_temp = download(
-                        self.patch, md5sum=self.options.get('patch-md5sum'))
+                    if self.patch is not '':
+                        try:
+                            self.patch, is_temp = download(
+                                self.patch,
+                                md5sum=self.options.get('patch-md5sum'))
+                        except:
+                            # If download/checksum of the patch fails, leaving
+                            # the tmp dir won't be helpful.
+                            shutil.rmtree(tmp)
+                            raise
                     try:
                         system("patch %s < %s"
                                % (self.patch_options, self.patch))
@@ -161,10 +169,13 @@
                     else:
                         raise ValueError("Couldn't find configure")
                 self.cmmi(dest)
+                shutil.rmtree(tmp)
             finally:
                 os.chdir(here)
         except:
             shutil.rmtree(dest)
+            if os.path.exists(tmp):
+                logger.error("cmmi failed: %s", tmp)
             raise
 
         return dest

Modified: zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/shared.txt
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt	2010-11-10 14:28:49 UTC (rev 118317)
+++ zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/shared.txt	2010-11-10 19:35:31 UTC (rev 118318)
@@ -182,11 +182,18 @@
     ... """ % (cache, distros))
 
     >>> remove('.installed.cfg')
-    >>> print system('bin/buildout')
+    >>> res = system('bin/buildout')
+    >>> print res
     Installing foo.
     ...
     ValueError: Couldn't find configure
 
+The temporary directory where tarball was unpacked was left behind for
+debugging purposes.
+
+    >>> import re
+    >>> shutil.rmtree(re.search('foo: cmmi failed: (.*)', res).group(1))
+
 When we now fix the error (by copying back the working version and resetting the
 cache), the build will be run again, and we don't use a half-baked shared
 directory:

Modified: zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/tests.py
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/tests.py	2010-11-10 14:28:49 UTC (rev 118317)
+++ zc.recipe.cmmi/branches/patricks-remove-tmpdir/src/zc/recipe/cmmi/tests.py	2010-11-10 19:35:31 UTC (rev 118318)
@@ -17,7 +17,6 @@
 
 import unittest
 import doctest
-import zope.testing
 from zope.testing import renormalizing
 from zc.buildout.tests import easy_install_SetUp
 from zc.buildout.tests import normalize_bang



More information about the checkins mailing list