Below is the corrected patch for this, but it's not quite ready yet.
See the email over on ports@ with some adjustments to perl.port.mk and
other patches to fix some ports fallout that sthen@ was super helpful in
tracking down.

The main issue was that somehow I lost a quote in the patch and so
it didn't work right.  But, this should apply and let you play with it
if you like.

Once we have a path forward with the ports fallout, I'll be looking for
more comments and maybe OKs.

On Sun, May 16, 2021 at 03:30:39PM -0700, Andrew Hewus Fresh wrote:
> This patch is should make it easier to recover from problems that happen
> when installing perl modules outside of the package system.  You might
> recognize the "loadable library and perl binaries are mismatched" error.
> 
> Adding a versioned subdirectory for cpan modules means that when the
> perl version changes it will no longer find those old modules and it
> will be easy to remove them without disturbing things from packages.
> 
> Only slightly related, but we can avoid breaking base tools like pkg_add
> and friend by using "no lib '/usr/local/libdata/perl5/site_perl';" to
> avoid looking in those directories at all.
> 
> 
> The new @INC looks like this.  The first "5.32.1" sitelib is where
> external things, like cpan(1), will install.  The current "site_perl"
> directory (now vendorlib) will continue to be where ports/packages go.
> Finally, "/usr/libdata" privlib is for things that ship with the base
> system.
> 
> $ perl -V | perl -ne 'print if /INC/..eof'
>   @INC:
>     /usr/local/libdata/perl5/site_perl/5.32.1/sparc64-openbsd
>     /usr/local/libdata/perl5/site_perl/5.32.1
>     /usr/local/libdata/perl5/site_perl/sparc64-openbsd
>     /usr/local/libdata/perl5/site_perl
>     /usr/libdata/perl5/sparc64-openbsd
>     /usr/libdata/perl5
> 
> 
> One place this might cause temporary issues in the ports tree is
> anything that doesn't use the overrides in perl.port.mk and looks up
> sitelib itself.  It should be fairly obvious as it should fail to
> package because the files in the PLIST will not exist (they'll be in the
> versioned subdir).  I didn't run into that in my testing, but I didn't
> complete a full bulk build.
> 
> There do appear to be some annoyances with still shared directories for
> man pages, in that if you install a CPAN module and then attempt to
> pkg_add it, it complains because "files already exist" in the man
> directory.  We could separate the cpan man pages, or I think un-setting
> the site_lib man*dir will mean cpan won't instal them.  I haven't yet
> tested that, but I'm not sure what would be best there.
> 
> 
> Unfortunately I did do a bunch of testing of different ways to add
> things to @INC which meant this patch also does some reorganization of
> the contents, I can turn it into a smaller patch if requested and do the
> cleanup separately.
> 
> 
> Comments, OK?  Should I see if sthen@ will do a full bulk build first?
 
 
Index: gnu/usr.bin/perl/config.over
===================================================================
RCS file: /cvs/src/gnu/usr.bin/perl/config.over,v
retrieving revision 1.22
diff -u -p -r1.22 config.over
--- gnu/usr.bin/perl/config.over        5 Feb 2017 00:33:38 -0000       1.22
+++ gnu/usr.bin/perl/config.over        31 Jul 2021 00:02:14 -0000
@@ -9,49 +9,85 @@ archname="`arch -s`-${osname}"
 myarchname="$archname"
 
 # Use correct paths for a distribution
-prefix='/usr'
+# site   is where cpan clients install files
+# vendor is where the ports tree puts packages
+# priv   is where the system installs files
+
+# We set up vendor paths for ports/packages
+usevendorprefix="${define}"
+d_vendorbin="${define}"
+d_vendorlib="${define}"
+d_vendorarch="${define}"
+#d_vendorscript="${define}"
+
+# Things from base go into /usr
 prefixexp='/usr'
+prefix="${prefixexp}"
 
-# But site binaries go in /usr/local/bin for ports
-siteprefix='/usr/local'
+# But vendor and site files go in /usr/local for ports and cpan
 siteprefixexp='/usr/local'
-installsitebin='/usr/local/bin'
+siteprefix="${siteprefixexp}"
+installsitebin='${siteprefix}/bin'
+
+vendorprefixexp='/usr/local'
+vendorprefix="${vendorprefixexp}"
+installvendorbin='${vendorprefix}/bin'
 
-installarchlib="/usr/libdata/perl5/${archname}"
+installprivlib="${prefix}/libdata/perl5"
+privlib="${installprivlib}"
+privlibexp="${privlib}"
+installarchlib="${installprivlib}/${archname}"
 archlib="${installarchlib}"
 archlibexp="${archlib}"
 
 test $useshrplib = "true" && ccdlflags="-Wl,-R${installarchlib}/CORE"   
 
