[Checkins] SVN: zc.recipe.rhrc/trunk/ Use the deployment name option (as provided by zc.recipe.deployment

Jim Fulton jim at zope.com
Fri Feb 1 16:22:20 EST 2008


Log message for revision 83395:
  Use the deployment name option (as provided by zc.recipe.deployment
  0.6.0 and later) if present when generating script names.
  
  Use the deployment rc-directory as the destination when a deployment
  is used.
  
  Use /sbin/chkconfig rather than chkconfig, as I'm told it is always in
  that location and rarely in anyone's path. :)
  

Changed:
  U   zc.recipe.rhrc/trunk/README.txt
  U   zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt
  U   zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py

-=-
Modified: zc.recipe.rhrc/trunk/README.txt
===================================================================
--- zc.recipe.rhrc/trunk/README.txt	2008-02-01 19:51:10 UTC (rev 83394)
+++ zc.recipe.rhrc/trunk/README.txt	2008-02-01 21:22:20 UTC (rev 83395)
@@ -10,6 +10,18 @@
 Changes
 *******
 
+1.1.0 (2008/02/01)
+==================
+
+Use the deployment name option (as provided by zc.recipe.deployment
+0.6.0 and later) if present when generating script names.
+
+Use the deployment rc-directory as the destination when a deployment
+is used.
+
+Use /sbin/chkconfig rather than chkconfig, as I'm told it is always in
+that location and rarely in anyone's path. :)
+
 1.0.0 (2008/01/15)
 ==================
 

Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt	2008-02-01 19:51:10 UTC (rev 83394)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/README.txt	2008-02-01 21:22:20 UTC (rev 83395)
@@ -576,25 +576,32 @@
 
 The zc.recipe.rhrc recipe is designed to work with the
 zc.recipe.deployment recipe.  You can specify the name of a deployment
-section.  If a deployment section is specified, then that name will be
-used for the rc scripts and the user from the deployment section will
-be used if a user isn't specified in the rc script's own section.
+section.  If a deployment section is specified then:
 
+- the deployment name will be used for the rc scripts
+
+- the user from the deployment section will be used if a user isn't
+  specified in the rc script's own section.
+
+- the rc-directory option from the deployment will be used if
+  destination isn't specified.
+
     >>> write('buildout.cfg',
     ... """
     ... [buildout]
     ... parts = zoperc
     ...
-    ... [acme]
+    ... [deployment]
+    ... name = acme
     ... user = acme
+    ... rc-directory = %(dest)s
     ...
     ... [zoperc]
     ... recipe = zc.recipe.rhrc
     ... parts = instance1 instance2
-    ... dest = %(dest)s
     ... chkconfig = 345 90 10
     ... chkconfigcommand = echo
-    ... deployment = acme
+    ... deployment = deployment
     ...
     ... [instance1]
     ... run-script = /opt/zope/bin/zopectl -C /etc/instance1.conf

Modified: zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py
===================================================================
--- zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py	2008-02-01 19:51:10 UTC (rev 83394)
+++ zc.recipe.rhrc/trunk/src/zc/recipe/rhrc/__init__.py	2008-02-01 21:22:20 UTC (rev 83395)
@@ -27,9 +27,14 @@
         self.name, self.options = name, options
         deployment = self.deployment = options.get('deployment')
         if deployment:
-            self.name = deployment
+            options['deployment-name'] = buildout[deployment].get('name',
+                                                                  deployment)
             if 'user' not in options:
                 options['user'] = buildout[deployment].get('user', '')
+            options['dest'] = self.options.get(
+                'dest', buildout[deployment]['rc-directory'])
+        else:
+            options['dest'] = self.options.get('dest', '/etc/init.d')
 
         options['scripts'] = '\n'.join([buildout[part].get('run-script', '')
                                         for part in options['parts'].split()
@@ -37,10 +42,10 @@
         options['envs'] = '\n'.join([buildout[part].get('env', '')
                                      for part in options['parts'].split()
                                      ])
-        options['dest'] = self.options.get('dest', '/etc/init.d')
 
     def install(self):
         options = self.options
+        name = options.get('deployment-name', self.name)
         parts = options['parts'].split()
         if not parts:
             return
@@ -69,7 +74,7 @@
 
                 if chkconfig:
                     script += ' \\\n      </dev/null'
-                self.output(chkconfig, script, self.name, created)
+                self.output(chkconfig, script, name, created)
             else:
                 cooked = []
                 for part, env, script in zip(parts, envs, scripts):
@@ -84,7 +89,7 @@
                         if env:
                             script = env + ' \\\n      ' + script
 
-                        self.output('', script, self.name+'-'+part, created)
+                        self.output('', script, name+'-'+part, created)
 
                     else:
                         script = self.no_script(part)
@@ -98,7 +103,7 @@
                 script = '\n\n    '.join(cooked)
                 cooked.reverse()
                 rscript = '\n\n    '.join(cooked)
-                self.output(chkconfig, script, self.name, created, rscript)
+                self.output(chkconfig, script, name, created, rscript)
             return created
         except:
             [os.remove(f) for f in created]
@@ -106,8 +111,9 @@
 
     def no_script(self, part):
         options = self.options
+        name = options.get('deployment-name', self.name)
         if self.deployment:
-            script = os.path.join(options['dest'], self.name+'-'+part)
+            script = os.path.join(options['dest'], name+'-'+part)
         else:
             script = os.path.join(options['dest'], part)
             
@@ -138,16 +144,16 @@
                  os.stat(ctlpath).st_mode | stat.S_IEXEC | stat.S_IXGRP)
         if chkconfig:
             chkconfigcommand = self.options.get('chkconfigcommand',
-                                                'chkconfig')
+                                                '/sbin/chkconfig')
             os.system(chkconfigcommand+' --add '+ctl)
 
     def update(self):
         pass
 
 def uninstall(name, options):
-    name = options.get('deployment', name)
+    name = options.get('deployment-name', name)
     if options.get('chkconfig'):
-        chkconfigcommand = options.get('chkconfigcommand', 'chkconfig')
+        chkconfigcommand = options.get('chkconfigcommand', '/sbin/chkconfig')
         os.system(chkconfigcommand+' --del '+name)
     
 



More information about the Checkins mailing list