[Checkins] SVN: zc.recipe.cmmi/trunk/ fixed #695977: don't cause buildout to delete shared builds, rebuild ones deleted by a third party
Thomas Lotze
tl at gocept.com
Tue Jan 18 02:43:16 EST 2011
Log message for revision 119630:
fixed #695977: don't cause buildout to delete shared builds, rebuild ones deleted by a third party
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/misc.txt
U zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt
-=-
Modified: zc.recipe.cmmi/trunk/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/trunk/CHANGES.txt 2011-01-18 06:45:40 UTC (rev 119629)
+++ zc.recipe.cmmi/trunk/CHANGES.txt 2011-01-18 07:43:15 UTC (rev 119630)
@@ -4,6 +4,9 @@
1.4 (unreleased)
================
+- Fixed a bug in location book-keeping that caused shared builds to be deleted
+ from disk when a part didn't need them anymore. (#695977)
+
- Made tests pass with both zc.buildout 1.4 and 1.5, lifted the upper version
bound on zc.buildout. (#695732)
Modified: zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py 2011-01-18 06:45:40 UTC (rev 119629)
+++ zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/__init__.py 2011-01-18 07:43:15 UTC (rev 119630)
@@ -96,6 +96,17 @@
return sha1(''.join(state)).hexdigest()
def install(self):
+ self.build()
+ if self.shared:
+ return ''
+ else:
+ return self.options['location']
+
+ def update(self):
+ if not os.path.isdir(self.options['location']):
+ self.build()
+
+ def build(self):
logger = logging.getLogger(self.name)
download = zc.buildout.download.Download(
self.buildout['buildout'], namespace='cmmi', hash_name=True,
@@ -178,11 +189,6 @@
logger.error("cmmi failed: %s", tmp)
raise
- return dest
-
- def update(self):
- pass
-
def cmmi(self, dest):
"""Do the 'configure; make; make install' command sequence.
Modified: zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/misc.txt
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/misc.txt 2011-01-18 06:45:40 UTC (rev 119629)
+++ zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/misc.txt 2011-01-18 07:43:15 UTC (rev 119630)
@@ -36,3 +36,39 @@
>>> import os.path
>>> os.path.isdir(join(sample_buildout, "parts", "foo"))
True
+
+Removing the parts folder
+-------------------------
+
+As a result of featuring shared builds, the handling of zc.recipe.cmmi's
+associated file-system paths is not entirely trivial. Let's make sure that
+when not sharing the build, the recipe gets the book-keeping of its part
+directory right.
+
+The part's directory is created when the part is installed:
+
+ >>> remove('.installed.cfg')
+ >>> rmdir('parts', 'foo')
+
+ >>> print system('bin/buildout')
+ Installing...
+ ...
+ installing foo
+
+ >>> os.path.isdir(join(sample_buildout, "parts", "foo"))
+ True
+
+The part's directory is removed when it is no longer needed (e.g. because the
+part now uses a shared build or because the part is gone altogether):
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts =
+ ... """)
+
+ >>> print system('bin/buildout')
+ Uninstalling foo.
+
+ >>> os.path.isdir(join(sample_buildout, "parts", "foo"))
+ False
Modified: zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt
===================================================================
--- zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt 2011-01-18 06:45:40 UTC (rev 119629)
+++ zc.recipe.cmmi/trunk/src/zc/recipe/cmmi/shared.txt 2011-01-18 07:43:15 UTC (rev 119630)
@@ -224,23 +224,112 @@
<BLANKLINE>
+Interaction with other users of shared builds
+=============================================
+
+While shared builds are a way to cache a build between installation runs of a
+given buildout part, they are, more importantly, shared between multiple parts
+and most probably, multiple buildouts. This implies two general rules of
+behaviour: We should never delete shared builds, and we need to be prepared
+for shared builds to be deleted by other system at any time.
+
+In other words: Every install or update run of the recipe that uses a shared
+build needs to check whether the build still exists on disk and rebuild it if
+it does not. On the other hand, a part using the shared build must not declare
+the shared build its own property lest buildout remove it when the shared
+build is no longer needed, either because the part no longer uses it or
+because the part itself is no longer used.
+
+The last thing we did above was to install a shared build:
+
+ >>> ls(cache, 'cmmi', 'build')
+ d <BUILDID>
+
+If someone deletes this shared build, updating the buildout part that needs it
+will cause it to be rebuilt:
+
+ >>> rmdir(cache, 'cmmi', 'build')
+ >>> print system('bin/buildout')
+ Updating foo.
+ foo: Unpacking and configuring
+ configuring foo /cache/cmmi/build/<BUILDID>
+ echo building foo
+ building foo
+ echo installing foo
+ installing foo
+
+ >>> ls(cache, 'cmmi', 'build')
+ d <BUILDID>
+
+If we stop using the shared build, it stays in the build cache:
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = foo
+ ... download-cache = %s
+ ...
+ ... [foo]
+ ... recipe = zc.recipe.cmmi
+ ... url = file://%s/foo.tgz
+ ... """ % (cache, distros))
+
+ >>> print system('bin/buildout')
+ Uninstalling foo.
+ Installing foo.
+ foo: Unpacking and configuring
+ configuring foo /sample-buildout/parts/foo
+ echo building foo
+ building foo
+ echo installing foo
+ installing foo
+
+ >>> ls(cache, 'cmmi', 'build')
+ d <BUILDID>
+
+
Regression: Keeping track of a reused shared build
==================================================
-zc.recipe.cmmi 1.2 had a bug that manifested when reusing a shared build by a
-second buildout: The part wouldn't keep track of the shared build and thus
-wasn't able to restore it if it got deleted from the cache. Let's simulate the
-second buildout by removing .installed.cfg, then this is how it should work:
+Let's first remove and rebuild everything to get some measure of isolation
+from the story so far:
>>> remove('.installed.cfg')
+ >>> rmdir(cache, 'cmmi', 'build')
+
+ >>> write('buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = foo
+ ... download-cache = %s
+ ...
+ ... [foo]
+ ... recipe = zc.recipe.cmmi
+ ... url = file://%s/foo.tgz
+ ... shared = True
+ ... """ % (cache, distros))
+
>>> print system('bin/buildout')
Installing foo.
+ foo: Unpacking and configuring
+ configuring foo /cache/cmmi/build/<BUILDID>
+ echo building foo
+ building foo
+ echo installing foo
+ installing foo
+
+zc.recipe.cmmi 1.2 had a bug that manifested after reusing a shared build: The
+part wouldn't keep track of the shared build and thus wasn't able to restore
+it if it got deleted from the cache. This is how it should work:
+
+ >>> remove('.installed.cfg')
+ >>> print system('bin/buildout')
+ Installing foo.
foo: using existing shared build
>>> rmdir(cache, 'cmmi', 'build')
>>> print system('bin/buildout')
- Uninstalling foo.
- Installing foo.
+ Updating foo.
foo: Unpacking and configuring
configuring foo /cache/cmmi/build/<BUILDID>
echo building foo
More information about the checkins
mailing list