From 56c10a3cd15bbcb0863d5963dcfb112bbcb5f45b Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Mon, 26 Nov 2018 16:05:17 +0100
Subject: [PATCH] slapos/obs: Set PERL5LIB and additional perl configurations

  This change is to follow up recent refactorization and perl and CPAN Setup.
---
 component/perl/buildout.cfg |  9 +++++++--
 component/slapos/obs.cfg    | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/component/perl/buildout.cfg b/component/perl/buildout.cfg
index 8cfd698e1..93ff52f38 100644
--- a/component/perl/buildout.cfg
+++ b/component/perl/buildout.cfg
@@ -54,6 +54,9 @@ install-inc =
 #  - extra arguments passed to perl Makefile.PL
 extra-configure-args =
 
+# - extra environ varialbles for configure and make
+extra-env =
+
 # Outputs:
 #  - site_perl, to use in inc in dependent packages
 site_perl=${:location}/lib/site_perl/${perl:version}:${:location}:${:inc}
@@ -64,12 +67,14 @@ perl-PATH = ${:location}/bin/
 #  dependencies
 perl-bin = ${:perl-PATH}/perl
 
+perl-PERL5LIB = 
 
 # Implementation
 recipe = slapos.recipe.cmmi
 url = https://www.cpan.org/modules/by-module/${:module}-${:version}.tar.gz
 configure-command =
-  PERL5LIB="${:inc}:${:install-inc}" \
+  ${:extra-env}
+  PERL5LIB="${:inc}:${:install-inc}:${:perl-PERL5LIB}" \
   ${perl:location}/bin/perl \
   Makefile.PL \
   PREFIX=${:location} \
@@ -80,7 +85,7 @@ make-options =
   INSTALLSITESCRIPT=${:location}/perl-bin/
 
 make-binary=
-  PERL5LIB="${:inc}:${:install-inc}" make
+  ${:extra-env} PERL5LIB="${:inc}:${:install-inc}:${:perl-PERL5LIB}" make
 
 # this post-make-hook is same for all users of the macro.
 post-make-hook = ${:_profile_base_location_}/../../component/perl/perl-CPAN-package-create-wrapper.py#d012f7ba3300b14b2c6b173351d410be:post_make_hook
diff --git a/component/slapos/obs.cfg b/component/slapos/obs.cfg
index 0a1de7a72..eef382712 100644
--- a/component/slapos/obs.cfg
+++ b/component/slapos/obs.cfg
@@ -41,6 +41,26 @@ configure-options +=
 make-options +=
   DESTDIR=${buildout:destdir}
 
+environment +=
+  PERL5LIB=${perl:location}/lib/5.26.1/
+
+[intltool]
+environment +=
+  PERL5LIB=${perl:location}/lib/5.26.1/
+
+[autoconf]
+environment +=
+  PERL5LIB=${perl:location}/lib/5.26.1/
+
+[automake]
+environment +=
+  PERL5LIB=${perl:location}/lib/5.26.1/
+
+[firewalld]
+environment +=
+  PERL5LIB=${perl:location}/lib/5.26.1/
+
+
 [dbus]
 configure-options +=
   --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
@@ -99,6 +119,7 @@ environment +=
   LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${libffi:location}/lib -Wl,-rpath=${libffi:location}/lib -lffi -L${python2.7:location}/lib
   ACLOCAL_PATH=${pkgconfig:location}/share/aclocal:${gettext:location}/share/aclocal:${libtool:location}/share/aclocal:${glib:location}/share/aclocal:${intltool:location}/share/aclocal
   M4=${m4:location}/bin/m4
+  PERL5LIB=${perl:location}/lib/5.26.1/
 
 post-install = 
   sed -i 's#!${python2.7:location}/bin/python2.7#!/opt/slapos/parts/python2.7/bin/python2.7#' ${python2.7:location}/bin/python-config
@@ -129,6 +150,17 @@ configure-options =
 environment +=
  BISON_PKGDATADIR=${bison:location}/share/bison/
 
+
+[perl-CPAN-package]
+perl-PERL5LIB=${perl:location}/lib/5.26.1/
+
+pre-configure =
+  sed -i "s#'/opt/slapos/parts/perl#'${perl:location}#" ${perl:location}/lib/5.26.1/x86_64-linux-thread-multi/Config.pm
+  sed -i "s#'/opt/slapos/parts/site_perl#'${buildout:destdir}/parts/site_perl#" ${perl:location}/lib/5.26.1/x86_64-linux-thread-multi/Config.pm
+post-install =
+  sed -i "s#'${perl:location}#'/opt/slapos/parts/perl#" ${perl:location}/lib/5.26.1/x86_64-linux-thread-multi/Config.pm
+  sed -i "s#'${buildout:destdir}/parts/site_perl#'/opt/slapos/parts/site_perl#" ${perl:location}/lib/5.26.1/x86_64-linux-thread-multi/Config.pm
+
 [perl]
 location = ${buildout:destdir}/parts/perl
 configure-command =
-- 
2.30.9