Subject: Proposal: changing the default perl library search path
To: None <tech-pkg@netbsd.org>
From: Johnny Lam <jlam@jgrind.org>
List: tech-pkg
Date: 01/24/2002 21:33:05
--+QahgC5+KEYLbs62
Content-Type: text/plain; charset=us-ascii

I think we need to change the default module/library search path for Perl
to have site_perl come before the standard directories.  In other words,
right now the path on an i386 is:

    /usr/pkg/lib/perl5/5.6.1/i386-netbsd
    /usr/pkg/lib/perl5/5.6.1
    /usr/pkg/lib/perl5/site_perl/5.6.1/i386-netbsd
    /usr/pkg/lib/perl5/site_perl/5.6.1
    /usr/pkg/lib/perl5/site_perl

but I think it should look like:

    /usr/pkg/lib/perl5/site_perl/5.6.1/i386-netbsd
    /usr/pkg/lib/perl5/site_perl/5.6.1
    /usr/pkg/lib/perl5/site_perl
    /usr/pkg/lib/perl5/5.6.1/i386-netbsd
    /usr/pkg/lib/perl5/5.6.1

The patch that makes this change is attached below.

The rationale for this is that when we install a module that is newer than
one in the standard library, the new module goes into the site_perl
directory as it's an add-on module.  However, we can't use the newer module
without modifying either the scripts of the perl environment to find the
newer module explicitly because of the order of the library search path:
the site_perl directories come after the standard directories.  The normal
solution is to directly replace the module in the standard library with
the newer module.  However, this isn't really on option when installing
via pkgsrc because the older module files are owned by the perl package.

By placing the the site_perl directories before the standard directories,
newer modules that we install via pkgsrc are simply found before the older
ones in the standard library.  The only bad point I see is that the pkgsrc
perl will differ in behaviour from a vanilla perl installation in the order
of the search path.  I'm not sure if users rely on the order of the search
path present in the vanilla installation.  However, I still think it's
needed in the pkgsrc perl since we can't replace parts of the perl library.

Please share your thoughts.  The PR that I'm working on that relates to
this problem is pkg/15342, where the latest release of CGI.pm fixes an
important bug present in CGI.pm-2.752, which is included in the perl-5.6.1
base library.

	Thanks,

	-- Johnny Lam <jlam@jgrind.org>

--+QahgC5+KEYLbs62
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-ah

$NetBSD$

--- perl.c.orig	Thu Mar 22 00:05:02 2001
+++ perl.c
@@ -3408,12 +3408,32 @@
     }
 
 /* Use the ~-expanded versions of APPLLIB (undocumented),
-    ARCHLIB PRIVLIB SITEARCH SITELIB VENDORARCH and VENDORLIB
+    SITEARCH SITELIB ARCHLIB PRIVLIB VENDORARCH and VENDORLIB
 */
 #ifdef APPLLIB_EXP
     incpush(APPLLIB_EXP, TRUE, TRUE);
 #endif
 
+#ifdef SITEARCH_EXP
+    /* sitearch is always relative to sitelib on Windows for
+     * DLL-based path intuition to work correctly */
+#  if !defined(WIN32)
+    incpush(SITEARCH_EXP, FALSE, FALSE);
+#  endif
+#endif
+
+#ifdef SITELIB_EXP
+#  if defined(WIN32)
+    incpush(SITELIB_EXP, TRUE, FALSE);	/* this picks up sitearch as well */
+#  else
+    incpush(SITELIB_EXP, FALSE, FALSE);
+#  endif
+#endif
+
+#ifdef SITELIB_STEM /* Search for version-specific dirs below here */
+    incpush(SITELIB_STEM, FALSE, TRUE);
+#endif
+
 #ifdef ARCHLIB_EXP
     incpush(ARCHLIB_EXP, FALSE, FALSE);
 #endif
@@ -3445,26 +3465,6 @@
     incpush(PRIVLIB_EXP, TRUE, FALSE);
 #else
     incpush(PRIVLIB_EXP, FALSE, FALSE);
-#endif
-
-#ifdef SITEARCH_EXP
-    /* sitearch is always relative to sitelib on Windows for
-     * DLL-based path intuition to work correctly */
-#  if !defined(WIN32)
-    incpush(SITEARCH_EXP, FALSE, FALSE);
-#  endif
-#endif
-
-#ifdef SITELIB_EXP
-#  if defined(WIN32)
-    incpush(SITELIB_EXP, TRUE, FALSE);	/* this picks up sitearch as well */
-#  else
-    incpush(SITELIB_EXP, FALSE, FALSE);
-#  endif
-#endif
-
-#ifdef SITELIB_STEM /* Search for version-specific dirs below here */
-    incpush(SITELIB_STEM, FALSE, TRUE);
 #endif
 
 #ifdef PERL_VENDORARCH_EXP

--+QahgC5+KEYLbs62--