From dde27023ae056365d639752c58af305e3a798ad3 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Tue, 7 Jun 2011 12:14:31 +0200
Subject: [PATCH] Create bt5 repositories

---
 slapos/recipe/bef_erp5/__init__.py | 22 ++++++++++++++++++++++
 software/sanef/instance.cfg        |  5 +++++
 software/sanef/software.cfg        | 12 +++++++++++-
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/slapos/recipe/bef_erp5/__init__.py b/slapos/recipe/bef_erp5/__init__.py
index 5f964a52f..079485c40 100644
--- a/slapos/recipe/bef_erp5/__init__.py
+++ b/slapos/recipe/bef_erp5/__init__.py
@@ -283,6 +283,27 @@ class Recipe(slapos.recipe.erp5.Recipe):
     ))
     return self.path_list
 
+  def installBT5Repo(self):
+    """
+    Create read only repo in the partition, to ease ERP5 configuration
+    """
+    repo_path = os.path.join(self.var_directory, "bt5repo")
+    if not os.path.isdir(repo_path):
+      os.mkdir(repo_path)
+    for repo in self.options.get('bt5_repo_list', '').splitlines():
+      if not repo:
+        continue
+      target, linkname = linkline.split()
+      link = os.path.join(repo_path, 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(repo_path)
+
   def _install(self):
     self.path_list = []
     self.requirements, self.ws = self.egg.working_set()
@@ -294,6 +315,7 @@ class Recipe(slapos.recipe.erp5.Recipe):
           'killpidfromfile')], self.ws, sys.executable, self.bin_directory)[0]
     self.path_list.append(self.killpidfromfile)
     self.linkBinary()
+    self.installBT5Repo()
     if self.parameter_dict.get('development', 'false').lower() == 'true':
       self.development = True
       return self.installDevelopmentEnvironment()
diff --git a/software/sanef/instance.cfg b/software/sanef/instance.cfg
index e9e314fac..8dbd80573 100644
--- a/software/sanef/instance.cfg
+++ b/software/sanef/instance.cfg
@@ -59,6 +59,11 @@ link_binary_list =
   ${xpdf:location}/bin/pdftotext
   ${xtrabackup:location}/bin/xtrabackup_51
 
+bt5_repo_list = 
+  ${erp5:location}/product/ERP5/bootstrap bt5bootstrap
+  ${erp5:location}/bt5 bt5erp5
+  ${bt5-bef:location} bt5bef
+
 # XXX: products won't be needed as soon as all ERP5 (and products-deps)
 # products will be eggified so then it will be possible to use them thanks to
 # availability in software's eggs
diff --git a/software/sanef/software.cfg b/software/sanef/software.cfg
index ffe4a86c5..61f0406ed 100644
--- a/software/sanef/software.cfg
+++ b/software/sanef/software.cfg
@@ -10,6 +10,8 @@ parts +=
   mysql-tritonn-5.0
   products-bef
   products-upgrade
+  bt5-bef
+  bt5-repository
 
 [eggs]
 # Just so buildout executes [bef_erp5-recipe] before [eggs], as
@@ -30,7 +32,7 @@ extra-paths +=
 
 [template]
 url = ${:_profile_base_location_}/instance.cfg
-md5sum = 8ed5e0c3dcbde0f88e18dba0d364fabf
+md5sum = 9487896be21080323462a5f289db6c5e
 
 [instance-recipe]
 egg = slapos.cookbook
@@ -47,6 +49,14 @@ location = ${buildout:parts-directory}/${:_buildout_section_name_}
 stop-on-error = true
 update-command = ${:command}
 
+[bt5-repository]
+recipe = plone.recipe.command
+stop-on-error = true
+command =
+  ${erp5:location}/product/ERP5/bin/genbt5list ${erp5:location}/product/ERP5/bootstrap ${erp5:location}/bt5 ${bt5-bef:location}
+update-command = ${:command}
+  
+
 [bt5-bef]
 <= bef-svn-template
 command =
-- 
2.30.9