-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·191 lines (168 loc) · 4.42 KB
/
setup.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
# Print script commands and exit on errors.
set -xe
#Src
BMV2_COMMIT="b447ac4c0cfd83e5e72a3cc6120251c1e91128ab" # August 10, 2019
PI_COMMIT="41358da0ff32c94fa13179b9cee0ab597c9ccbcc" # August 10, 2019
P4C_COMMIT="69e132d0d663e3408d740aaf8ed534ecefc88810" # August 10, 2019
PROTOBUF_COMMIT="v3.2.0"
GRPC_COMMIT="v1.3.2"
#Get the number of cores to speed up the compilation process
NUM_CORES=`grep -c ^processor /proc/cpuinfo`
# --- Mininet --- #
#git clone git://github.com/mininet/mininet mininet
#sudo ./mininet/util/install.sh -nwv
# --- Protobuf --- #
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout ${PROTOBUF_COMMIT}
export CFLAGS="-Os"
export CXXFLAGS="-Os"
export LDFLAGS="-Wl,-s"
./autogen.sh
./configure --prefix=/usr
make -j${NUM_CORES}
sudo make install
sudo ldconfig
unset CFLAGS CXXFLAGS LDFLAGS
# Force install python module
cd python
sudo python setup.py install
cd ../..
# --- gRPC --- #
git clone https://github.com/grpc/grpc.git
cd grpc
git checkout ${GRPC_COMMIT}
git submodule update --init --recursive
export LDFLAGS="-Wl,-s"
make -j${NUM_CORES}
sudo make install
sudo ldconfig
unset LDFLAGS
cd ..
# Install gRPC Python Package
sudo pip install grpcio
# --- BMv2 deps (needed by PI) --- #
git clone https://github.com/p4lang/behavioral-model.git
cd behavioral-model
git checkout ${BMV2_COMMIT}
# From bmv2's install_deps.sh, we can skip apt-get install.
# Nanomsg is required by p4runtime, p4runtime is needed by BMv2...
tmpdir=`mktemp -d -p .`
cd ${tmpdir}
bash ../travis/install-thrift.sh
bash ../travis/install-nanomsg.sh
sudo ldconfig
bash ../travis/install-nnpy.sh
cd ..
sudo rm -rf $tmpdir
cd ..
# --- PI/P4Runtime --- #
git clone https://github.com/p4lang/PI.git
cd PI
git checkout ${PI_COMMIT}
git submodule update --init --recursive
./autogen.sh
./configure --with-proto
make -j${NUM_CORES}
sudo make install
sudo ldconfig
cd ..
# --- Bmv2 --- #
cd behavioral-model
./autogen.sh
./configure --enable-debugger --with-pi
make -j${NUM_CORES}
sudo make install
sudo ldconfig
# Simple_switch_grpc target
cd targets/simple_switch_grpc
./autogen.sh
./configure --with-thrift
make -j${NUM_CORES}
sudo make install
sudo ldconfig
cd ../../..
# --- P4C --- #
git clone https://github.com/p4lang/p4c
cd p4c
git checkout ${P4C_COMMIT}
git submodule update --init --recursive
mkdir -p build
cd build
cmake ..
# The command 'make -j${NUM_CORES}' works fine for the others, but
# with 2 GB of RAM for the VM, there are parts of the p4c build where
# running 2 simultaneous C++ compiler runs requires more than that
# much memory. Things work better by running at most one C++ compilation
# process at a time.
make -j1
sudo make install
sudo ldconfig
cd ../..
# --- Tutorials --- #
sudo pip install crcmod
git clone https://github.com/p4lang/tutorials
sudo mv tutorials /home/p4
sudo chown -R p4:p4 /home/p4/tutorials
pip install --upgrade grpcio
# --- Emacs --- #
#sudo cp p4_16-mode.el /usr/share/emacs/site-lisp/
#sudo mkdir /home/p4/.emacs.d/
#echo "(autoload 'p4_16-mode' \"p4_16-mode.el\" \"P4 Syntax.\" t)" > init.el
#echo "(add-to-list 'auto-mode-alist '(\"\\.p4\\'\" . p4_16-mode))" | tee -a init.el
#sudo mv init.el /home/p4/.emacs.d/
#sudo ln -s /usr/share/emacs/site-lisp/p4_16-mode.el /home/p4/.emacs.d/p4_16-mode.el
#sudo chown -R p4:p4 /home/p4/.emacs.d/
# --- Vim --- #
#cd ~
#mkdir .vim
#cd .vim
#mkdir ftdetect
#mkdir syntax
#echo "au BufRead,BufNewFile *.p4 set filetype=p4" >> ftdetect/p4.vim
#echo "set bg=dark" >> ~/.vimrc
#sudo mv ~/.vimrc /home/p4/.vimrc
#cp ~/p4.vim syntax/p4.vim
#cd ~
#sudo mv .vim /home/p4/.vim
#sudo chown -R p4:p4 /home/p4/.vim
#sudo chown p4:p4 /home/p4/.vimrc
# --- Adding Desktop icons --- #
#DESKTOP=/home/${USER}/Desktop
#mkdir -p ${DESKTOP}
#cat > ${DESKTOP}/Terminal << EOF
#[Desktop Entry]
#Encoding=UTF-8
#Type=Application
#Name=Terminal
#Name[en_US]=Terminal
#Icon=konsole
#Exec=/usr/bin/x-terminal-emulator
#Comment[en_US]=
#EOF
#cat > ${DESKTOP}/Wireshark << EOF
#[Desktop Entry]
#Encoding=UTF-8
#Type=Application
#Name=Wireshark
#Name[en_US]=Wireshark
#Icon=wireshark
#Exec=/usr/bin/wireshark
#Comment[en_US]=
#EOF
#cat > ${DESKTOP}/Sublime\ Text << EOF
#[Desktop Entry]
#Encoding=UTF-8
#Type=Application
#Name=Sublime Text
#Name[en_US]=Sublime Text
#Icon=sublime-text
#Exec=/opt/sublime_text/sublime_text
#Comment[en_US]=
#EOF
#sudo mkdir -p /home/p4/Desktop
#sudo mv /home/${USER}/Desktop/* /home/p4/Desktop
#sudo chown -R p4:p4 /home/p4/Desktop/
# Do this last!
sudo reboot