You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2017/01/27 16:53:41 UTC
[20/36] incubator-trafficcontrol git commit: Reset
build_trafficops_perl_library
Reset build_trafficops_perl_library
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/832a50f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/832a50f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/832a50f3
Branch: refs/heads/master
Commit: 832a50f3320cf18c50b4f186683b138d2324a167
Parents: 5bcd2be
Author: peryder <pe...@cisco.com>
Authored: Wed Dec 7 10:09:39 2016 -0500
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri Jan 27 09:52:53 2017 -0700
----------------------------------------------------------------------
.../install/bin/build_trafficops_perl_library | 138 ++++++++-----------
1 file changed, 60 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/832a50f3/traffic_ops/install/bin/build_trafficops_perl_library
----------------------------------------------------------------------
diff --git a/traffic_ops/install/bin/build_trafficops_perl_library b/traffic_ops/install/bin/build_trafficops_perl_library
index 0bca5e9..684916d 100755
--- a/traffic_ops/install/bin/build_trafficops_perl_library
+++ b/traffic_ops/install/bin/build_trafficops_perl_library
@@ -1,13 +1,12 @@
#!/usr/bin/perl
#
-# Copyright 2015 Comcast Cable Communications Management, LLC
#
# 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.
@@ -18,13 +17,15 @@
use strict;
use warnings;
use Getopt::Std;
+use InstallUtils;
our ($opt_i);
-my @dependencies = ("expat-devel","mod_ssl","mkisofs","libpcap","libpcap-devel",
- "libcurl","libcurl-devel","mysql-server","mysql-devel",
- "openssl","openssl-devel","cpan","gcc","make","pkgconfig","automake","autoconf",
- "libtool","gettext","libidn-devel");
+my @dependencies = (
+ "expat-devel", "mod_ssl", "mkisofs", "libpcap", "libpcap-devel", "libcurl",
+ "libcurl-devel", "mysql-server", "mysql-devel", "openssl", "cpan", "gcc",
+ "make", "pkgconfig", "automake", "autoconf", "libtool", "gettext"
+);
my $msg = << 'EOF';
This script will build and package the required Traffic Ops perl modules.
@@ -33,55 +34,36 @@ compiler will be installed on this machine.
EOF
-sub execCommand {
- my ($command, @args) = @_;
- my $pid = fork ();
- my $result = 0;
+sub promptUser {
+ my ( $promptString, $defaultValue, $noEcho ) = @_;
- if ($pid == 0) {
- exec ($command, @args);
- exit 0;
+ if ($defaultValue) {
+ print $promptString, " [", $defaultValue, "]: ";
}
else {
- wait;
- $result = $?;
- if ($result != 0) {
- print "ERROR executing: $command, args: " . join (' ', @args) . "\n";
+ print $promptString, ": ";
+ }
+
+ if ( defined $noEcho && $noEcho ) {
+ my $response = read_password('');
+ if ( ( !defined $response || $response eq '' ) && ( defined $defaultValue && $defaultValue ne '' ) ) {
+ $response = $defaultValue;
}
+ return $response;
}
- return $result;
-}
+ else {
+ $| = 1;
+ $_ = <STDIN>;
+ chomp;
-sub promptUser {
- my ($promptString, $defaultValue, $noEcho) = @_;
-
- if ($defaultValue) {
- print $promptString, " [", $defaultValue, "]: ";
- }
- else {
- print $promptString, ": ";
- }
-
- if (defined $noEcho && $noEcho) {
- my $response = read_password('');
- if ((!defined $response || $response eq '') && (defined $defaultValue && $defaultValue ne '')) {
- $response = $defaultValue;
- }
- return $response
- }
- else {
- $| = 1;
- $_ = <STDIN>;
- chomp;
-
- if ("$defaultValue") {
- return $_ ? $_ : $defaultValue;
- }
- else {
- return $_;
- }
- return $_;
- }
+ if ("$defaultValue") {
+ return $_ ? $_ : $defaultValue;
+ }
+ else {
+ return $_;
+ }
+ return $_;
+ }
}
sub trim {
@@ -99,69 +81,69 @@ my $result;
## MAIN ##
#################################
-$ENV{PERL_MM_USE_DEFAULT}=1;
-$ENV{PERL_MM_NONINTERACTIVE}=1;
-$ENV{AUTOMATED_TESTING}=1;
+$ENV{PERL_MM_USE_DEFAULT} = 1;
+$ENV{PERL_MM_NONINTERACTIVE} = 1;
+$ENV{AUTOMATED_TESTING} = 1;
-getopts ('i');
+getopts('i');
-execCommand ("/usr/bin/tput","clear");
+InstallUtils::execCommand( "/usr/bin/tput", "clear" );
-if ($ENV{USER} ne "root") {
+if ( $ENV{USER} ne "root" ) {
print "WARNING: You must run this script as the root user.\n";
exit 0;
}
print $msg;
-promptUser ("Hit ENTER to continue","");
+promptUser( "Hit ENTER to continue", "" );
-chdir ("/opt/traffic_ops/app");
+chdir("/opt/traffic_ops/app");
-if (defined $opt_i && $opt_i == 1) {
- if (! -x "/usr/bin/yum") {
+if ( defined $opt_i && $opt_i == 1 ) {
+ if ( !-x "/usr/bin/yum" ) {
print "WARNING: You must install 'yum'.\n";
exit 0;
}
print "\nInstalling dependencies.\n";
- $result = execCommand ("/usr/bin/yum", "install", @dependencies);
- if ($result != 0) {
+ $result = InstallUtils::execCommand( "/usr/bin/yum", "install", @dependencies );
+ if ( $result != 0 ) {
print "WARNING: dependency installation failed, look through the output and correct the problem.\n";
exit 0;
}
print "\nBuilding perl modules\n";
- $result = execCommand ("/opt/traffic_ops/install/bin/cpan.sh", "/opt/traffic_ops/install/bin/yaml.txt");
- if ($result != 0) {
+ $result = InstallUtils::execCommand( "/usr/bin/cpan", "-if", "YAML" );
+ if ( $result != 0 ) {
print "WARNING: Failed to install YAML, look through the output and correct the problem.\n";
exit 0;
}
- $result = execCommand ("/opt/traffic_ops/install/bin/cpan.sh", "/opt/traffic_ops/install/bin/carton.txt");
- if ($result != 0) {
+ $result = InstallUtils::execCommand( "/usr/bin/cpan", "-if", "MIYAGAWA/Carton-v1.0.15.tar.gz" );
+ if ( $result != 0 ) {
print "WARNING: Failed to install Carton, look through the output and correct the problem.\n";
exit 0;
}
}
-$result = execCommand ("/usr/local/bin/carton","install","--deployment","--cached");
-if ($result != 0) {
+$result = InstallUtils::execCommand( "/usr/local/bin/carton", "install" );
+if ( $result != 0 ) {
print "WARNING: Failure to build required perl modules, check the output and correct the problem.\n";
exit 0;
}
-if (! -s "/opt/traffic_ops/lib/perl5") {
- print "Linking perl libraries...\n";
- if (! -d "/opt/traffic_ops/lib") {
- mkdir ("/opt/traffic_ops/lib");
- }
- symlink ("/opt/traffic_ops/app/local/lib/perl5","/opt/traffic_ops/lib/perl5");
- execCommand ("/bin/chown","-R","trafops:trafops","/opt/traffic_ops/lib");
+if ( !-s "/opt/traffic_ops/lib/perl5" ) {
+ print "Linking perl libraries...\n";
+ 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" );
}
print "Installing perl scripts\n";
-chdir ("/opt/traffic_ops/app/local/bin");
-my $rc = execCommand ("/bin/cp","-R",".","/opt/traffic_ops/app/bin");
-if ($rc != 0) {
- print "WARNING: Failed to copy perl scripts to /opt/traffic_ops/app/bin.\n";
+chdir("/opt/traffic_ops/app/local/bin");
+my $rc = InstallUtils::execCommand( "/bin/cp", "-R", ".", "/opt/traffic_ops/app/bin" );
+if ( $rc != 0 ) {
+ print "WARNING: Failed to copy perl scripts to /opt/traffic_ops/app/bin.\n";
}