[Rt-commit] rt branch, 4.0/force-sitelib-installs, created. rt-4.0.5-79-g343e1b0

Alex Vandiver alexmv at bestpractical.com
Wed Feb 29 13:10:27 EST 2012


The branch, 4.0/force-sitelib-installs has been created
        at  343e1b058610685fa6e8a086ed6b9aac55543f50 (commit)

- Log -----------------------------------------------------------------
commit 343e1b058610685fa6e8a086ed6b9aac55543f50
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Feb 29 02:01:55 2012 -0500

    Force dual-life modules to be installed into site_perl if possible
    
    Generally, perl prior to 5.11 had privlib (the core perl libraries)
    before sitelib.  However, some helpful distributions (RedHat, Debian,
    etc) patched perl to have site_perl come before core perl.
    Unfortunately, the dual-life modules don't know this, and still assume
    they need to install into core perl for the updated module to be seen --
    which the distribution will promptly clobber if it ever reinstalls its
    perl package.
    
    Detect such patched perls, identifiable by being < 5.11, but having
    sitelib before privlib, and set INSTALLDIRS=site.  This tells CPAN to
    force installation into the site_perl directory, even for dual-life
    modules, which will prevent them being later clobbered by the package.
    
    This change, while it will lead to fewer installs broken by
    distributions, does have the downside that running a simple `cpan
    modulename` later will update the core version, which will be shadowed
    by the site_perl version.  We thus allow the --no-siteinstall option to
    configure to disable this new behavior.

diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index 03c813b..e1f9ef1 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -78,6 +78,7 @@ GetOptions(
     'download=s',
     'repository=s',
     'list-deps',
+    'siteinstall!',
     'help|h',
 );
 
@@ -457,6 +458,27 @@ sub resolve_dep {
     my $module = shift;
     my $version = shift;
 
+    unless (defined $args{siteinstall}) {
+        require Config;
+        my %uniq;
+        my @order = grep {($_ eq $Config::Config{sitelibexp}
+                        or $_ eq $Config::Config{privlibexp})
+                        and not $uniq{$_}++} @INC;
+        if ($] < 5.011 and @order == 2
+                and $order[0] eq $Config::Config{sitelibexp}
+                and $order[1] eq $Config::Config{privlibexp}) {
+
+            print "\n";
+            print "Patched perl, with site_perl before core in \@INC, detected.\n";
+            print "Installing dual-life modules into site_perl so they are not\n";
+            print "later overridden by the distribution's package.\n";
+
+            $args{siteinstall} = 1;
+        } else {
+            $args{siteinstall} = 0;
+        }
+    }
+
     print "\nInstall module $module\n";
 
     my $ext = $ENV{'RT_FIX_DEPS_CMD'} || $ENV{'PERL_PREFER_CPAN_CLIENT'};
@@ -476,6 +498,12 @@ Please run `@PERL@ -MCPAN -e shell` to configure it.
 END
             exit(1);
         }
+
+        my $installdirs = $CPAN::Config->{makepl_arg} ||= "";
+        $installdirs =~ s/(\bINSTALLDIRS=\S+|$)/ INSTALLDIRS=site/
+            if $args{siteinstall};
+        local $CPAN::Config->{makepl_arg} = $installdirs;
+
         my $rv = eval { require CPAN; CPAN::Shell->install($module) };
         return $rv unless $@;
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list