MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //scripts.20110531.215904.25158/realperlinstaller
#!/usr/bin/perl
# cpanel - realperlinstaller                      Copyright(c) 2010 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

BEGIN {
    eval { require CPAN::Config; };
    if ($@) {
        $CPAN::Config = {};    # Initialize the $CPAN::Config hash so that it can be updated
    }
    unshift @INC, '/usr/local/cpanel';
}

$| = 1;

#PERL SSL MODULE BROKENESS FIX
symlink '..', '/usr/local/ssl' if ( !-e '/usr/local/ssl' );

alarm(1200);

umask(0022);

use Cpanel::cPCPAN               ();
use Cpanel::cPCPAN::MirrorSearch ();
use Cpanel::cPCPAN::Config       ();
require Config;
use CPAN;

if ( !$ENV{'FROM_PERLINSTALLER'} ) {
    print STDERR "\n*** $0 should not be invoked directly ***\n" . "\nUsage: /scripts/perlinstaller " . join( " ", @ARGV ) . "\n" . "\nNOT RECOMMENDED: this restriction can be bypassed by setting FROM_PERLINSTALLER=1\n\n";
    exit;
}

my $argv = join( ' ', @ARGV );
my @ARGS = split( /\s+/, $argv );

my $cPCPAN = Cpanel::cPCPAN->new();

my $force = 0;
if ( $ARGS[0] eq '--force' ) {
    shift @ARGS;
    $force = 1;
}

my $system = $^O;
my $protoc = $system =~ m/bsd/i ? 'ftp' : 'http';

# Workaround for improperly compiled Perl that doesn't include /usr/local in libpth
# This is important for compiling XS modules successfully on FreeBSD
if ( $system =~ m/freebsd/i && $Config::Config{'libpth'} !~ m/\/usr\/local\/lib/ ) {
    if ( !eval { $Config::Config{'libpth'} .= ' /usr/local/lib' } ) {
        my $config_libpth = $Config::Config{'libpth'};
        $config_libpth .= ' /usr/local/lib';
        my %Config_Copy = %Config::Config;
        $Config_Copy{'libpth'} = $config_libpth;
        untie %Config::Config;
        %Config::Config = %Config_Copy;
    }

    if ( $Config::Config{'libpth'} =~ m/\/usr\/local\/lib/ ) {
        print "Perl libpth updated to include /usr/local/lib: $Config::Config{'libpth'}\n";
    }
    else {
        print "Failed to update Perl libpth. This may cause problems building some XS modules.\n";
        sleep 2;
    }
}

sub CPAN::Distribution::test {
    my ($self) = @_;
    $self->make;
}

my $MyConfig = $cPCPAN->fetch_config( 'prefer_cache' => 1 );
if ( $> != 0 ) {
    require Cpanel::PwCache;
    my $homedir = ( Cpanel::PwCache::getpwuid($>) )[7];
    my @ADDINC;
    foreach my $inc (@INC) {
        if ( $inc =~ m/^\Q$Config::Config{'installprefix'}\E/o ) {
            unshift @ADDINC, $homedir . '/perl' . $inc;
        }
    }
    if (@ADDINC) {
        unshift @INC, @ADDINC;
    }
}
if ( -e '/usr/lib64' ) {
    if ( -x '/scripts/cpan_sandbox/x86_64/perl' ) {
        $CPAN::Perl = '/scripts/cpan_sandbox/x86_64/perl';
    }
    $ENV{'GD_LIBS'}   = '-L/usr/lib64 -L/usr/X11R6/lib64';
    $ENV{'PATH'}      = "/scripts/cpan_sandbox/x86_64:$ENV{'PATH'}";
    $ENV{'BZLIB_LIB'} = '/usr/lib64';
    $ENV{'LDFLAGS'}   = '-L/usr/lib64 -L/usr/X11R6/lib64';
    foreach my $key ( 'makepl_arg', 'make_arg', 'make_install_arg', 'mbuildpl_arg' ) {
        my @c = split( /\s+/, $MyConfig->{$key} );
        push( @c, 'OTHERLDFLAGS=-L/usr/lib64' );
        push( @c, 'LDFLAGS=-L/usr/lib64' );
        push( @c, 'EXTRALIBDIR=/usr/lib64' );
        $MyConfig->{$key} = join( ' ', @c );
    }

}

mergeconfig( $MyConfig, $CPAN::Config );

# Determine if path to CPAN/Config.pm is set
# (won't be set if Config.pm does not exist)
my $config_path =
  exists $INC{'CPAN/Config.pm'}
  ? $INC{'CPAN/Config.pm'}
  : $INC{'CPAN.pm'};

