[Checkins] SVN: zc.recipe.cmmi/trunk/ fixed tests (buildout's output changed)

Jodok Batlogg jodok.batlogg at lovelysystems.com
Sun Jun 3 12:24:04 EDT 2007


Log message for revision 76256:
  fixed tests (buildout's output changed)
  added support for patching
  

Changed:
  _U  zc.recipe.cmmi/trunk/
  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/tests.py

-=-

Property changes on: zc.recipe.cmmi/trunk
___________________________________________________________________
Name: svn:externals
   + bootstrap svn://svn.zope.org/repos/main/zc.buildout/trunk/bootstrap/


Modified: zc.recipe.cmmi/trunk/CHANGES.txt
===================================================================
--- zc.recipe.cmmi/trunk/CHANGES.txt	2007-06-03 16:21:11 UTC (rev 76255)
+++ zc.recipe.cmmi/trunk/CHANGES.txt	2007-06-03 16:24:03 UTC (rev 76256)
@@ -1,6 +1,16 @@
 Release History
 ***************
 
+1.0.2 (2007-06-03)
+==================
+
+Added support for patches.
+
+Bugs Fixed
+----------
+
+Tests fixed (buildout's output changed)
+
 1.0.1 (2006-11-22)
 ==================
 

Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt	2007-06-03 16:21:11 UTC (rev 76255)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/README.txt	2007-06-03 16:24:03 UTC (rev 76256)
@@ -21,7 +21,7 @@
 It creates a make file which is also run:
 
     >>> print system('bin/buildout'),
-    buildout: Installing foo
+    Installing foo.
     configuring foo --prefix=/sample-buildout/parts/foo
     echo building foo
     building foo
@@ -37,7 +37,7 @@
 does nothing:
 
     >>> print system('bin/buildout'),
-    buildout: Updating foo
+    Updating foo.
 
 You can supply extra configure options:
 
@@ -53,8 +53,8 @@
     ... """ % distros)
 
     >>> print system('bin/buildout'),
-    buildout: Uninstalling foo
-    buildout: Installing foo
+    Uninstalling foo.
+    Installing foo.
     configuring foo --prefix=/sample-buildout/parts/foo -a -b c
     echo building foo
     building foo
@@ -76,3 +76,59 @@
     extra_options = -a -b c
     location = /sample-buildout/parts/foo
     ...
+
+Sometimes it's necessary to patch the sources before building a package.
+You can specify the name of the patch to apply and (optional) patch options:
+
+First of all let's write a patchfile:
+
+    >>> import sys
+    >>> mkdir('patches')
+    >>> write('patches/config.patch', 
+    ... """--- configure
+    ... +++ /dev/null
+    ... @@ -1,13 +1,13 @@
+    ...  #!%s
+    ...  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 
+passed, -p0 is appended by default.
+
+    >>> write('buildout.cfg',
+    ... """
+    ... [buildout]
+    ... parts = foo
+    ...
+    ... [foo]
+    ... recipe = zc.recipe.cmmi
+    ... url = file://%s/foo.tgz
+    ... patch = ${buildout:directory}/patches/config.patch
+    ... patch_options = -p0
+    ... """ % distros)
+
+    >>> print system('bin/buildout'),
+    Uninstalling foo.
+    Installing foo.
+    patching file configure
+    configuring foo patched --prefix=/sample_buildout/parts/foo
+    echo building foo patched
+    building foo patched
+    echo installing foo patched
+    installing foo patched
+    
\ No newline at end of file

Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py	2007-06-03 16:21:11 UTC (rev 76255)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/__init__.py	2007-06-03 16:24:03 UTC (rev 76256)
@@ -33,6 +33,8 @@
         # 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())
+        patch = self.options.get('patch', '')
+        patch_options = self.options.get('patch_options', '-p0')
 
         url = self.options['url']
         _, _, urlpath, _, _, _ = urlparse.urlparse(url)
@@ -47,6 +49,12 @@
             here = os.getcwd()
             try:
                 os.chdir(tmp)
+                if patch is not '':
+                    try:
+                        system("patch %s < %s" % (patch_options, patch))                    
+                    finally:
+                        os.chdir(tmp)
+                                        
                 try:
                     if not os.path.exists('configure'):
                         entries = os.listdir(tmp)

Modified: zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py
===================================================================
--- zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py	2007-06-03 16:21:11 UTC (rev 76255)
+++ zc.recipe.cmmi/trunk/zc/recipe/cmmi/tests.py	2007-06-03 16:24:03 UTC (rev 76256)
@@ -31,7 +31,6 @@
     info.size = len(configure)
     info.mode = 0755
     tar.addfile(info, StringIO.StringIO(configure))
-    
 
 def add(tar, name, src, mode=None):
     info.size = len(src)
@@ -53,8 +52,7 @@
 
 open('Makefile', 'w').write(Makefile_template)
 
-"""
-    
+"""    
 
 def test_suite():
     return unittest.TestSuite((



More information about the Checkins mailing list