Subject: perl modules path
To: None <tech-pkg@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-pkg
Date: 08/03/2000 18:28:46
--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii

Hi,
the way perl module works is that the Makefile is auto-generated from
a Makefile.pl, which will define, amongst others, paths for installation.
These path can contains directories specific to the version of perl (e.g.
/usr/pkg/lib/perl5/i386-netbsd/5.00404).
The problem with perl 5.005 is that it now installs modules in directories
where the perl version appears, which means that almost all our perl modules
needs to be touched when perl is upgraded. For example, with our pelr5-current
package, p5-IO-stringy installs:
lib/perl5/site_perl/5.005/IO/Stringy.pm
lib/perl5/site_perl/5.005/IO/Wrap.pm
lib/perl5/site_perl/5.005/IO/Lines.pm
lib/perl5/site_perl/5.005/IO/WrapTie.pm
lib/perl5/site_perl/5.005/IO/ScalarArray.pm
lib/perl5/site_perl/5.005/IO/AtomicFile.pm
lib/perl5/site_perl/5.005/IO/Scalar.pm
lib/perl5/5.00503/man/man3/IO::Stringy.3
lib/perl5/5.00503/man/man3/IO::Wrap.3
lib/perl5/5.00503/man/man3/IO::Lines.3
lib/perl5/5.00503/man/man3/IO::WrapTie.3
lib/perl5/5.00503/man/man3/IO::AtomicFile.3
lib/perl5/5.00503/man/man3/IO::ScalarArray.3
lib/perl5/5.00503/man/man3/IO::Scalar.3
lib/perl5/site_perl/5.005/i386-netbsd/auto/IO-stringy/.packlist

One solution would be to hack perl5-current to install things in the same place
the old perl did. The problem is that we have to do this for each perl release,
and can lead to significant divergences from a stock perl install.
The second solution is to adapt our p5-* packages to dynamically build the
PLIST. This is not that hard, because the all the needed infos are provided
by the perl binary itself:
perl -V:installman3dir
perl -V:installsitearch
perl -V:installsitelib 
perl -V:installarchlib 
(these are the ones I found usefull, there are others).
So I hacked bsd.pkg.mk to provide 4 more variables when USE_PERL5 is defined:
PERL5_MAN3DIR, PERL5_SITEARCH, PERL5_SITELIB, PERL5_ARCHLIB; and to also do  
substitution in the PLIST (this is the attached diff). For example, the PLIST
for p5-HTML-Parser looks like:
${PERL5_MAN3DIR}/HTML::Parser.3
${PERL5_MAN3DIR}/HTML::Entities.3
${PERL5_MAN3DIR}/HTML::Filter.3
${PERL5_MAN3DIR}/HTML::HeadParser.3
${PERL5_MAN3DIR}/HTML::TokeParser.3
${PERL5_MAN3DIR}/HTML::LinkExtor.3
${PERL5_SITELIB}/HTML/Parser.pm   
${PERL5_SITELIB}/HTML/Entities.pm 
${PERL5_SITELIB}/HTML/Filter.pm 
${PERL5_SITELIB}/HTML/HeadParser.pm
${PERL5_SITELIB}/HTML/LinkExtor.pm
${PERL5_SITELIB}/HTML/TokeParser.pm
${PERL5_SITEARCH}/auto/HTML/Parser/.packlist
@dirrm ${PERL5_SITEARCH}/auto/HTML/Parser   
@dirrm ${PERL5_SITELIB}/HTML

This way a perl upgrade is almost transparent for module packages (you still
need to reinstall them but 'make update' does a good job at this).
I'd like to commit the attached patch very soon. This way we could then convert
the p5-* packages to use these variables without breaking anything.
(I also have a few packages that depends on this :)

Comments ?

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--

--M9NhX3UHpAaciwkO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.374
diff -u -r1.374 bsd.pkg.mk
--- bsd.pkg.mk	1999/11/30 04:17:58	1.374
+++ bsd.pkg.mk	2000/08/03 15:47:06
@@ -114,7 +114,19 @@
 .endif
 
 .if defined(USE_PERL5)
-DEPENDS+=		perl-5.00404:${PKGSRCDIR}/lang/perl5
+DEPENDS+=		perl-*:${PKGSRCDIR}/lang/perl5
+__PERL5_MAN3DIR		!= ${LOCALBASE}/bin/perl -V:installman3dir
+_PERL5_MAN3DIR		= ${__PERL5_MAN3DIR:S|installman3dir='||:S|';||}
+PERL5_MAN3DIR		= ${_PERL5_MAN3DIR:S|${LOCALBASE}/||}
+__PERL5_SITEARCH	!= ${LOCALBASE}/bin/perl -V:installsitearch
+_PERL5_SITEARCH		= ${__PERL5_SITEARCH:S|installsitearch='||:S|';||}
+PERL5_SITEARCH		= ${_PERL5_SITEARCH:S|${LOCALBASE}/||}
+__PERL5_SITELIB		!= ${LOCALBASE}/bin/perl -V:installsitelib 
+_PERL5_SITELIB		= ${__PERL5_SITELIB:S|installsitelib='||:S|';||}
+PERL5_SITELIB		= ${_PERL5_SITELIB:S|${LOCALBASE}/||}
+__PERL5_ARCHLIB		!= ${LOCALBASE}/bin/perl -V:installarchlib
+_PERL5_ARCHLIB		= ${__PERL5_ARCHLIB:S|installarchlib='||:S|';||}
+PERL5_ARCHLIB		= ${_PERL5_ARCHLIB:S|${LOCALBASE}/||}
 .endif
 
 .if defined(USE_FORTRAN)
@@ -373,6 +385,13 @@
 		LOWER_VENDOR=${LOWER_VENDOR}			\
 		LOWER_OPSYS=${LOWER_OPSYS}			\
 		PKGNAME=${PKGNAME}
+
+.ifdef USE_PERL5
+PLIST_SUBST+=	PERL5_MAN3DIR=${PERL5_MAN3DIR}			\
+		PERL5_SITEARCH=${PERL5_SITEARCH}		\
+		PERL5_SITELIB=${PERL5_SITELIB}			\
+		PERL5_ARCHLIB=${PERL5_ARCHLIB}
+.endif
 
 # Set INSTALL_FILE to be the name of any INSTALL file
 .if !defined(INSTALL_FILE) && exists(${PKGDIR}/INSTALL)

--M9NhX3UHpAaciwkO--