Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Builds and installs all tools needed for developing and testing P4 support in |
| 4 | # ONOS. |
| 5 | # |
| 6 | # Tested on Ubuntu 14.04 and 16.04. |
| 7 | # |
| 8 | # Recommended minimum system requirements: |
| 9 | # 4 GB of RAM |
| 10 | # 2 cores |
| 11 | # 8 GB free hard drive space (~4 GB to build everything) |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 12 | # |
| 13 | # To execute up to a given step, pass the step name as the first argument. For |
| 14 | # example, to install PI, but not BMv2, p4c, etc: |
| 15 | # ./install-p4-tools.sh PI |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 16 | # ----------------------------------------------------------------------------- |
| 17 | |
| 18 | # Exit on errors. |
| 19 | set -e |
| 20 | |
| 21 | BUILD_DIR=~/p4tools |
Esin Karaman | 971fb7f | 2017-12-28 13:44:52 +0000 | [diff] [blame] | 22 | # in case BMV2_COMMIT value is updated, the same variable in |
| 23 | # protocols/bmv2/thrift-api/BUCK file should also be updated |
Carmelo Cascone | f645e84 | 2018-07-16 18:31:52 +0200 | [diff] [blame] | 24 | BMV2_COMMIT="a3f0ebe4c0f10a656f8aa1ad68cb20402a62b0ee" |
| 25 | PI_COMMIT="7e94b025bac6db63bc8534e5dd21a008984e38bc" |
| 26 | P4C_COMMIT="2d089af757212a057c6690998861ef67439305f4" |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 27 | PROTOBUF_COMMIT="tags/v3.2.0" |
| 28 | GRPC_COMMIT="tags/v1.3.2" |
| 29 | LIBYANG_COMMIT="v0.14-r1" |
| 30 | SYSREPO_COMMIT="v0.7.2" |
| 31 | |
| 32 | NUM_CORES=`grep -c ^processor /proc/cpuinfo` |
| 33 | |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 34 | # If false, build tools without debug features to improve throughput of BMv2 and |
| 35 | # reduce CPU/memory footprint. |
| 36 | DEBUG_FLAGS=${DEBUG_FLAGS:-true} |
| 37 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 38 | # Execute up to the given step (first argument), or all if not defined. |
| 39 | LAST_STEP=${1:-all} |
| 40 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 41 | function do_requirements { |
| 42 | sudo apt update |
| 43 | sudo apt-get install -y --no-install-recommends \ |
| 44 | autoconf \ |
| 45 | automake \ |
| 46 | bison \ |
| 47 | build-essential \ |
| 48 | cmake \ |
| 49 | cpp \ |
| 50 | curl \ |
| 51 | flex \ |
| 52 | git \ |
| 53 | libavl-dev \ |
| 54 | libboost-dev \ |
| 55 | libboost-program-options-dev \ |
| 56 | libboost-system-dev \ |
| 57 | libboost-filesystem-dev \ |
| 58 | libboost-thread-dev \ |
| 59 | libboost-filesystem-dev \ |
| 60 | libboost-program-options-dev \ |
| 61 | libboost-system-dev \ |
| 62 | libboost-test-dev \ |
| 63 | libboost-thread-dev \ |
| 64 | libc6-dev \ |
| 65 | libev-dev \ |
| 66 | libevent-dev \ |
| 67 | libffi-dev \ |
| 68 | libfl-dev \ |
| 69 | libgc-dev \ |
| 70 | libgc1c2 \ |
| 71 | libgflags-dev \ |
| 72 | libgmp-dev \ |
| 73 | libgmp10 \ |
| 74 | libgmpxx4ldbl \ |
| 75 | libjudy-dev \ |
| 76 | libpcap-dev \ |
| 77 | libpcre3-dev \ |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 78 | libreadline6 \ |
| 79 | libreadline6-dev \ |
| 80 | libssl-dev \ |
| 81 | libtool \ |
| 82 | make \ |
| 83 | mktemp \ |
| 84 | pkg-config \ |
| 85 | protobuf-c-compiler \ |
Carmelo Cascone | 57defd3 | 2018-05-11 14:34:01 -0700 | [diff] [blame] | 86 | python2.7 \ |
| 87 | python2.7-dev \ |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 88 | tcpdump \ |
| 89 | wget \ |
| 90 | unzip |
| 91 | |
Charles Chan | 87dc82e | 2018-08-05 16:27:10 -0700 | [diff] [blame] | 92 | sudo -H pip install setuptools cffi ipaddr ipaddress pypcap |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | function do_requirements_1404 { |
| 96 | sudo apt install -y python-software-properties software-properties-common |
| 97 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test |
| 98 | sudo add-apt-repository -y ppa:george-edison55/cmake-3.x |
| 99 | sudo apt update |
| 100 | sudo apt install -y \ |
| 101 | dpkg-dev \ |
| 102 | g++-4.9 \ |
| 103 | gcc-4.9 \ |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 104 | cmake \ |
| 105 | libbz2-dev |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 106 | |
| 107 | # Needed for p4c. |
| 108 | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 |
| 109 | sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50 |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 110 | |
| 111 | if [ -z "$(ldconfig -p | grep libboost_iostreams.so.1.58.0)" ]; then |
| 112 | do_boost |
| 113 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | function do_requirements_1604 { |
| 117 | sudo apt-get update |
| 118 | sudo apt-get install -y --no-install-recommends \ |
| 119 | ca-certificates \ |
| 120 | g++ \ |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 121 | libboost-iostreams1.58-dev \ |
| 122 | libprotobuf-c-dev |
| 123 | } |
| 124 | |
| 125 | function do_boost { |
| 126 | cd ${BUILD_DIR} |
| 127 | wget https://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download -O boost_1_58_0.tar.bz2 |
| 128 | tar --bzip2 -xf boost_1_58_0.tar.bz2 |
| 129 | cd boost_1_58_0 |
| 130 | |
| 131 | ./bootstrap.sh --with-libraries=iostreams |
| 132 | sudo ./b2 install |
| 133 | sudo ldconfig |
| 134 | |
| 135 | cd .. |
| 136 | sudo rm -rf boost_1_58_0 |
| 137 | } |
| 138 | |
| 139 | function do_protobuf-c { |
| 140 | cd ${BUILD_DIR} |
| 141 | git clone https://github.com/protobuf-c/protobuf-c.git |
| 142 | cd protobuf-c |
| 143 | |
| 144 | ./autogen.sh |
| 145 | ./configure --prefix=/usr |
| 146 | make -j${NUM_CORES} |
| 147 | sudo make install |
| 148 | sudo ldconfig |
| 149 | |
| 150 | cd .. |
| 151 | sudo rm -rf protobuf-c |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | function do_protobuf { |
| 155 | cd ${BUILD_DIR} |
| 156 | if [ ! -d protobuf ]; then |
| 157 | git clone https://github.com/google/protobuf.git |
| 158 | fi |
| 159 | cd protobuf |
| 160 | git fetch |
| 161 | git checkout ${PROTOBUF_COMMIT} |
| 162 | |
| 163 | export CFLAGS="-Os" |
| 164 | export CXXFLAGS="-Os" |
| 165 | export LDFLAGS="-Wl,-s" |
| 166 | ./autogen.sh |
| 167 | ./configure --prefix=/usr |
| 168 | make -j${NUM_CORES} |
| 169 | sudo make install |
| 170 | sudo ldconfig |
| 171 | unset CFLAGS CXXFLAGS LDFLAGS |
Carmelo Cascone | f645e84 | 2018-07-16 18:31:52 +0200 | [diff] [blame] | 172 | |
| 173 | cd python |
| 174 | sudo python setup.py install --cpp_implementation |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | function do_grpc { |
| 178 | cd ${BUILD_DIR} |
| 179 | if [ ! -d grpc ]; then |
| 180 | git clone https://github.com/grpc/grpc.git |
| 181 | fi |
| 182 | cd grpc |
| 183 | git fetch |
| 184 | git checkout ${GRPC_COMMIT} |
| 185 | git submodule update --init |
| 186 | |
| 187 | export LDFLAGS="-Wl,-s" |
| 188 | make -j${NUM_CORES} |
| 189 | sudo make install |
| 190 | sudo ldconfig |
| 191 | unset LDFLAGS |
Carmelo Cascone | f645e84 | 2018-07-16 18:31:52 +0200 | [diff] [blame] | 192 | |
| 193 | sudo pip install -r requirements.txt |
| 194 | sudo pip install . |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | function do_libyang { |
| 198 | cd ${BUILD_DIR} |
| 199 | if [ ! -d libyang ]; then |
| 200 | git clone https://github.com/CESNET/libyang.git |
| 201 | fi |
| 202 | cd libyang |
| 203 | git fetch |
| 204 | git checkout ${LIBYANG_COMMIT} |
| 205 | |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 206 | mkdir -p build |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 207 | cd build |
| 208 | cmake .. |
| 209 | make -j${NUM_CORES} |
| 210 | sudo make install |
| 211 | sudo ldconfig |
| 212 | } |
| 213 | |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 214 | function do_sysrepo_deps { |
| 215 | RELEASE=`lsb_release -rs` |
| 216 | if version_ge $RELEASE 14.04 && [ -z "$(ldconfig -p | grep libprotobuf-c)" ]; then |
| 217 | do_protobuf-c |
| 218 | fi |
| 219 | } |
| 220 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 221 | function do_sysrepo { |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 222 | do_sysrepo_deps |
| 223 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 224 | cd ${BUILD_DIR} |
| 225 | if [ ! -d sysrepo ]; then |
| 226 | git clone https://github.com/sysrepo/sysrepo.git |
| 227 | fi |
| 228 | cd sysrepo |
| 229 | git fetch |
| 230 | git checkout ${SYSREPO_COMMIT} |
| 231 | |
Kevin Chuang | 53a9d5b | 2018-01-17 15:55:32 +0800 | [diff] [blame] | 232 | mkdir -p build |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 233 | cd build |
| 234 | cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=Off \ |
| 235 | -DCALL_TARGET_BINS_DIRECTLY=Off .. |
| 236 | make -j${NUM_CORES} |
| 237 | sudo make install |
| 238 | sudo ldconfig |
| 239 | } |
| 240 | |
| 241 | function checkout_bmv2 { |
| 242 | cd ${BUILD_DIR} |
| 243 | if [ ! -d bmv2 ]; then |
| 244 | git clone https://github.com/p4lang/behavioral-model.git bmv2 |
| 245 | fi |
| 246 | cd bmv2 |
| 247 | git fetch |
| 248 | git checkout ${BMV2_COMMIT} |
| 249 | } |
| 250 | |
| 251 | function do_pi_bmv2_deps { |
| 252 | checkout_bmv2 |
| 253 | # From bmv2's install_deps.sh. |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 254 | # Nanomsg is required also by PI. |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 255 | tmpdir=`mktemp -d -p .` |
| 256 | cd ${tmpdir} |
| 257 | bash ../travis/install-thrift.sh |
| 258 | bash ../travis/install-nanomsg.sh |
| 259 | sudo ldconfig |
| 260 | bash ../travis/install-nnpy.sh |
| 261 | cd .. |
| 262 | sudo rm -rf $tmpdir |
| 263 | } |
| 264 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 265 | function do_PI { |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 266 | cd ${BUILD_DIR} |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 267 | if [ ! -d PI ]; then |
| 268 | git clone https://github.com/p4lang/PI.git |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 269 | fi |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 270 | cd PI |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 271 | git fetch |
| 272 | git checkout ${PI_COMMIT} |
| 273 | git submodule update --init --recursive |
| 274 | |
| 275 | ./autogen.sh |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 276 | # FIXME: re-enable --with-sysrepo when gNMI support becomes more stable |
| 277 | # ./configure --with-proto --with-sysrepo 'CXXFLAGS=-O0 -g' |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 278 | if [ "${DEBUG_FLAGS}" = true ] ; then |
Carmelo Cascone | f742a11 | 2018-07-03 19:28:18 +0200 | [diff] [blame] | 279 | ./configure --with-proto "CXXFLAGS=-O0 -g" |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 280 | else |
Carmelo Cascone | f742a11 | 2018-07-03 19:28:18 +0200 | [diff] [blame] | 281 | ./configure --with-proto |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 282 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 283 | make -j${NUM_CORES} |
| 284 | sudo make install |
| 285 | sudo ldconfig |
| 286 | |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 287 | # FIXME: re-enable when gNMI support becomes more stable |
| 288 | # sudo proto/sysrepo/install_yangs.sh |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | function do_bmv2 { |
| 292 | checkout_bmv2 |
| 293 | |
| 294 | ./autogen.sh |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 295 | if [ "${DEBUG_FLAGS}" = true ] ; then |
Carmelo Cascone | f645e84 | 2018-07-16 18:31:52 +0200 | [diff] [blame] | 296 | ./configure --with-pi --enable-debugger --disable-elogger "CXXFLAGS=-O0 -g" |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 297 | else |
Carmelo Cascone | f742a11 | 2018-07-03 19:28:18 +0200 | [diff] [blame] | 298 | ./configure --with-pi --disable-logging-macros --disable-elogger --without-nanomsg |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 299 | fi |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 300 | make -j${NUM_CORES} |
| 301 | sudo make install |
| 302 | sudo ldconfig |
| 303 | |
| 304 | # Simple_switch_grpc target |
| 305 | cd targets/simple_switch_grpc |
| 306 | ./autogen.sh |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 307 | |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 308 | if [ "${DEBUG_FLAGS}" = true ] ; then |
Carmelo Cascone | f742a11 | 2018-07-03 19:28:18 +0200 | [diff] [blame] | 309 | ./configure --with-thrift "CXXFLAGS=-O0 -g" |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 310 | else |
Carmelo Cascone | f742a11 | 2018-07-03 19:28:18 +0200 | [diff] [blame] | 311 | ./configure --with-thrift |
Carmelo Cascone | f02872d | 2018-06-20 08:49:02 +0200 | [diff] [blame] | 312 | fi |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 313 | # FIXME: re-enable --with-sysrepo when gNMI support becomes more stable |
| 314 | # ./configure --with-sysrepo --with-thrift 'CXXFLAGS=-O0 -g' |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 315 | make -j${NUM_CORES} |
| 316 | sudo make install |
| 317 | sudo ldconfig |
| 318 | } |
| 319 | |
| 320 | function do_p4c { |
| 321 | cd ${BUILD_DIR} |
| 322 | if [ ! -d p4c ]; then |
| 323 | git clone https://github.com/p4lang/p4c.git |
| 324 | fi |
| 325 | cd p4c |
| 326 | git fetch |
| 327 | git checkout ${P4C_COMMIT} |
| 328 | git submodule update --init --recursive |
| 329 | |
| 330 | mkdir -p build |
| 331 | cd build |
| 332 | cmake .. |
| 333 | make -j${NUM_CORES} |
| 334 | sudo make install |
| 335 | sudo ldconfig |
| 336 | } |
| 337 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 338 | function do_scapy-vxlan { |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 339 | cd ${BUILD_DIR} |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 340 | if [ ! -d scapy-vxlan ]; then |
| 341 | git clone https://github.com/p4lang/scapy-vxlan.git |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 342 | fi |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 343 | cd scapy-vxlan |
| 344 | |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 345 | git pull origin master |
| 346 | |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 347 | sudo python setup.py install |
| 348 | } |
| 349 | |
| 350 | function do_ptf { |
| 351 | cd ${BUILD_DIR} |
| 352 | if [ ! -d ptf ]; then |
| 353 | git clone https://github.com/p4lang/ptf.git |
| 354 | fi |
| 355 | cd ptf |
| 356 | git pull origin master |
| 357 | |
| 358 | sudo python setup.py install |
Carmelo Cascone | 76b3ee6 | 2018-01-30 15:45:27 -0800 | [diff] [blame] | 359 | } |
| 360 | |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 361 | function check_commit { |
| 362 | if [ ! -e $2 ]; then |
| 363 | return 0 # true |
| 364 | fi |
| 365 | if [[ $(< $2) != "$1" ]]; then |
| 366 | return 0 # true |
| 367 | fi |
| 368 | return 1 # false |
| 369 | } |
| 370 | |
| 371 | # The following is borrowed from Mininet's util/install.sh |
| 372 | function version_ge { |
| 373 | # sort -V sorts by *version number* |
| 374 | latest=`printf "$1\n$2" | sort -V | tail -1` |
| 375 | # If $1 is latest version, then $1 >= $2 |
| 376 | [ "$1" == "$latest" ] |
| 377 | } |
| 378 | |
| 379 | MUST_DO_ALL=false |
| 380 | DID_REQUIREMENTS=false |
| 381 | function check_and_do { |
| 382 | # Check if the latest built commit is the same we are trying to build now, |
| 383 | # or if all projects must be built. If true builds this project. |
| 384 | commit_id="$1" |
| 385 | proj_dir="$2" |
| 386 | func_name="$3" |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 387 | step_name="$4" |
| 388 | commit_file=${BUILD_DIR}/${proj_dir}/.last_built_commit_${step_name} |
Carmelo Cascone | 0535467 | 2018-04-10 13:24:03 -0700 | [diff] [blame] | 389 | if [ ${MUST_DO_ALL} = true ] \ |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 390 | || check_commit ${commit_id} ${commit_file}; then |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 391 | echo "#" |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 392 | echo "# Building ${step_name} (${commit_id})" |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 393 | echo "#" |
| 394 | # Print commands used to install to aid debugging |
| 395 | set -x |
| 396 | if ! ${DID_REQUIREMENTS} = true; then |
| 397 | do_requirements |
| 398 | # TODO consider other Linux distros; presently this script assumes |
| 399 | # that it is running on Ubuntu. |
| 400 | RELEASE=`lsb_release -rs` |
| 401 | if version_ge $RELEASE 16.04; then |
| 402 | do_requirements_1604 |
| 403 | elif version_ge $RELEASE 14.04; then |
| 404 | do_requirements_1404 |
| 405 | else |
| 406 | echo "Ubuntu version $RELEASE is not supported" |
| 407 | exit 1 |
| 408 | fi |
| 409 | DID_REQUIREMENTS=true |
| 410 | fi |
| 411 | eval ${func_name} |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 412 | echo ${commit_id} > ${commit_file} |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 413 | # Build all next projects as they might depend on this one. |
| 414 | MUST_DO_ALL=true |
| 415 | # Disable printing to reduce output |
| 416 | set +x |
| 417 | else |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 418 | echo "${step_name} is up to date (commit ${commit_id})" |
| 419 | fi |
| 420 | # Exit if last step. |
| 421 | if [ ${step_name} = ${LAST_STEP} ]; then |
| 422 | exit |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 423 | fi |
| 424 | } |
| 425 | |
| 426 | mkdir -p ${BUILD_DIR} |
| 427 | cd ${BUILD_DIR} |
| 428 | # In dependency order. |
| 429 | check_and_do ${PROTOBUF_COMMIT} protobuf do_protobuf protobuf |
| 430 | check_and_do ${GRPC_COMMIT} grpc do_grpc grpc |
Carmelo Cascone | 4f985cd | 2018-02-11 17:36:42 -0800 | [diff] [blame] | 431 | # FIXME: re-enable when gNMI support becomes more stable |
| 432 | # check_and_do ${LIBYANG_COMMIT} libyang do_libyang libyang |
| 433 | # check_and_do ${SYSREPO_COMMIT} sysrepo do_sysrepo sysrepo |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 434 | check_and_do ${BMV2_COMMIT} bmv2 do_pi_bmv2_deps bmv2-deps |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 435 | check_and_do ${PI_COMMIT} PI do_PI PI |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 436 | check_and_do ${BMV2_COMMIT} bmv2 do_bmv2 bmv2 |
| 437 | check_and_do ${P4C_COMMIT} p4c do_p4c p4c |
Carmelo Cascone | 95e5afd | 2018-07-17 14:45:23 +0200 | [diff] [blame] | 438 | check_and_do master scapy-vxlan do_scapy-vxlan scapy-vxlan |
| 439 | check_and_do master ptf do_ptf ptf |
Carmelo Cascone | b7e618d | 2018-01-12 18:31:33 -0800 | [diff] [blame] | 440 | |
| 441 | echo "Done!" |