From 7ce36bcf4a0fa834c712fa8c9b85cde5b71d5d19 Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Wed, 16 May 2012 17:10:29 -0300
Subject: [PATCH] Unify cloudooo with erp5 and install it direct from git

Install cloudooo from git mainstream (like erp5) instead rely on
eggs for this. This makes development and testing faster by adoptiong
mainstream always.

Unify the standalone setup and the setup into erp5 to provide the same
outcome and reduce maintenace.

Update cloudooo configuration to make it compatible with erp5testnode and
permit re-enable continuous integration.
---
 component/cloudooo/buildout.cfg               |  38 ++++--
 component/cloudooo/buildout.eggversion.cfg    |  31 +++++
 setup.py                                      |   1 +
 slapos/recipe/cloudooo/__init__.py            | 112 ------------------
 .../recipe/cloudooo/template/cloudooo.cfg.in  |  67 -----------
 slapos/recipe/cloudooo_test/__init__.py       |  51 ++++++++
 slapos/recipe/cloudooo_test/test.py           |  64 ++++++++++
 software/cloudooo/development.cfg             |   3 -
 software/cloudooo/instance-cloudoo.cfg.in     |  95 +++++++++++++++
 software/cloudooo/instance.cfg                |  26 ----
 software/cloudooo/instance.cfg.in             |  69 +++++++++++
 software/cloudooo/software.cfg                | 106 +++++++++++++----
 software/erp5/software.cfg                    |   5 +
 stack/cloudooo.cfg                            |  41 ++++---
 stack/erp5.cfg                                |  17 +--
 15 files changed, 457 insertions(+), 269 deletions(-)
 mode change 100644 => 100755 component/cloudooo/buildout.cfg
 create mode 100755 component/cloudooo/buildout.eggversion.cfg
 mode change 100644 => 100755 setup.py
 delete mode 100644 slapos/recipe/cloudooo/__init__.py
 delete mode 100644 slapos/recipe/cloudooo/template/cloudooo.cfg.in
 create mode 100644 slapos/recipe/cloudooo_test/__init__.py
 create mode 100644 slapos/recipe/cloudooo_test/test.py
 delete mode 100644 software/cloudooo/development.cfg
 create mode 100644 software/cloudooo/instance-cloudoo.cfg.in
 delete mode 100644 software/cloudooo/instance.cfg
 create mode 100644 software/cloudooo/instance.cfg.in
 mode change 100644 => 100755 software/cloudooo/software.cfg
 mode change 100644 => 100755 stack/cloudooo.cfg

diff --git a/component/cloudooo/buildout.cfg b/component/cloudooo/buildout.cfg
old mode 100644
new mode 100755
index 40d156d6b..a3c17d71c
--- a/component/cloudooo/buildout.cfg
+++ b/component/cloudooo/buildout.cfg
@@ -5,21 +5,43 @@ extends =
 parts =
   cloudooo
 
-sources = sources
+develop +=
+  ${:parts-directory}/cloudooo-repository
 
-[sources]
-# Include information related to official cloudooo source code.
-cloudooo = git http://git.erp5.org/repos/cloudooo.git
+[cloudooo-check-recipe]
+recipe = plone.recipe.command
+stop-on-error = true
+update-command = ${:command}
+command = grep parts ${buildout:develop-eggs-directory}/cloudooo.egg-link
 
-[lxml-python]
-python = python2.6
+[cloudooo-repository]
+recipe = plone.recipe.command
+location = ${buildout:parts-directory}/${:_buildout_section_name_}
+stop-on-error = true
+repository = http://git.erp5.org/repos/cloudooo.git
+branch = master
+revision =
+command = ${git:location}/bin/git clone --quiet -b ${:branch} ${:repository} ${:location} && if [ -n ${:revision} ]; then cd ${:location} && ${git:location}/bin/git reset --quiet --hard ${:revision} ; fi
+update-command = cd ${:location} && ${git:location}/bin/git pull --quiet && if [ -n ${:revision} ]; then cd ${:location} && ${git:location}/bin/git reset --quiet --hard ${:revision} ; fi
 
 [cloudooo]
 recipe = zc.recipe.egg
 python = python2.6
+extra-paths = ${cloudooo-repository:location}
 eggs =
   ${lxml-python:egg}
-  cloudooo
   PasteScript
