forked from ipdk-io/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_dep_packages.sh
executable file
·177 lines (161 loc) · 5.34 KB
/
install_dep_packages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Copyright (c) 2021 Intel Corporation.
#
# 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.
#! /bin/bash
set -e
source os_ver_details.sh
WS_DIR=$PWD
echo "WS_DIR: $WS_DIR"
if [ -z "$1" ];
then
echo "- Missing mandatory arguments:"
echo " - Usage: ./install_dep_packages.sh <SRC_FOLDER> [INSTALL_FOLDER]"
exit 1
fi
echo "#### \
THIS SCRIPT INSTALLS THE DEPENDENCY MODULES \
NEEDED FOR P4-OVS COMPILATION/RUNNING \
####"
#First argument is taken as the directory path \
#for the source code and installables scratch area.
SRC_DIR=$1/P4OVS_DEPS_SRC_CODE
echo "Removing and Creating SOURCE directory, $SRC_DIR"
if [ -d "$SRC_DIR" ]; then rm -rf $SRC_DIR; fi
mkdir -p $SRC_DIR
if [ -z "$2" ];
then
CMAKE_PREFIX=""
CONFIG_PREFIX=""
MAKE_PREFIX=""
else
INSTALL_DIR=$2/P4OVS_DEPS_INSTALL
CMAKE_PREFIX="-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR"
MAKE_PREFIX="prefix=$INSTALL_DIR"
CONFIG_PREFIX="--prefix=$INSTALL_DIR"
echo "Removing and Creating INSTALL scratch directory, $INSTALL_DIR"
if [ -d "$INSTALL_DIR" ]; then rm -rf $INSTALL_DIR; fi
mkdir -p $INSTALL_DIR
fi
#Get the OS and Version details
get_os_ver_details
echo "OS and Version details..."
echo "$OS : $VER"
echo ""
#Read the number of CPUs in a system and derive the NUM threads
get_num_cores
echo "Number of Parallel threads used: $NUM_THREADS ..."
echo ""
# Dependencies needed for building netlink library
if [[ $OS =~ "Fedora" ]]; then
sudo dnf install -y pkgconfig
sudo dnf install -y libnl3-devel
elif [[ $OS =~ "Ubuntu" ]]; then
sudo apt-get install -y pkg-config
sudo apt-get install -y libnl-route-3-dev
else
sudo yum install -y pkgconfig
sudo yum install -y libnl3-devel
fi
#gflags source code Repo checkout, Build and Install
MODULE="gflags"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/gflags/gflags.git ${SRC_DIR}/$MODULE
cd $SRC_DIR/$MODULE
git checkout 827c769e5fc98e0f2a34c47cef953cc6328abced
mkdir -p $SRC_DIR/$MODULE/build
cd $SRC_DIR/$MODULE/build
cmake -DBUILD_SHARED_LIBS=ON $CMAKE_PREFIX ..
make $NUM_THREADS
sudo make $NUM_THREADS install
sudo ldconfig
#glog source code Repo checkout, Build and Install
MODULE="glog"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/google/glog.git ${SRC_DIR}/$MODULE
cd $SRC_DIR/$MODULE
git checkout 503e3dec8d1fe071376befc62119a837c26612a3
mkdir -p $SRC_DIR/$MODULE/build
cd $SRC_DIR/$MODULE/build
cmake $CMAKE_PREFIX ..
make $NUM_THREADS
sudo make $NUM_THREADS install
sudo ldconfig
#abseil-cpp source code Repo checkout, Build and Install
MODULE="abseil-cpp"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/abseil/abseil-cpp.git ${SRC_DIR}/$MODULE
cd $SRC_DIR/$MODULE
git checkout ec0d76f1d012cc1a4b3b08dfafcfc5237f5ba2c9
mkdir -p $SRC_DIR/$MODULE/build
cd $SRC_DIR/$MODULE/build
cmake -DBUILD_TESTING=OFF $CMAKE_PREFIX ..
make $NUM_THREADS
sudo make $NUM_THREADS install
sudo ldconfig
#cctz source code Repo checkout, Build and Install
MODULE="cctz"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/google/cctz.git ${SRC_DIR}/$MODULE
cd $SRC_DIR/$MODULE
git checkout 02918d62329ef440935862719829d061a5f4beba
mkdir -p $SRC_DIR/$MODULE/build
cd $SRC_DIR/$MODULE/build
cmake -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON $CMAKE_PREFIX ..
make $NUM_THREADS
sudo make $NUM_THREADS install
sudo ldconfig
#Protobuf source code Repo checkout, Build and Install
MODULE="protobuf"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/google/protobuf.git ${SRC_DIR}/$MODULE
cd ${SRC_DIR}/$MODULE
git checkout tags/v3.6.1
./autogen.sh
./configure $CONFIG_PREFIX
make $NUM_THREADS
sudo make $NUM_THREADS install
sudo ldconfig
#grpc source code Repo checkout, Build and Install
MODULE="grpc"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/google/grpc.git ${SRC_DIR}/$MODULE
cd ${SRC_DIR}/$MODULE
git checkout tags/v1.17.2
git submodule update --init --recursive
if [[ $OS =~ "Fedora" ]];
then
git apply $WS_DIR/external/PATCH-01-GRPC
fi
make $NUM_THREADS $MAKE_PREFIX
sudo make $NUM_THREADS $MAKE_PREFIX install
sudo ldconfig
#nlohmann source code Repo checkout, Build and Install
MODULE="json"
echo "#### Cloning, Building and Installing the '$MODULE' module ####"
mkdir -p ${SRC_DIR}/$MODULE
git clone https://github.com/nlohmann/json.git ${SRC_DIR}/$MODULE
cd $SRC_DIR/$MODULE
git checkout 760304635dc74a5bf77903ad92446a6febb85acf
mkdir -p $SRC_DIR/$MODULE/build
cd $SRC_DIR/$MODULE/build
cmake $CMAKE_PREFIX ..
make $NUM_THREADS
sudo make $NUM_THREADS install
sudo ldconfig
set +e