<commit_before>#!/usr/bin/perl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

use lib qw(/opt/traffic_ops/install/lib /opt/traffic_ops/lib/perl5 /opt/traffic_ops/app/lib);

package BuildPerlDeps;

use strict;
use warnings;

use InstallUtils qw{ :all };

use base qw{ Exporter };
our @EXPORT_OK = qw{ build };
our %EXPORT_TAGS = ( all => \@EXPORT_OK );

sub build {
    my $opt_i       = shift;
    my $cpanLogFile = shift;

    my @dependencies = ( "expat-devel", "mod_ssl", "mkisofs", "libpcap", "libpcap-devel", "libcurl", "libcurl-devel", "openssl", "openssl-devel", "cpan", "gcc", "make", "pkgconfig", "automake", "autoconf", "libtool", "gettext", "libidn-devel" );

    my $msg = << 'EOF';

This script will build and package the required Traffic Ops perl modules.
In order to complete this operation, Development tools such as the gcc
compiler will be installed on this machine.

EOF

    $ENV{PERL_MM_USE_DEFAULT}    = 1;
    $ENV{PERL_MM_NONINTERACTIVE} = 1;
    $ENV{AUTOMATED_TESTING}      = 1;

    my $result;

    if ( $ENV{USER} ne "root" ) {
        errorOut("You must run this script as the root user");
    }

    InstallUtils::logger( $msg, "info" );

    chdir("/opt/traffic_ops/app");

    if ( defined $opt_i && $opt_i == 1 ) {
        if ( !-x "/usr/bin/yum" ) {
            errorOut("You must install 'yum'");
        }

        InstallUtils::logger( "Installing dependencies", "info" );
        $result = InstallUtils::execCommand( "/usr/bin/yum", "-y", "install", @dependencies );
        if ( $result != 0 ) {
            errorOut("Dependency installation failed, look through the output and correct the problem");
        }
        InstallUtils::logger( "Building perl modules", "info" );

        $result = InstallUtils::execCommand( "/usr/bin/cpan", "pi_custom_log=" . $cpanLogFile, "-if", "YAML" );
        if ( $result != 0 ) {
            errorOut("Failed to install YAML, look through the output and correct the problem");
        }

        $result = InstallUtils::execCommand( "/usr/bin/cpan", "pi_custom_log=" . $cpanLogFile, "-if", "MIYAGAWA/Carton-v1.0.15.tar.gz" );
        if ( $result != 0 ) {
            errorOut("Failed to install Carton, look through the output and correct the problem");
        }
    }

    $result = InstallUtils::execCommand( "/usr/local/bin/carton", "install" );
    if ( $result != 0 ) {
        errorOut("Failure to build required perl modules, check the output and correct the problem");
    }

    if ( !-s "/opt/traffic_ops/lib/perl5" ) {
        InstallUtils::logger( "Linking perl libraries...", "info" );
        if ( !-d "/opt/traffic_ops/lib" ) {
            mkdir("/opt/traffic_ops/lib");
        }
        symlink( "/opt/traffic_ops/app/local/lib/perl5", "/opt/traffic_ops/lib/perl5" );
        InstallUtils::execCommand( "/bin/chown", "-R", "trafops:trafops", "/opt/traffic_ops/lib" );
    }
    InstallUtils::logger( "Installing perl scripts", "info" );
    chdir("/opt/traffic_ops/app/local/bin");
    my $rc = InstallUtils::execCommand( "/bin/cp", "-R", ".", "/opt/traffic_ops/app/bin" );
    if ( $rc != 0 ) {
        InstallUtils::logger( "Failed to copy perl scripts to /opt/traffic_ops/app/bin", "error" );
    }

    return 0;
}

1;
<commit_msg>no symlinks,  no copying local/bin files<commit_after>#!/usr/bin/perl
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

package BuildPerlDeps;

use strict;
use warnings;

use InstallUtils qw{ :all };

use base qw{ Exporter };
our @EXPORT_OK = qw{ build };
our %EXPORT_TAGS = ( all => \@EXPORT_OK );

sub build {
    my $opt_i       = shift;
    my $cpanLogFile = shift;

    my @dependencies = ( "expat-devel", "mod_ssl", "mkisofs", "libpcap", "libpcap-devel", "libcurl", "libcurl-devel", "openssl", "openssl-devel", "cpan", "gcc", "make", "pkgconfig", "automake", "autoconf", "libtool", "gettext", "libidn-devel" );

    my $msg = << 'EOF';

This script will build and package the required Traffic Ops perl modules.
In order to complete this operation, Development tools such as the gcc
compiler will be installed on this machine.

EOF

    $ENV{PERL_MM_USE_DEFAULT}    = 1;
    $ENV{PERL_MM_NONINTERACTIVE} = 1;
    $ENV{AUTOMATED_TESTING}      = 1;

    my $result;

    if ( $ENV{USER} ne "root" ) {
        errorOut("You must run this script as the root user");
    }

    InstallUtils::logger( $msg, "info" );

    chdir("/opt/traffic_ops/app");

    if ( defined $opt_i && $opt_i == 1 ) {
        if ( !-x "/usr/bin/yum" ) {
            errorOut("You must install 'yum'");
        }

        InstallUtils::logger( "Installing dependencies", "info" );
        $result = InstallUtils::execCommand( "/usr/bin/yum", "-y", "install", @dependencies );
        if ( $result != 0 ) {
            errorOut("Dependency installation failed, look through the output and correct the problem");
        }
        InstallUtils::logger( "Building perl modules", "info" );

        $result = InstallUtils::execCommand( "/usr/bin/cpan", "pi_custom_log=" . $cpanLogFile, "-if", "YAML" );
        if ( $result != 0 ) {
            errorOut("Failed to install YAML, look through the output and correct the problem");
        }

        $result = InstallUtils::execCommand( "/usr/bin/cpan", "pi_custom_log=" . $cpanLogFile, "-if", "MIYAGAWA/Carton-v1.0.15.tar.gz" );
        if ( $result != 0 ) {
            errorOut("Failed to install Carton, look through the output and correct the problem");
        }
    }

    $result = InstallUtils::execCommand( "/usr/local/bin/carton", "install" );
    if ( $result != 0 ) {
        errorOut("Failure to build required perl modules, check the output and correct the problem");
    }

    return 0;
}

1;

{'fraction_non_alphanumeric': 0.14343646740762991, 'fraction_numerical': 0.006158005407029138, 'mean_word_length': 3.0603658536585368, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4638654', 'n_tokens_mistral': 2193, 'n_tokens_neox': 2095, 'n_words': 648}