From a6df0ebf8db8590078d93871ef084865b8cffc62 Mon Sep 17 00:00:00 2001
From: Viktor Horvath <technique@alixen.fr>
Date: Wed, 19 Sep 2012 14:46:16 +0200
Subject: [PATCH] Perl: compile Perl 5.14.2 for Mioga, for AMD64 systems;
 Apache-Perl: compile mod_apreq2 and the Perl module Apache2::Request; Mioga:
 include simple modules like Date::Perl.

This needs a recent version of the CPAN recipe to work!
(starting with commit 018da2d)
---
 component/apache-perl/buildout.cfg          | 15 ++++++--
 component/perl/buildout.cfg                 |  8 +++--
 slapos/recipe/apacheperl/template/apache.in | 13 +++----
 software/mioga/instance.cfg                 | 27 ++++++++-------
 software/mioga/software.cfg                 | 38 +++++++++++++++++++--
 5 files changed, 76 insertions(+), 25 deletions(-)

diff --git a/component/apache-perl/buildout.cfg b/component/apache-perl/buildout.cfg
index 3165218eb..39750bde5 100644
--- a/component/apache-perl/buildout.cfg
+++ b/component/apache-perl/buildout.cfg
@@ -1,5 +1,5 @@
 [buildout]
-parts = apache-perl
+parts = apache-perl perl-Apache2-Request
 
 extends =
   ../apache/buildout.cfg
@@ -15,7 +15,16 @@ configure-command =
   ${perl:location}/bin/perl Makefile.PL
 configure-options =
   MP_AP_PREFIX=${apache-2.2:location}
+  LIBS="-L${libuuid:location}/lib -Wl,-rpath=${libuuid:location}"
 
+# for mod_apreq2 and Apache2::Request
+[perl-Apache2-Request]
+recipe = slapos.recipe.build:cpan
+modules =
+  I/IS/ISAAC/libapreq2-2.13.tar.gz
+perl = perl
+cpan-configuration =
+  makepl_arg = --with-apache2-apxs=${apache-2.2:location}/bin/apxs
 environment =
-  # CPPFLAGS=-I${libuuid:location}/include
-  MP_CCOPTS=-L${libuuid:location}/lib
+  APR_LDFLAGS = -L${libuuid:location}/lib -Wl,-R${libuuid:location}/lib -L${libexpat:location}/lib -Wl,-R${libexpat:location}/lib -L${apache-2.2:location}/lib -Wl,-R${apache-2.2:location}/lib
+  LDFLAGS=-L${libuuid:location}/lib -Wl,-rpath=${libuuid:location}/lib -L${libexpat:location}/lib -Wl,-rpath=${libexpat:location}/lib -L${apache-2.2:location}/lib -Wl,-rpath=${apache-2.2:location}/lib
diff --git a/component/perl/buildout.cfg b/component/perl/buildout.cfg
index 0041bcba7..575ee2879 100644
--- a/component/perl/buildout.cfg
+++ b/component/perl/buildout.cfg
@@ -16,15 +16,18 @@ filename = ${:_buildout_section_name_}
 recipe = hexagonit.recipe.cmmi
 depends =
   ${gdbm:version}
-version = 5.16.0
+version = 5.14.2
 url = http://www.cpan.org/src/5.0/perl-${:version}.tar.bz2
-md5sum = 15a2f95fb27231e10998240f13acf961
+md5sum = 04a4c5d3c1f9f19d77daff8e8cd19a26
 siteprefix = ${buildout:parts-directory}/site_${:_buildout_section_name_}
 patch-options = -p1
 patches =
   ${perl-keep-linker-flags-in-ldflags.patch:location}/${perl-keep-linker-flags-in-ldflags.patch:filename}
+# Viktor has adapted the following commands for AMD64 compilation
+# TODO: find out how we can write a generic code that suits all architectures
 configure-command =
   sh Configure -des \
+    -A ccflags=-fPIC \
     -Dprefix=${buildout:parts-directory}/${:_buildout_section_name_} \
     -Dsiteprefix=${:siteprefix} \
     -Dcflags=-I${gdbm:location}/include \
@@ -33,3 +36,4 @@ configure-command =
     -Dnoextensions=ODBM_File
 environment =
   PATH=${patch:location}/bin:%(PATH)s
