-
Notifications
You must be signed in to change notification settings - Fork 0
/
do_install.sh
138 lines (115 loc) · 3.4 KB
/
do_install.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
#!/bin/bash
# exit when any command fails
set -e
# parse custom args
for ARGUMENT in "$@"
do
KEY=$(echo $ARGUMENT | cut -f1 -d=)
VALUE=$(echo $ARGUMENT | cut -f2 -d=)
case "$KEY" in
INSTALL_BMV2) INSTALL_BMV2=${VALUE} ;;
*)
esac
done
# fetch submodules and update apt
echo "Initializing submodules..."
git submodule update --init --recursive
sudo apt-get update
SRC_DIR="$(pwd)"
MODULE_DIR="$(pwd)/modules"
echo "Installing P4C dependencies..."
# Install pip and python
sudo apt install -y python3
sudo apt install -y python3-pip
sudo apt install -y python3-setuptools
# Install the p4 compiler dependencies
sudo apt install -y bison \
build-essential \
cmake \
git \
flex \
libboost-dev \
libboost-graph-dev \
libboost-iostreams-dev \
libfl-dev \
libgc-dev \
libgmp-dev \
pkg-config
# This only works on Ubuntu 18+
sudo apt install -y libprotoc-dev protobuf-compiler
# install python packages using pip
pip3 install --user wheel
pip3 install --user pyroute2 ipaddr ply scapy
# only install the behavioral model if requested
if [ "$INSTALL_BMV2" == "ON" ]; then
echo "Behavioral model install selected."
# Install the behavioral model dependencies
echo "Installing behavioral model dependencies."
sudo apt install -y automake \
cmake \
libjudy-dev \
libgmp-dev \
libpcap-dev \
libboost-dev \
libboost-test-dev \
libboost-program-options-dev \
libboost-system-dev \
libboost-filesystem-dev \
libboost-thread-dev \
libevent-dev \
libtool \
flex \
bison \
pkg-config \
g++ \
libssl-dev \
libnanomsg-dev \
libgrpc-dev
echo "Installing thrift dependency."
# this only works on Ubuntu 19.10+...
if sudo apt install -y libthrift-dev ; then
sudo apt install -y thrift-compiler
echo "Installed thrift with apt."
else
# unfortunately we still have to install thrift the manual way...
cd ${MODULE_DIR}/behavioral-model
wget -N https://archive.apache.org/dist/thrift/0.13.0/thrift-0.13.0.tar.gz
tar -xvf thrift-0.13.0.tar.gz
cd thrift-0.13.0/
./bootstrap.sh
./configure --without-rs --without-nodejs
make
sudo make install
sudo ldconfig
fi
pip3 install --user thrift==0.13.0
# build the behavioral model
echo "Installing behavioral model..."
cd ${MODULE_DIR}/behavioral-model
autoreconf -i # this is needed for some reason...
./autogen.sh
./configure
make
sudo make install
cd ${SRC_DIR}
fi
# If the behavioral model dependencies did not cover filesystem
# This is needed for the validation binaries
sudo apt install libboost-filesystem-dev
# grab the toz3 extension for the p4 compiler
mkdir -p ${MODULE_DIR}/p4c/extensions
# only install bludgeon if we are not running in CI
if [ "$RUN_CI" == "ON" ]; then
echo "Also linking extra modules..."
ln -sf ${MODULE_DIR}/bludgeon ${MODULE_DIR}/p4c/extensions/bludgeon
fi
ln -sf ${MODULE_DIR}/toz3 ${MODULE_DIR}/p4c/extensions/toz3
# build the p4 compiler
echo "Building P4C..."
cd ${MODULE_DIR}/p4c
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DENABLE_TEST_TOOLS=ON
make -j `getconf _NPROCESSORS_ONLN`
cd ../..
echo "Gauntlet installation completed successfully."