[Checkins] SVN: zc.recipe.cmmi/trunk/ Remove the build directory for a shared build when the source cannot be downloaded.
Thomas Lotze
tl at gocept.com
Mon Aug 9 13:14:49 EDT 2010
Log message for revision 115589:
Remove the build directory for a shared build when the source cannot be downloaded.
Changed:
U zc.recipe.cmmi/trunk/CHANGES.txt
U zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py
U zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt
-=-
Modified: zc.recipe.cmmi/trunk/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/trunk/CHANGES.txt 2010-08-09 17:05:10 UTC (rev 115588)
+++ zc.recipe.cmmi/trunk/CHANGES.txt 2010-08-09 17:14:48 UTC (rev 115589)
@@ -4,7 +4,8 @@
1.4 (unreleased)
================
-- Nothing changed yet.
+- Remove the build directory for a shared build when the source cannot be
+ downloaded.
1.3.1 (2009-09-10)
Modified: zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py 2010-08-09 17:05:10 UTC (rev 115588)
+++ zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py 2010-08-09 17:14:48 UTC (rev 115589)
@@ -105,14 +105,7 @@
if os.path.isdir(self.shared):
logger.info('using existing shared build')
return self.shared
- else:
- os.makedirs(self.shared)
- dest = self.options['location']
- here = os.getcwd()
- if not os.path.exists(dest):
- os.mkdir(dest)
-
fname, is_temp = download(self.url, md5sum=self.options.get('md5sum'))
# now unpack and work as normal
@@ -128,7 +121,18 @@
logger.info('Updating environment: %s=%s' % (key, value))
os.environ.update(self.environ)
+ # XXX This is probably more complicated than it needs to be. I
+ # retained the distinction between makedirs and mkdir when I moved
+ # creation of the build dir after downloading the source since I
+ # didn't understand the reason for the distinction. (tlotze)
+ if self.shared and not os.path.isdir(self.shared):
+ os.makedirs(self.shared)
+ dest = self.options['location']
+ if not os.path.exists(dest):
+ os.mkdir(dest)
+
try:
+ here = os.getcwd()
os.chdir(tmp)
try:
if not (os.path.exists(self.source_directory_contains) or
Modified: zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt 2010-08-09 17:05:10 UTC (rev 115588)
+++ zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt 2010-08-09 17:14:48 UTC (rev 115589)
@@ -240,3 +240,45 @@
building foo
echo installing foo
installing foo
+
+
+Regression: Don't leave behind a build directory if the download failed
+=======================================================================
+
+zc.recipe.cmmi up to version 1.3.1 had a bug that caused an empty build
+directory to be left behind if a download failed, causing it to be mistaken
+for a good shared build.
+
+We cause the download to fail by specifying a nonsensical MD5 sum:
+
+ >>> shutil.rmtree(cache)
+ >>> cache = tmpdir('cache')
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = foo
+ ... download-cache = %s
+ ...
+ ... [foo]
+ ... recipe = zc.recipe.cmmi
+ ... url = file://%s/foo.tgz
+ ... md5sum = 1234
+ ... shared = True
+ ... """ % (cache, distros))
+
+ >>> remove('.installed.cfg')
+ >>> print system('bin/buildout')
+ Installing foo.
+ ...
+ Error: MD5 checksum mismatch for local resource at '/distros/foo.tgz'.
+
+The build directory must not exist anymore:
+
+ >>> ls(cache, 'cmmi')
+
+Another buildout run must fail the same way as the first attempt:
+
+ >>> print system('bin/buildout')
+ Installing foo.
+ ...
+ Error: MD5 checksum mismatch for local resource at '/distros/foo.tgz'.
More information about the checkins
mailing list