-installprivlib="/usr/libdata/perl5"
-privlib="${installprivlib}"
-privlibexp="${privlib}"
-
-installsitearch="/usr/local/libdata/perl5/site_perl/${archname}"
-sitearch="${installsitearch}"
-sitearchexp="${sitearch}"
 
-installsitelib="/usr/local/libdata/perl5/site_perl"
+# We keep vendor in site_perl so we don't have to bump every perl port
+# otherwise this would be pkg_perl
+# Not versioned here because pkg tools handle that for us.
+installvendorlib="${vendorprefix}/libdata/perl5/site_perl"
+vendorlib="${installvendorlib}"
+vendorlibexp="${vendorlib}"
+installvendorarch="${installvendorlib}/${archname}"
+vendorarch="${installvendorarch}"
+vendorarchexp="${vendorarch}"
+
+# cpan(1) and similar tools install in a $version dir that's easy
+# to remove after upgrade and won't cause issues for packages when
+# perl versions change.
+installsitelib="${siteprefix}/libdata/perl5/site_perl/${version}"
 sitelib="${installsitelib}"
 sitelibexp="${sitelib}"
+installsitearch="${installsitelib}/${archname}"
+sitearch="${installsitearch}"
+sitearchexp="${sitearch}"
 
 installstyle="${privlib}"
 
-# We install the man pages ourselves until installman gets smarter
-man1dir='/usr/share/man/man1'
-man1direxp='/usr/share/man/man1'
-installman1dir='/usr/share/man/man1'
 man1ext='1'
-man3dir='/usr/share/man/man3p'
-man3direxp='/usr/share/man/man3p'
-installman3dir='/usr/share/man/man3p'
 man3ext='3p'
-siteman1dir='/usr/local/man/man1'
-siteman1direxp='/usr/local/man/man1'
-installsiteman1dir='/usr/local/man/man1'
-siteman3dir='/usr/local/man/man3p'
-siteman3direxp='/usr/local/man/man3p'
-installsiteman3dir='/usr/local/man/man3p'
+
+installman1dir="${prefix}/share/man/man1"
+man1dir="${installman1dir}"
+man1direxp="${man1dir}"
+installman3dir="${prefix}/share/man/man3p"
+man3dir="${installman3dir}"
+man3direxp="${man3dir}"
+
+installvendorman1dir="${vendorprefix}/man/man1"
+vendorman1dir="${installvendorman1dir}"
+vendorman1direxp="${vendorman1dir}"
+installvendorman3dir="${vendorprefix}/man/man3p"
+vendorman3dir="${installvendorman3dir}"
+vendorman3direxp="${vendorman3dir}"
+
+installsiteman1dir="${siteprefix}/man/man1"
+siteman1dir="${installsiteman1dir}"
+siteman1direxp="${siteman1dir}"
+installsiteman3dir="${siteprefix}/man/man3p"
+siteman3dir="${installsiteman3dir}"
+siteman3direxp="${siteman3dir}"
 
 # Never hardcode developer info into a distribution
 cf_by='root'
Index: gnu/usr.bin/perl/installperl
===================================================================
RCS file: /cvs/src/gnu/usr.bin/perl/installperl,v
retrieving revision 1.52
diff -u -p -r1.52 installperl
--- gnu/usr.bin/perl/installperl        1 Mar 2021 23:21:24 -0000       1.52
+++ gnu/usr.bin/perl/installperl        31 Jul 2021 00:02:14 -0000
@@ -203,6 +203,8 @@ my $installprivlib = "$opts{destdir}$Con
 my $installarchlib = "$opts{destdir}$Config{installarchlib}";
 my $installsitelib = "$opts{destdir}$Config{installsitelib}";
 my $installsitearch = "$opts{destdir}$Config{installsitearch}";
+my $installvendorlib = "$opts{destdir}$Config{installvendorlib}";
+my $installvendorarch = "$opts{destdir}$Config{installvendorarch}";
 my $installman1dir = "none";
 my $man1ext = $Config{man1ext};
 my $libperl = $Config{libperl};
@@ -340,6 +342,8 @@ mkpath($installprivlib);
 mkpath($installarchlib);
 mkpath($installsitelib, $opts{verbose}, 0777) if ($installsitelib);
 mkpath($installsitearch, $opts{verbose}, 0777) if ($installsitearch);
+mkpath($installvendorlib, $opts{verbose}, 0777) if ($installvendorlib);
+mkpath($installvendorarch, $opts{verbose}, 0777) if ($installvendorarch);
 
 if (-d 'lib') {
     find({no_chdir => 1, wanted => \&installlib}, 'lib')

Reply via email to