From a1192d3b029e7b0e704b29c9c4a76d5e54dac8ce Mon Sep 17 00:00:00 2001
From: Nicolas Dumazet <nicolas.dumazet@nexedi.com>
Date: Mon, 22 Feb 2010 06:00:46 +0000
Subject: [PATCH] We need different binaries depending on the architecture

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32893 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../recipes/erp5.recipe.openoffice/setup.py   | 27 +++++++++++++++
 .../src/erp5/__init__.py                      |  6 ++++
 .../src/erp5/recipe/__init__.py               |  6 ++++
 .../src/erp5/recipe/openoffice/__init__.py    | 33 +++++++++++++++++++
 buildout/software-profiles/openoffice-bin.cfg |  8 +++--
 5 files changed, 78 insertions(+), 2 deletions(-)
 create mode 100644 buildout/recipes/erp5.recipe.openoffice/setup.py
 create mode 100644 buildout/recipes/erp5.recipe.openoffice/src/erp5/__init__.py
 create mode 100644 buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/__init__.py
 create mode 100644 buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/openoffice/__init__.py

diff --git a/buildout/recipes/erp5.recipe.openoffice/setup.py b/buildout/recipes/erp5.recipe.openoffice/setup.py
new file mode 100644
index 0000000000..160f11fb75
--- /dev/null
+++ b/buildout/recipes/erp5.recipe.openoffice/setup.py
@@ -0,0 +1,27 @@
+from setuptools import setup, find_packages
+
+name = "erp5.recipe.openoffice"
+version = '0.1'
+
+setup(
+    name = name,
+    version = version,
+    author = "Nicolas Dumazet",
+    author_email = "nicolas.dumazet@nexedi.com",
+    description = "ZC Buildout recipe to install openoffice",
+    license = "ZPL 2.1",
+    keywords = "openoffice buildout",
+    classifiers=[
+      "License :: OSI Approved :: Zope Public License",
+      "Framework :: Buildout",
+      ],
+    packages = find_packages('src'),
+    include_package_data = True,
+    package_dir = {'':'src'},
+    namespace_packages = ['erp5', 'erp5.recipe'],
+    install_requires = [
+        'z3c.recipe.openoffice',
+    ],
+    zip_safe=False,
+    entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
+    )
diff --git a/buildout/recipes/erp5.recipe.openoffice/src/erp5/__init__.py b/buildout/recipes/erp5.recipe.openoffice/src/erp5/__init__.py
new file mode 100644
index 0000000000..f48ad10528
--- /dev/null
+++ b/buildout/recipes/erp5.recipe.openoffice/src/erp5/__init__.py
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
diff --git a/buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/__init__.py b/buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/__init__.py
new file mode 100644
index 0000000000..f48ad10528
--- /dev/null
+++ b/buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/__init__.py
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
diff --git a/buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/openoffice/__init__.py b/buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/openoffice/__init__.py
new file mode 100644
index 0000000000..60f8cbace0
--- /dev/null
+++ b/buildout/recipes/erp5.recipe.openoffice/src/erp5/recipe/openoffice/__init__.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import z3c.recipe.openoffice.recipe as original
+import platform
+
+class Recipe(original.Recipe):
+  """
+  Wrap z3c.recipe.openoffice to allow selecting the architecture
+  """
+  def __init__(self, buildout, name, options):
+    machine = platform.uname()[-2]
+    if machine in ('i386', 'i586', 'i686'):
+      target = 'x86_32'
+    elif machine == 'x86_64':
+      target = 'x86_64'
+    else:
+      raise ValueError('Unknown machine')
+
+    options['download-url'] = options['download-%s' % target]
+    original.Recipe.__init__(self, buildout, name, options)
diff --git a/buildout/software-profiles/openoffice-bin.cfg b/buildout/software-profiles/openoffice-bin.cfg
index a8608092b2..c489817347 100644
--- a/buildout/software-profiles/openoffice-bin.cfg
+++ b/buildout/software-profiles/openoffice-bin.cfg
@@ -1,13 +1,17 @@
 [buildout]
 parts =
   openoffice-bin
+develop =
+  recipes/erp5.recipe.openoffice
 
 [openoffice-bin]
-recipe = z3c.recipe.openoffice
+recipe = erp5.recipe.openoffice
 install-pyuno-egg = no
 hack-openoffice-python = no
-download-url =
+download-x86_64 =
   http://download.services.openoffice.org/files/stable/3.2.0/OOo_3.2.0_LinuxX86-64_install_wJRE_en-US.tar.gz
+download-x86_32 =
+  http://download.services.openoffice.org/files/stable/3.2.0/OOo_3.2.0_LinuxIntel_install_wJRE_en-US.tar.gz
 unpack-name = OOO320_m12_native_packed-1_en-US.9483
 # below version is internally used in recipe
 version = 3
-- 
2.30.9