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: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/installgd
#!/usr/bin/perl
# cpanel - installgd                              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 { unshift @INC, '/usr/local/cpanel'; }

use IPC::Open3 ();
use Config;
use Cpanel::SysPkgs ();

my $gdstatus = getgdstatus();
if ($gdstatus) {
    print "GD installed ok\n";
    exit;
}

system("/scripts/bsdldconfig");

my $compiler_broken = system("/scripts/checkccompiler");
if ($compiler_broken) {
    print "The C compiler appears to be broken.  GD cannot be installed until this is resolved.\n";
    exit 1;
}

my (@RPMLIST);

if ( -e "/etc/debian_version" ) {
    @RPMLIST = ( "freetype2", "freetype-dev", "freetype", "freetype-devel", "libfreetype6", "libfreetype6-dev", "libjpeg62", "libjpeg62-dev" );
}
else {
    @RPMLIST = ( "freetype2", "freetype2-devel", "freetype", "freetype-devel" );
}
my @pkgs = ( @RPMLIST, "perl-CPAN", "libpng-devel", "libjpeg-devel", "XFree86-devel", "iconv", "jpeg", "xpm", "png", "linuxthreads" );
my $syspkgobj = Cpanel::SysPkgs->new();
if ( !$syspkgobj ) { die print "Could not create SysPkgs object\n"; }
$syspkgobj->install( 'pkglist' => \@pkgs );

my $brokeninstall = 0;
print "Building GD....";
open( RNULL, "<", "/dev/null" );
my $perlpid = IPC::Open3::open3( ">&RNULL", ">&STDOUT", \*ERH, "/scripts/perlinstaller", "Tree::MultiNode", "GD", "GD::Graph" );
while (<ERH>) {
    print "......\n";
    if (/^[\s\t]*make:.*GD.*Error/) {
        $brokeninstall = 1;
    }
}
close(RNULL);
close(ERH);
waitpid( $perlpid, 0 );
print "Done\n";

fixgdImagepmbug();

my $gdstatus = getgdstatus($brokeninstall);

print "GD status [$gdstatus]\n";

if ( !$gdstatus ) {
    system("/scripts/fetchgd");
    system( '/scripts/perlinstaller', "Tree::MultiNode", "GD::Graph" );
    system( "/scripts/perlinstaller", "--force",         "GD" );
}
else {
    print "GD installed ok\n";
    exit;
}

fixgdImagepmbug();

my $gdstatus = getgdstatus();

if ($gdstatus) {
    print "GD installed ok\n";
}
else {
    system( '/scripts/cleangd', '--quit' );
    system('/scripts/fetchgd');
    system( '/scripts/perlinstaller', "Tree::MultiNode", "GD::Graph" );
    system( '/scripts/perlinstaller', '--force',         'GD' );
}

my $gdstatus = getgdstatus();

if ($gdstatus) {
    print "GD installed ok\n";
}
else {
    print "GD install failed\n";
}

sub getgdstatus {
    my ($brokeninstall) = @_;
    if ($brokeninstall) { return (0); }
    my $hasgd = 0;
    eval {
        require GD;
        $hasgd = 1;
    };
    open( WNULL, ">", "/dev/null" );
    open( RNULL, "<", "/dev/null" );
    my $gdpid = IPC::Open3::open3( "<&RNULL", ">&WNULL", \*ERR, "/scripts/checkgd" );
    while (<ERR>) {
        if ( /Undefined/i || /error/i ) {
            $hasgd = 0;
        }
    }
    close(ERR);
    close(WNULL);
    close(RNULL);
    waitpid( $gdpid, 0 );

    open( WNULL, ">", "/dev/null" );
    open( RNULL, "<", "/dev/null" );
    $gdpid = IPC::Open3::open3( "<&RNULL", \*ERR, ">&WNULL", "/scripts/checkgd" );
    while (<ERR>) {
        if ( /missing/i || /error/i ) {
            $hasgd = 0;
        }
    }
    close(ERR);
    close(WNULL);
    close(RNULL);
    waitpid( $gdpid, 0 );

    return ($hasgd);
}

sub fixgdImagepmbug {

    my (@MISSINGFILES) = ( 'GD/Polygon.pm', 'GD/Image.pm' );

    my $testfile = "$Config{sitearch}/GD/Simple.pm";

    my (@GD);
    opendir( BD, "/home/.cpan/build" );
    while ( my $file = readdir(BD) ) {
        if ( $file =~ /^GD-/ ) { push( @GD, $file ); }
    }
    closedir(BD);

    foreach my $missingfile (@MISSINGFILES) {
        my $distfile = "/home/.cpan/build/$GD[0]/${missingfile}";

        if ( -e $testfile && !-e "$Config{sitearch}/${missingfile}" ) {
            print "${missingfile} installer bug detected!\n";
            if ( -e $distfile ) {
                print "${missingfile} BugFix Activated: $distfile -> $Config{sitearch}/${missingfile}\n";
                system( "install", "-m", "444", $distfile, "$Config{sitearch}/${missingfile}" );
            }
            else {
                print "${distfile} is missing, cannot activate workaround!\n";
            }
        }
    }
}