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/fix_sa_compile
#!/usr/bin/perl
# cpanel - fix_sa_compile                         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 Cpanel::FindBin  ();
use Cpanel::LoadFile ();
use Cpanel::Usage    ();

my $verbose = 0;
my %opts = ( 'verbose' => \$verbose );

Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts );

# sa-compile specifies site-perl in a use lib line.  If perl has been updated and any of the modules in
# site-perl are broken, sa-compile will be loading them first and cause fun breakage.

### ADD ANY OTHER MODULES THAT NEED TO BE CHECKED HERE ###
my @check_modules = ('Errno');

my $sa_compile;
foreach my $argv (@ARGV) {
    next if $argv =~ m/^--/;
    $sa_compile = $argv;
    last;
}

if ( !$sa_compile ) {
    $sa_compile = Cpanel::FindBin::findbin( 'sa-compile', 'path' => [ '/usr/sbin', '/usr/local/sbin', '/usr/bin', '/usr/local/bin' ] );
}

die "Could not locate sa-compile" unless $sa_compile;

my $sa_compile_text = Cpanel::LoadFile::loadfile($sa_compile);
if ( !$sa_compile_text ) {
    die "Unable to load $sa_compile\n";
}

if ( $sa_compile_text =~ m/^\s*use\s*lib\s*['"]([^'"]+)['"]/m ) {
    my $libpath = $1;
    print "Search path: $libpath\n" if $verbose;
    foreach my $module (@check_modules) {
        if ($verbose) {
            print "Checking module $module\n";
        }
        my $broken_module = 1;
        eval "use lib '$libpath'; use $module; \$broken_module = 0;";

        if ($broken_module) {
            print "$module.pm appears to be broken - attempting to autofix...\n" if $verbose;
            system '/scripts/perlinstaller', '--force', $module;
            eval "use lib '$libpath'; use $module; \$broken_module = 0;";
            print $broken_module ? "$module update appears to have failed\n" : "$module updated successfully\n" if $verbose;
        }
        else {
            print "$module.pm appears to be working.\n" if $verbose;
        }
    }
}

sub usage {
    print <<'EOM';
fix_sa_compile - Fix perl module problems caused by sa-compile's use of site-perl

fix_sa_compile [options]

    Options:
      --help       Brief help message
      --verbose    Show information about each module being checked
EOM
    exit;
}

1;