From ec940627adb5f4965dcf692cb488f09b5cc4406b Mon Sep 17 00:00:00 2001 From: Pavel Odintsov Date: Fri, 2 Oct 2015 14:33:43 +0200 Subject: [PATCH] Add gRPC and protocol buffers to installer --- src/fastnetmon_install.pl | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/src/fastnetmon_install.pl b/src/fastnetmon_install.pl index 7bc7d552..0740e1b4 100755 --- a/src/fastnetmon_install.pl +++ b/src/fastnetmon_install.pl @@ -73,6 +73,8 @@ my $we_have_hiredis_support = ''; my $we_have_log4cpp_support = ''; my $we_have_pfring_support = ''; my $we_have_mongo_support = ''; +my $we_have_protobuf_support = ''; +my $we_have_grpc_support = ''; if ($we_use_code_from_master) { $we_have_ndpi_support = 1; @@ -211,6 +213,14 @@ sub main { install_mongo_client(); } + if ($we_have_protobuf_support) { + install_protobuf(); + } + + if ($we_have_grpc_support) { + install_grpc(); + } + if ($we_have_log4cpp_support) { install_log4cpp(); } @@ -792,6 +802,66 @@ sub install_log4cpp { put_library_path_to_ld_so("/etc/ld.so.conf.d/log4cpp.conf", "$log4cpp_install_path/lib"); } +sub install_grpc { + # We use this commit because 0.11.1 is broken and do not build on CentOS 6 correctly + my $grpc_git_commit = "7a94236d698477636dd06282f12f706cad527029"; + my $grpc_install_path = "/opt/grpc_0_11_1_$grpc_git_commit"; + + if ($distro_type eq 'debian' or $distro_type eq 'ubuntu') { + apt_get('gcc', 'make', 'autoconf', 'automake', 'git', 'libtool', 'g++', 'python-all-dev', 'python-virtualenv'); + } + + # TODO: add deps for CentOS + chdir $temp_folder_for_building_project; + + print "Clone gRPC repository\n"; + exec_command("git clone https://github.com/grpc/grpc.git"); + chdir "grpc"; + + # For back compatibility with old git + exec_command("git checkout $grpc_git_commit"); + exec_command("git submodule update --init"); + + print "Build gRPC\n"; + exec_command("make $make_options"); + + print "Install gRPC\n"; + exec_command("make install prefix=$grpc_install_path"); +} + +sub install_protobuf { + if ($distro_type eq 'debian' or $distro_type eq 'ubuntu') { + apt_get('gcc', 'make', 'autoconf', 'automake', 'git', 'libtool', 'g++', 'curl'); + } + + # TODO: add deps for CentOS + + my $protobuf_install_path = '/opt/protobuf_3.0.0_alpha4'; + my $distro_file_name = 'v3.0.0-alpha-4.tar.gz'; + + chdir $temp_folder_for_building_project; + print "Download protocol buffers\n"; + + my $protobuf_download_result = download_file("https://github.com/google/protobuf/archive/$distro_file_name", + $distro_file_name, 'd23048ba3218af21ba65fa39bfb6326f5bf9f7a4'); + + unless ($protobuf_download_result) { + die "Can't download protobuf\n"; + } + + print "Unpack protocol buffers\n"; + exec_command("tar -xf $distro_file_name"); + + chdir "protobuf-3.0.0-alpha-4"; + print "Configure protobuf\n"; + + exec_command("./autogen.sh"); + exec_command("./configure --prefix=$protobuf_install_path"); + + print "Build protobuf\n"; + exec_command("make $make_options install"); +} + sub install_mongo_client { my $distro_file_name = 'mongo-c-driver-1.1.9.tar.gz'; my $mongo_install_path = '/opt/mongo_c_driver_1_1_9';