+  CFLAGS='-m64 -mtune=nocona'
diff --git a/slapos/recipe/apacheperl/template/apache.in b/slapos/recipe/apacheperl/template/apache.in
index 9adab64e4..42e6940bc 100644
--- a/slapos/recipe/apacheperl/template/apache.in
+++ b/slapos/recipe/apacheperl/template/apache.in
@@ -7,6 +7,7 @@ LoadModule headers_module modules/mod_headers.so
 LoadModule dir_module modules/mod_dir.so
 LoadModule mime_module modules/mod_mime.so
 LoadModule perl_module modules/mod_perl.so
+LoadModule apreq_module modules/mod_apreq2.so
 
 # Basic server configuration
 PidFile "%(pid_file)s"
@@ -33,7 +34,7 @@ CustomLog "%(access_log)s" common
   use Apache2::RequestIO ();
   use Apache2::RequestRec ();
 
-  # use Apache2::Request;
+  use Apache2::Request;
   use Date::Calc ();
 
   sub test_handler {
@@ -48,11 +49,11 @@ CustomLog "%(access_log)s" common
       $r->print("Testing Date::Calc: English ordinal for current year is "
         . Date::Calc::English_Ordinal($year) . "\n");
     }
-    # {
-    #   my $apreq = new Apache2::Request($r);
-    #   my $hello = $apreq->param('hello');
-    #   $r->print("Testing Apache2::Request: The parameter 'hello' is '$hello'\n");
-    # }
+    {
+      my $apreq = new Apache2::Request($r);
+      my $hello = $apreq->param('hello');
+      $r->print("Testing Apache2::Request: The parameter 'hello' is '$hello'\n");
+    }
     return Apache2::Const::OK;
   }
 </Perl>
diff --git a/software/mioga/instance.cfg b/software/mioga/instance.cfg
index fffebea8f..017d14069 100644
--- a/software/mioga/instance.cfg
+++ b/software/mioga/instance.cfg
@@ -1,17 +1,20 @@
 [buildout]
+parts =
+  switch-softwaretype
+
 eggs-directory = ${buildout:eggs-directory}
 develop-eggs-directory = ${buildout:develop-eggs-directory}
+offline = true
 
-parts = instance
-
-[instance]
-recipe = ${instance-recipe:egg}:${instance-recipe:module}
-source = ${application:location}
-template = ${application-template:location}/${application-template:filename}
-configuration = ${application-configuration:location}
+[switch-softwaretype]
+recipe = slapos.cookbook:softwaretype
+default = ${template-apacheperl:output}
 
-httpd_binary = ${apache:location}/bin/httpd
-mysql_binary = ${mariadb:location}/bin/mysql
-mysql_install_binary = ${mariadb:location}/bin/mysql_install_db
-mysql_upgrade_binary = ${mariadb:location}/bin/mysql_upgrade
-mysqld_binary = ${mariadb:location}/libexec/mysqld
+[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}
\ No newline at end of file
diff --git a/software/mioga/software.cfg b/software/mioga/software.cfg
index 10f53fd5f..74ee96e1d 100644
--- a/software/mioga/software.cfg
+++ b/software/mioga/software.cfg
@@ -1,9 +1,43 @@
 [buildout]
-extends = 
-  ../../component/postgresql/buildout.cfg
+develop =
+  /srv/slapgrid/slappart9/srv/runner/project/slapos
+  /opt/slapdev_build
+
+# ../../component/postgresql/buildout.cfg
+extends =
   ../../component/apache-perl/buildout.cfg
+  ../../component/lxml-python/buildout.cfg  
   ../../stack/slapos.cfg
 
+# parts = eggs postgresql apache-perl template perl-Apache2-Request
+parts = eggs cpan-simple-modules apache-perl template perl-Apache2-Request
+
+[eggs]
+recipe = zc.recipe.egg
+eggs =
+  ${lxml-python:egg}
+  slapos.cookbook
+
+[template]
+recipe = slapos.recipe.template
+url = ${:_profile_base_location_}/instance.cfg
+# md5sum = 
+output = ${buildout:directory}/template.cfg
+mode = 0644
+
+[template-apacheperl]
+recipe = slapos.recipe.template
+url = ${:_profile_base_location_}/instance-apacheperl.cfg
+# md5sum = 
+output = ${buildout:directory}/template-apacheperl.cfg
+mode = 0644
+
+[cpan-simple-modules]
+recipe = slapos.recipe.build:cpan
+modules =
+  S/ST/STBEY/Date-Calc-6.3.tar.gz
+perl = perl
+
 [networkcache]
 # Cedric de Saint Martin signature certificate
 signature-certificate-list =
-- 
2.30.9