-scripts =
+  python-magic
+  psutil
+  WSGIUtils
+  cloudooo
+entry-points =
+  main=cloudooo.paster_application:application
+  cloudooo_tester=cloudooo.bin.cloudooo_tester:main
+  runCloudoooUnitTest=cloudooo.tests.runHandlerUnitTest:run
+  runCloudoooTestSuite=cloudooo.tests.runTestSuite:run
+scripts = 
   paster=cloudooo_paster
+  runCloudoooUnitTest
+  runCloudoooTestSuite
+ugly-depend-on = ${cloudooo-repository:command} ${cloudooo-repository:update-command} ${cloudooo-check-recipe:command}
diff --git a/component/cloudooo/buildout.eggversion.cfg b/component/cloudooo/buildout.eggversion.cfg
new file mode 100755
index 000000000..e11192523
--- /dev/null
+++ b/component/cloudooo/buildout.eggversion.cfg
@@ -0,0 +1,31 @@
+[buildout]
+extends =
+  ../lxml-python/buildout.cfg
+
+parts =
+  cloudooo
+
+[lxml-python]
+python = python2.6
+
+[cloudooo]
+recipe = zc.recipe.egg
+python = python2.6
+eggs =
+  ${lxml-python:egg}
+  cloudooo
+  cloudooo.handler.ooo
+  cloudooo.handler.pdf
+  cloudooo.handler.ffmpeg
+  cloudooo.handler.imagemagick
+  PasteScript
+  python-magic
+entry-points =
+  cloudooo_tester=cloudooo.bin.cloudooo_tester:main
+  runCloudoooUnitTest=cloudooo.tests.runHandlerUnitTest:run
+
+scripts =
+  paster=cloudooo_paster
+  runCloudoooUnitTest
+
+
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
index 6d57bec12..ea010b6c1
--- a/setup.py
+++ b/setup.py
@@ -63,6 +63,7 @@ setup(name=name,
           'generic.onetimeupload = slapos.recipe.generic_onetimeupload:Recipe',
           'helloworld = slapos.recipe.helloworld:Recipe',
           'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe',
+          'cloudooo.test = slapos.recipe.cloudooo_test:Recipe',
           'firefox = slapos.recipe.firefox:Recipe',
           'fontconfig = slapos.recipe.fontconfig:Recipe',
           'java = slapos.recipe.java:Recipe',
diff --git a/slapos/recipe/cloudooo/__init__.py b/slapos/recipe/cloudooo/__init__.py
deleted file mode 100644
index df8ec564e..000000000
--- a/slapos/recipe/cloudooo/__init__.py
+++ /dev/null
@@ -1,112 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
-#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsibility of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# guarantees and support are strongly adviced to contract a Free Software
-# Service Company
-#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 3
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-#
-##############################################################################
-from slapos.lib.recipe.BaseSlapRecipe import BaseSlapRecipe
-import os
-import pkg_resources
-import sys
-import zc.buildout
-import zc.recipe.egg
-
-class Recipe(BaseSlapRecipe):
-  def getTemplateFilename(self, template_name):
-    return pkg_resources.resource_filename(__name__,
-        'template/%s' % template_name)
-
-  def _install(self):
-    self.path_list = []
-    self.requirements, self.ws = self.egg.working_set([__name__])
-    # Use killpidfromfile from ERP5.
-    self.killpidfromfile = zc.buildout.easy_install.scripts(
-        [('killpidfromfile', __name__ + 'slapos.recipe.erp5.killpidfromfile',
-          'killpidfromfile')], self.ws, sys.executable, self.bin_directory)[0]
-    self.path_list.append(self.killpidfromfile)
-    conversion_server_conf = self.installConversionServer(
-        self.getLocalIPv4Address(), 23000, 23060)
-
-    self.linkBinary()
-    self.setConnectionDict(dict(
-      site_url="http://%s:%s/" % (self.getLocalIPv4Address(), 23000),
-    ))
-    return self.path_list
-
-  def linkBinary(self):
-    """Links binaries to instance's bin directory for easier exposal"""
-    for linkline in self.options.get('link_binary_list', '').splitlines():
-      if not linkline:
-        continue
-      target = linkline.split()
-      if len(target) == 1:
-        target = target[0]
-        path, linkname = os.path.split(target)
-      else:
-        linkname = target[1]
-        target = target[0]
-      link = os.path.join(self.bin_directory, linkname)
-      if os.path.lexists(link):
-        if not os.path.islink(link):
-          raise zc.buildout.UserError(
-              'Target link already %r exists but it is not link' % link)
-        os.unlink(link)
-      os.symlink(target, link)
-      self.logger.debug('Created link %r -> %r' % (link, target))
-      self.path_list.append(link)
-
-  def installConversionServer(self, ip, port, openoffice_port):
-    name = 'conversion_server'
-    working_directory = self.createDataDirectory(name)
-    conversion_server_dict = dict(
-      working_path=working_directory,
-      uno_path=self.options['ooo_uno_path'],
-      office_binary_path=self.options['ooo_binary_path'],
-      ip=ip,
-      port=port,
-      openoffice_port=openoffice_port,
-    )
-    for env_line in self.options['environment'].splitlines():
-      env_line = env_line.strip()
-      if not env_line:
-        continue
-      if '=' in env_line:
-        env_key, env_value = env_line.split('=')
-        conversion_server_dict[env_key.strip()] = env_value.strip()
-      else:
-        raise zc.buildout.UserError('Line %r in environment parameter is '
-            'incorrect' % env_line)
-    config_file = self.createConfigurationFile(name + '.cfg',
-        self.substituteTemplate(self.getTemplateFilename('cloudooo.cfg.in'),
-          conversion_server_dict))
-    self.path_list.append(config_file)
-    # Use execute from erp5.
-    self.path_list.extend(zc.buildout.easy_install.scripts([(name,
-      __name__ + 'slapos.recipe.librecipe.execute',
-      'execute_with_signal_translation')], self.ws,
-      sys.executable, self.wrapper_directory,
-      arguments=[self.options['ooo_paster'].strip(), 'serve', config_file]))
-    return {
-      name + '_port': conversion_server_dict['port'],
-      name + '_ip': conversion_server_dict['ip']
-      }
diff --git a/slapos/recipe/cloudooo/template/cloudooo.cfg.in b/slapos/recipe/cloudooo/template/cloudooo.cfg.in
deleted file mode 100644
index cdf99be81..000000000
--- a/slapos/recipe/cloudooo/template/cloudooo.cfg.in
+++ /dev/null
@@ -1,67 +0,0 @@
-[app:main]
-use = egg:cloudooo
-#
-## System config
-#
-debug_mode = True
-# Folder where pid files, lock files and virtual frame buffer mappings
-# are stored. In this folder is necessary create a folder tmp, because this
-# folder is used to create all temporary documents.
-working_path = %(working_path)s
-# Folder where UNO library is installed
-uno_path = %(uno_path)s
-# Folder where soffice.bin is installed
-office_binary_path = %(office_binary_path)s
-#
-## Monitor Settings
-#
-# Limit to use the Openoffice Instance. if pass of the limit, the instance is
-# stopped and another is started.
-limit_number_request = 100
-# Interval to check the factory
-monitor_interval = 10
-timeout_response = 180
-enable_memory_monitor = True
-# Set the limit in MB
-# e.g 1000 = 1 GB, 100 = 100 MB
-limit_memory_used = 3000
-#
-## OOFactory Settings
-#
-# The pool consist of several OpenOffice.org instances
-application_hostname = %(ip)s
-# OpenOffice Port
-openoffice_port = %(openoffice_port)s
-# LD_LIBRARY_PATH passed to OpenOffice
-env-LD_LIBRARY_PATH = %(LD_LIBRARY_PATH)s
-
-#
-# Mimetype Registry
-# It is used to select the handler that will be used in conversion.
-# Priority matters, first match take precedence on next lines.
-mimetype_registry =
-  application/pdf * ooo
-  video/* * ffmpeg
-  audio/* * ffmpeg
-  application/x-shockwave-flash * ffmpeg
-  application/ogg * ffmpeg
-  application/ogv * ffmpeg
-  image/* * ooo
-  text/* * ooo
-  application/zip * ooo
-  application/msword * ooo
-  application/vnd* * ooo
-  application/x-vnd* * ooo
-  application/postscript * ooo
-  application/wmf * ooo
-  application/csv * ooo
-  application/x-openoffice-gdimetafile * ooo
-  application/x-emf * ooo
-  application/emf * ooo
-  application/octet* * ooo
-  * application/vnd.oasis.opendocument* ooo
-
-[server:main]
-use = egg:PasteScript#wsgiutils
-host = %(ip)s
-port = %(port)s
diff --git a/slapos/recipe/cloudooo_test/__init__.py b/slapos/recipe/cloudooo_test/__init__.py
new file mode 100644
index 000000000..2cb6f6863
--- /dev/null
+++ b/slapos/recipe/cloudooo_test/__init__.py
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+from slapos.recipe.librecipe import GenericBaseRecipe
+import urlparse
+
+class Recipe(GenericBaseRecipe):
+  def install(self):
+    path_list = []
+    common_dict = dict(
+        prepend_path=self.options['prepend-path'],
+    )
+    common_list = [
+           "--paster_path", self.options['ooo-paster'],
+           self.options['configuration-file']
+          ]
+    run_unit_test_path = self.createPythonScript(self.options['run-unit-test'],
+        __name__ + '.test.runUnitTest', [dict(
+        call_list=[self.options['run-unit-test-binary'],
+          ] + common_list, **common_dict)])
+
+    path_list.append(run_unit_test_path)
+    path_list.append(self.createPythonScript(self.options['run-test-suite'],
+        __name__ + '.test.runTestSuite', [dict(
+        call_list=[self.options['run-test-suite-binary'],
+          ], **common_dict)]))
+
+    return path_list
diff --git a/slapos/recipe/cloudooo_test/test.py b/slapos/recipe/cloudooo_test/test.py
new file mode 100644
index 000000000..70baa22f5
--- /dev/null
+++ b/slapos/recipe/cloudooo_test/test.py
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsibility of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# guarantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 3
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+import os
+import sys
+def runTestSuite(args):
+  env = os.environ.copy()
+  d = args[0]
+  env['PATH'] = ':'.join([d['prepend_path']] + os.environ['PATH'].split(':'))
+  # Deal with Shebang size limitation
+  executable_filepath = d['call_list'][0]
+  file_object = open(executable_filepath, 'r')
+  line = file_object.readline()
+  file_object.close()
+  argument_list = []
+  if line[:2] == '#!':
+    executable_filepath = line[2:].strip()
+    argument_list.append(executable_filepath)
+  argument_list.extend(d['call_list'])
+  argument_list.extend(sys.argv[1:])
+  argument_list.append(env)
+  os.execle(executable_filepath, *argument_list)
+
+def runUnitTest(args):
+  env = os.environ.copy()
+  d = args[0]
+  env['PATH'] = ':'.join([d['prepend_path']] + os.environ.get('PATH', '').split(':'))
+  # Deal with Shebang size limitation
+  executable_filepath = d['call_list'][0]
+  file_object = open(executable_filepath, 'r')
+  line = file_object.readline()
+  file_object.close()
+  argument_list = []
+  if line[:2] == '#!':
+    executable_filepath = line[2:].strip()
+    argument_list.append(executable_filepath)
+  argument_list.extend(d['call_list'])
+  argument_list.extend(sys.argv[1:])
+  argument_list.append(env)
+  os.execle(executable_filepath, *argument_list)
+
diff --git a/software/cloudooo/development.cfg b/software/cloudooo/development.cfg
deleted file mode 100644
index d86faeff1..000000000
--- a/software/cloudooo/development.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-[buildout]
-extends = software.cfg
-auto-checkout = cloudooo
diff --git a/software/cloudooo/instance-cloudoo.cfg.in b/software/cloudooo/instance-cloudoo.cfg.in
new file mode 100644
index 000000000..e17ad18db
--- /dev/null
+++ b/software/cloudooo/instance-cloudoo.cfg.in
@@ -0,0 +1,95 @@
+{% set json = json_module.loads(parameter_dict.get('cloudooo-json', '{}')) -%}
+{% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
+[buildout]
+parts =
+  publish-cloudooo-connection-information
+  cloudooo-instance
+  cloudooo-test-runner
+
+eggs-directory = {{ eggs_directory }}
+develop-eggs-directory = {{ develop_eggs_directory }}
+offline = true
+
+[publish-cloudooo-connection-information]
+recipe = slapos.cookbook:publishurl
+url = cloudooo://${cloudooo-instance:ip}:${cloudooo-instance:port}/
+
+[cloudooo-instance]
+recipe = slapos.cookbook:generic.cloudooo
+
+# Network options
+ip = ${slap-network-information:local-ipv4}
+port = 23000
+openoffice-port = 23060
+
+# Paths
+configuration-file = ${rootdirectory:etc}/cloudooo.cfg
+wrapper = ${basedirectory:services}/cloudooo
+
+# Paths: Data
+data-directory = ${directory:cloudooo-data}
+
+environment =
+  LD_LIBRARY_PATH = {{ parameter_dict['file'] }}/lib:{{ parameter_dict['fontconfig'] }}/lib:{{ parameter_dict['freetype'] }}/lib:{{ parameter_dict['libICE'] }}/lib:{{ parameter_dict['libpng12'] }}/lib:{{ parameter_dict['libSM'] }}/lib:{{ parameter_dict['libX11'] }}/lib:{{ parameter_dict['libXau'] }}/lib:{{ parameter_dict['libXdmcp'] }}/lib:{{ parameter_dict['libXext'] }}/lib:{{ parameter_dict['libxcb'] }}/lib:{{ parameter_dict['libXrender'] }}/lib:{{ parameter_dict['zlib'] }}/lib
+  FONTCONFIG_FILE = ${fontconfig-instance:conf-path}
+  PATH = ${binary-link:target-directory}
+
+# Binary information
+# cloudooo specific configuration
+ooo-binary-path = {{ parameter_dict['libreoffice-bin'] }}/program
+ooo-paster = {{ bin_directory }}/cloudooo_paster
+ooo-uno-path = {{ parameter_dict['libreoffice-bin'] }}/basis-link/program
+
+[cloudooo-test-runner]
+recipe = slapos.cookbook:cloudooo.test
+
+prepend-path = ${buildout:bin-directory}
+run-unit-test = ${buildout:bin-directory}/runUnitTest
+run-test-suite = ${buildout:bin-directory}/runTestSuite
+
+ooo-paster = ${cloudooo-instance:ooo-paster}
+configuration-file = ${cloudooo-instance:configuration-file}
+
+run-unit-test-binary = {{ bin_directory }}/runCloudoooUnitTest
+run-test-suite-binary = {{ bin_directory }}/runCloudoooTestSuite
+
+[fontconfig-instance]
+recipe = slapos.cookbook:fontconfig
+conf-path = ${rootdirectory:etc}/font.conf
+font-system-folder = {{ parameter_dict['fonts'] }}
+font-folder = ${directory:font}
+url-list = {{ json.get('font_url_list', []) | join(' ') }}
+service-folder = ${basedirectory:services}
+onetimedownload_path = {{ bin_directory }}/onetimedownload
+
+[binary-link]
+recipe = slapos.cookbook:symbolic.link
+target-directory = ${rootdirectory:bin}
+link-binary =
+  {{ parameter_dict['coreutils'] }}/bin/basename
+  {{ parameter_dict['coreutils'] }}/bin/cat
+  {{ parameter_dict['coreutils'] }}/bin/cp
+  {{ parameter_dict['coreutils'] }}/bin/ls
+  {{ parameter_dict['coreutils'] }}/bin/tr
+  {{ parameter_dict['coreutils'] }}/bin/uname
+  {{ parameter_dict['imagemagick'] }}/bin/convert
+  {{ parameter_dict['imagemagick'] }}/bin/identify
+  {{ parameter_dict['poppler'] }}/bin/pdfinfo
+  {{ parameter_dict['poppler'] }}/bin/pdftotext
+  {{ parameter_dict['poppler'] }}/bin/pdftohtml
+
+# rest of parts are candidates for some generic stuff
+[basedirectory]
+recipe = slapos.cookbook:mkdirectory
+services = ${rootdirectory:etc}/run
+
+[directory]
+recipe = slapos.cookbook:mkdirectory
+cloudooo-data = ${rootdirectory:srv}/cloudooo
+font = ${rootdirectory:srv}/font
+
+[rootdirectory]
+recipe = slapos.cookbook:mkdirectory
+etc = ${buildout:directory}/etc
+srv = ${buildout:directory}/srv
+bin = ${buildout:directory}/bin
diff --git a/software/cloudooo/instance.cfg b/software/cloudooo/instance.cfg
deleted file mode 100644
index a1a1b42e2..000000000
--- a/software/cloudooo/instance.cfg
+++ /dev/null
@@ -1,26 +0,0 @@
-[buildout]
-parts =
-  instance
-
-eggs-directory = ${buildout:eggs-directory}
-develop-eggs-directory = ${buildout:develop-eggs-directory}
-
-[instance]
-recipe = ${instance-recipe:egg}:${instance-recipe:module}
-
-# cloudooo specific configuration
-ooo_binary_path = ${libreoffice-bin:location}/program
-ooo_paster = ${buildout:bin-directory}/cloudooo_paster
-ooo_uno_path = ${libreoffice-bin:location}/basis-link/program
-
-link_binary_list =
-  ${xpdf:location}/bin/pdfinfo
-  ${xpdf:location}/bin/pdftotext
-  ${ffmpeg:location}/bin/ffmpeg
-  ${ffmpeg:location}/bin/ffprobe
-  ${imagemagick:location}/bin/convert
-  ${imagemagick:location}/bin/identify
-  ${pdftk:location}/bin/pdftk
-
-environment =
-  LD_LIBRARY_PATH = ${file:location}/lib:${fontconfig:location}/lib:${freetype:location}/lib:${libICE:location}/lib:${libpng12:location}/lib:${libSM:location}/lib:${libX11:location}/lib:${libXau:location}/lib:${libXdmcp:location}/lib:${libXext:location}/lib:${libxcb:location}/lib:${libXrender:location}/lib:${zlib:location}/lib
diff --git a/software/cloudooo/instance.cfg.in b/software/cloudooo/instance.cfg.in
new file mode 100644
index 000000000..e341a342e
--- /dev/null
+++ b/software/cloudooo/instance.cfg.in
@@ -0,0 +1,69 @@
+[buildout]
+parts =
+  switch-softwaretype
+
+eggs-directory = {{ eggs_directory }}
+develop-eggs-directory = {{ develop_eggs_directory }}
+offline = true
+
+[slap-parameters]
+recipe = slapos.cookbook:slapparameters
+computer = ${slap-connection:computer-id}
+partition = ${slap-connection:partition-id}
+url = ${slap-connection:server-url}
+key = ${slap-connection:key-file}
+cert = ${slap-connection:cert-file}
+
+[jinja2-template-base]
+recipe = slapos.recipe.template:jinja2
+rendered = ${buildout:parts-directory}/${:_buildout_section_name_}/${:filename}
+extra-context =
+context =
+    key eggs_directory buildout:eggs-directory
+    key develop_eggs_directory buildout:develop-eggs-directory
+    jsonkey slapparameter_dict slap-parameters:json
+    ${:extra-context}
+
+[dynamic-template-cloudooo-parameters]
+file = {{ file_location }}
+fontconfig = {{ fontconfig_location }}
+freetype = {{ freetype_location }}
+libICE = {{ libICE_location }}
+libpng12 = {{ libpng12_location }}
+libSM = {{ libSM_location }}
+libX11 = {{ libX11_location }}
+libXau = {{ libXau_location }}
+libXdmcp = {{ libXdmcp_location }}
+libXext = {{ libXext_location }}
+libxcb = {{ libxcb_location }}
+libXrender = {{ libXrender_location }}
+zlib = {{ zlib_location }}
+libreoffice-bin = {{ libreoffice_bin_location }}
+fonts = {{ fonts_location }}
+coreutils = {{ coreutils_location }}
+imagemagick = {{ imagemagick_location }}
+poppler = {{ poppler_location }}
+buildout-bin-directory = {{ buildout_bin_directory }}
+
+[dynamic-template-cloudooo]
+< = jinja2-template-base
+template = {{ template_cloudooo }}
+filename = instance-cloudoo.cfg
+extra-context =
+    section parameter_dict dynamic-template-cloudooo-parameters
+    import json_module json
+# Must match the key id in [switch-softwaretype] which uses this section.
+    raw software_type default
+
+[switch-softwaretype]
+recipe = slapos.cookbook:softwaretype
+default = ${dynamic-template-cloudooo:rendered}
+
+[slap-connection]
+# part to migrate to new - separated words
+computer-id = ${slap_connection:computer_id}
+partition-id = ${slap_connection:partition_id}
+server-url = ${slap_connection:server_url}
+software-release-url = ${slap_connection:software_release_url}
+key-file = ${slap_connection:key_file}
+cert-file = ${slap_connection:cert_file}
diff --git a/software/cloudooo/software.cfg b/software/cloudooo/software.cfg
old mode 100644
new mode 100755
index 7f8143fb4..78d6b6345
--- a/software/cloudooo/software.cfg
+++ b/software/cloudooo/software.cfg
@@ -1,20 +1,20 @@
 [buildout]
-extensions =
-  slapos.rebootstrap
-  slapos.zcbworkarounds
-  mr.developer
-
-find-links =
-    http://www.nexedi.org/static/packages/source/slapos.buildout/
-    http://dist.repoze.org
-    http://www.nexedi.org/static/packages/source/
-
 extends =
+  ../../stack/shacache-client.cfg
   ../../stack/cloudooo.cfg
 
 versions = versions
 
+# Local development
+develop +=
+  ${:parts-directory}/slapos.cookbook-repository
+  ${:parts-directory}/cloudooo-repository
 parts +=
+# Local development
+  slapos.cookbook-repository
+  check-recipe
+  slapos.cookbook-python2.6
+  slapos.recipe.template-python2.6
 # Create instance template
   template
 
@@ -23,16 +23,80 @@ parts +=
 # development / fast switching environment for whole software
 unzip = true
 
-[instance-recipe]
-# Note: In case if specific instantiation recipe is used this is the place to
-# put its name
-egg = slapos.cookbook
-module = cloudooo
+# Local development
+[slapos.cookbook-repository]
+recipe = plone.recipe.command
+stop-on-error = true
+location = ${buildout:parts-directory}/${:_buildout_section_name_}
+command = ${git:location}/bin/git clone --branch cloudooo --quiet http://git.erp5.org/repos/slapos.git ${:location}
+update-command = cd ${:location} && ${git:location}/bin/git pull --quiet
+
+[check-recipe]
+recipe = plone.recipe.command
+stop-on-error = true
+update-command = ${:command}
+command = grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link
+
+[slapos.cookbook-python2.6]
+recipe = zc.recipe.egg
+eggs = slapos.cookbook
+scripts =
+python = python2.6
+ugly-depend-on = ${slapos.cookbook-repository:command} ${slapos.cookbook-repository:update-command}
+
+[slapos.recipe.template-python2.6]
+recipe = zc.recipe.egg
+eggs = slapos.recipe.template
+scripts =
+python = python2.6
+
+[template-jinja2-base]
+recipe = slapos.recipe.template:jinja2
+template = ${:_profile_base_location_}/${:filename}.in
+rendered = ${buildout:directory}/${:filename}
+# XXX: extra-context is needed because we cannot append to a key of an extended
+# section.
+extra-context =
+context =
+    key bin_directory buildout:bin-directory
+    key develop_eggs_directory buildout:develop-eggs-directory
+    key eggs_directory buildout:eggs-directory
+    ${:extra-context}
 
 [template]
-# Default template for erp5 instance.
-recipe = slapos.recipe.template
-url = ${:_profile_base_location_}/instance.cfg
-md5sum = 49da453a38dc5462c170747a029037b7
-output = ${buildout:directory}/template.cfg
-mode = 0644
+< = template-jinja2-base
+# XXX: "template.cfg" is hardcoded in instanciation recipe
+filename = template.cfg
+template = ${:_profile_base_location_}/instance.cfg.in
+md5sum = 46a1f4dc69ccf0b42b9d579e34b40df9
+extra-context =
+    key buildout_bin_directory buildout:bin-directory
+    key dcron_location dcron:location
+    key file_location file:location
+    key fontconfig_location fontconfig:location
+    key fonts_location fonts:location
+    key freetype_location freetype:location
+    key git_location git:location
+    key imagemagick_location imagemagick:location
+    key libICE_location libICE:location
+    key libSM_location libSM:location
+    key libX11_location libX11:location
+    key libXau_location libXau:location
+    key libXdmcp_location libXdmcp:location
+    key libXext_location libXext:location
+    key libXrender_location libXrender:location
+    key libpng12_location libpng12:location
+    key libreoffice_bin_location libreoffice-bin:location
+    key libxcb_location libxcb:location
+    key openssl_location openssl:location
+    key pdftk_location pdftk:location
+    key poppler_location poppler:location
+    key template_cloudooo template-cloudooo:target
+    key zlib_location zlib:location
+    key coreutils_location coreutils:location
+
+[template-cloudooo]
+recipe = slapos.recipe.build:download
+url = ${:_profile_base_location_}/instance-cloudoo.cfg.in
+md5sum = b4692fb5916e997c9766b9d0e1030e6c
+mode = 640
diff --git a/software/erp5/software.cfg b/software/erp5/software.cfg
index c552c70ab..281a840fd 100644
--- a/software/erp5/software.cfg
+++ b/software/erp5/software.cfg
@@ -8,6 +8,8 @@ versions = versions
 # Local development
 develop =
   ${:parts-directory}/slapos.cookbook-repository
+  ${:parts-directory}/cloudooo-repository
+
 parts +=
 # Local development
   slapos.cookbook-repository
@@ -139,6 +141,9 @@ url = ${:_profile_base_location_}/instance-cloudoo.cfg.in
 md5sum = aea927d5d3363177fd1017c4b89838d7
 mode = 640
 
+# Additional Configuration
+configurator_bt5_list = erp5_core_proxy_field_legacy erp5_full_text_myisam_catalog erp5_base erp5_workflow erp5_configurator erp5_configurator_standard erp5_configurator_maxma_demo erp5_configurator_ung
+
 [template]
 < = template-jinja2-base
 # XXX: "template.cfg" is hardcoded in instanciation recipe
diff --git a/stack/cloudooo.cfg b/stack/cloudooo.cfg
old mode 100644
new mode 100755
index 00456586c..1dbdd1fe4
--- a/stack/cloudooo.cfg
+++ b/stack/cloudooo.cfg
@@ -1,12 +1,14 @@
 [buildout]
 extensions =
-  slapos.tool.rebootstrap
+  slapos.rebootstrap
   slapos.zcbworkarounds
-  mr.developer
+  buildout-versions
 
-find-links = http://www.nexedi.org/static/packages/source/slapos.buildout/
+find-links = 
+    http://www.nexedi.org/static/packages/source/slapos.buildout/
     http://dist.repoze.org
     http://www.nexedi.org/static/packages/source/
+    http://www.owlfish.com/software/wsgiutils/download.html
 
 extends =
   ../component/libreoffice-bin/buildout.cfg 
@@ -16,18 +18,26 @@ extends =
   ../component/python-2.7/buildout.cfg
   ../component/xorg/buildout.cfg
   ../component/fonts/buildout.cfg
-  ../component/xpdf/buildout.cfg
+  ../component/git/buildout.cfg
+  ../component/poppler/buildout.cfg
   ../component/imagemagick/buildout.cfg
   ../component/pdftk/buildout.cfg
+  ../component/xpdf/buildout.cfg
   ../component/ffmpeg/buildout.cfg
   ../component/file/buildout.cfg
+  ../component/stunnel/buildout.cfg
+  ../component/rdiff-backup/buildout.cfg
+  ../component/dcron/buildout.cfg
+  ../component/coreutils/buildout.cfg
   ../component/cloudooo/buildout.cfg
-
+ 
 versions = versions
 
 parts =
   libreoffice-bin
-
+  stunnel
+  dcron
+  
 # basic Xorg
   libXdmcp
   libXext
@@ -43,30 +53,27 @@ parts =
   libpng12
   imagemagick
   file
-  xpdf 
+  poppler
+  xpdf
   pdftk
   ffmpeg
 
-  instance-recipe-egg
   bootstrap2.6
+  rdiff-backup
   cloudooo
 
-[instance-recipe-egg]
-recipe = zc.recipe.egg
-python = python2.6
-eggs =
-  ${lxml-python:egg}
-# instantiation egg
-  ${instance-recipe:egg}
+# Local development
+develop +=
+  ${:parts-directory}/cloudooo
 
 [bootstrap2.6]
 python = python2.6
 
 [rebootstrap]
 # Default first version of rebootstrapped python
-version = 2
+version = 3
 section = python2.7
 
 [versions]
 # Use SlapOS patched zc.buildout
-zc.buildout = 1.5.3-dev-SlapOS-001
+zc.buildout = 1.6.0-dev-SlapOS-003
diff --git a/stack/erp5.cfg b/stack/erp5.cfg
index 2ff059e19..555ecac05 100644
--- a/stack/erp5.cfg
+++ b/stack/erp5.cfg
@@ -3,6 +3,7 @@ extensions =
   slapos.rebootstrap
   slapos.zcbworkarounds
   buildout-versions
+  mr.developer
 
 find-links =
     http://www.nexedi.org/static/packages/source/slapos.buildout/
@@ -81,6 +82,7 @@ extends =
   ../component/dash/buildout.cfg
   ../component/wget/buildout.cfg
   ../component/aspell/buildout.cfg
+  ../component/cloudooo/buildout.cfg
 
 versions = versions
 
@@ -99,7 +101,6 @@ parts =
   stunnel
   w3m
   poppler
-  libpng12
   libpng
   ghostscript
   mariadb
@@ -432,20 +433,6 @@ scripts =
   onetimedownload
   zodbpack
 
-[cloudooo]
-recipe = zc.recipe.egg
-python = python2.6
-eggs =
-  ${lxml-python:egg}
-  cloudooo.handler.ffmpeg
-  cloudooo.handler.imagemagick
-  cloudooo.handler.ooo
-  cloudooo.handler.pdf
-  cloudooo
-  PasteScript
-scripts =
-  paster=cloudooo_paster
-
 [versions]
 # Use SlapOS patched zc.buildout
 zc.buildout = 1.6.0-dev-SlapOS-005
-- 
2.30.9