# Set path in %INC so commit will know where to save Config.pm
# If $INC{'CPAN/Config.pm'} is not set then CPAN dies violently
if ( $config_path eq $INC{'CPAN.pm'} ) {
    $config_path =~ s{ [.]pm \z }{}xms;
    $config_path .= '/Config.pm';
    $INC{'CPAN/Config.pm'} = $config_path;
}

# Sets path for Config.pm system apps
# Called twice to set paths for newly installed apps
if ( $> == 0 && loaditems() ) {
    system '/scripts/fixbinpath';
    loaditems();
}

if ( $> == 0 ) {

    # Commit config (the completely safe way)
    CPAN::Shell->o( 'conf', 'commit' );
}

my @INSTALLMODS;    # modules to be installed

if ( $ARGS[0] =~ /^file:(\S+)/ && $ENV{'WHM50'} eq '' ) {
    my $modfile = $1;
    $modfile =~ /(.*)/;
    $modfile = $1;
    print "Reading module list from file $modfile\n";
    open my $mf_fh, $modfile or die "Could not open $modfile for reading: $!";
    while (<$mf_fh>) {
        chomp;
        push( @INSTALLMODS, $_ );
    }
    close $mf_fh;
}
else {
    @INSTALLMODS = @ARGS;
}

my $CPAN__Shell__expand = \&CPAN::Shell::expand;

# Must be evaled
eval <<'CPANSHELLEXPAND_CHANGE_END';
sub CPAN::Shell::expand {
    my @res = $CPAN__Shell__expand->(@_);
    $cPCPAN->fixupmodversions(\@res,$force);
    return wantarray ? @res : $res[0];
}
CPANSHELLEXPAND_CHANGE_END

eval 'sub CPAN::FTP::_recommend_url_for { return; }';

foreach my $module (@INSTALLMODS) {

    # Detect and skip Core modules so Perl is never reinstalled by CPAN
    my $requested_module = CPAN::Shell->expand( 'Module', $module );
    if ( $requested_module->{'RO'}{'CPAN_FILE'} =~ m{ / perl- \d \. [\d.]+ \. tar \. gz \z }xms || ( exists $requested_module->{'CPAN_COMMENT'} && $requested_module->{'CPAN_COMMENT'} =~ m/isa_perl\(.+?\)/ ) ) {
        print "cPCPAN: Core module \"$requested_module->{'ID'}\" detected. Skipped.\n";
        next;
    }

    mergeconfig( $MyConfig, $CPAN::Config );

    if ( $CPAN::VERSION < 1.80 ) {
        if ( $> == 0 ) {
            alarm(900);
            CPAN::Shell->install('Bundle::CPAN') if !Cpanel::cPCPAN::MirrorSearch::checkedcpan();
        }
        alarm(1200);
        $force
          ? CPAN::Shell->force( 'install', $module )
          : CPAN::Shell->install($module);
    }
    else {
        if ( $> == 0 ) {
            alarm(900);
            CPAN::Shell->notest( 'install', 'Bundle::CPAN' ) if !Cpanel::cPCPAN::MirrorSearch::checkedcpan();
        }
        alarm(1200);
        $force
          ? CPAN::Shell->force( 'notest', 'install', $module )
          : CPAN::Shell->notest( 'install', $module );
    }
}

print "perlmod--Install done\n";
if ( $ENV{'CPCPAN_UPDATE'} ) {
    $cPCPAN->save_version_updates();
}
exit 0;

sub mergeconfig {
    my ( $r1, $r2 ) = @_;
    foreach ( keys %{$r1} ) {
        $r2->{$_} = $r1->{$_};
    }
}

sub loaditems {
    my @ENSUREITEMS;
    my @BINPATH = qw(/bin /usr/bin /usr/local/bin);
    my @SITEMS  = qw(unzip wget tar gzip pager make ftp);
  ITEM:
    foreach my $item (@SITEMS) {
        next if -x $CPAN::Config->{$item};
      PATH:
        foreach my $path (@BINPATH) {
            my $exec = $item;
            if ( $item eq 'pager' ) { $exec = 'less' }
            if ( -e "$path/$exec" ) {
                $CPAN::Config->{$item} = "$path/$exec";
                last PATH;
            }
        }
        push( @ENSUREITEMS, $item ) if !-e $CPAN::Config->{$item};
    }

    if ( $#ENSUREITEMS >= 0 ) {
        return if $ENV{'CPANEL_BASE_INSTALL'};
        print 'Attempting to install missing CPAN items: ' . join( ',', @ENSUREITEMS ) . "\n";
        require Cpanel::SysPkgs;
        my $syspkgobj = Cpanel::SysPkgs->new();
        if ( !$syspkgobj ) {
            print "Could not create SysPkgs object, don't expect success\n";
            return;
        }
        $syspkgobj->install( 'pkglist' => \@ENSUREITEMS );
        return 1;
    }
    return 0;
}