2 ##############################################################################
3 # Copyright (c) 2017 Tim Rozet (Red Hat) and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
15 # Builds Quagga, Zebra and other dependency RPMs for CentOS 7
16 # Install package dependencies
17 install_quagga_build_deps() {
18 sudo yum -y install automake bison flex libtool make readline-devel \
19 texinfo texi2html rpm-build libcap-devel groff net-snmp-devel pam-devel glib2 glib2-devel epel-release spectool \
20 wget git gcc-c++ openssl-devel boost-devel boost-static gtest zeromq-4.1.4 zeromq-devel-4.1.4 \
21 capnproto-devel capnproto-libs capnproto
22 sudo yum -y groupinstall "Development Tools"
28 $0 Builds Quagga/ZRPC and Dependency RPMs
30 usage: $0 [ [-a | --artifact] artifact ]
33 -a artifact to build (thrift, capnproto, quagga, zrpc). Default: All artifacts.
34 -c clean all build directories
35 -h help, prints this help text
38 build_quagga.sh -a thrift
43 while [ "${1:0:1}" = "-" ]
67 # Removes build directory folder and re-creates RPM DIRs to use
68 function quagga_clean(){
69 rm -rf ${QUAGGA_BUILD_DIR}
70 sudo yum remove -y zrpc* quagga* thrift* c-capnproto*
74 function build_thrift(){
76 git clone https://git-wip-us.apache.org/repos/asf/thrift.git
79 wget https://issues.apache.org/jira/secure/attachment/12840511/0002-THRIFT-3986-using-autoreconf-i-fails-because-of-miss.patch
80 wget https://issues.apache.org/jira/secure/attachment/12840512/0001-THRIFT-3987-externalise-declaration-of-thrift-server.patch
81 patch -p1 < 0002-THRIFT-3986-using-autoreconf-i-fails-because-of-miss.patch
82 patch -p1 < 0001-THRIFT-3987-externalise-declaration-of-thrift-server.patch
84 ./configure --without-qt4 --without-qt5 --without-csharp --without-java \
85 --without-erlang --without-nodejs --without-perl --without-python \
86 --without-php --without-php_extension --without-dart --without-ruby \
87 --without-haskell --without-go --without-haxe --without-d
88 # Hack somehow the testing file of php is not there
89 # We will disable php anyhow later on.
90 touch lib/php/src/ext/thrift_protocol/run-tests.php
93 spectool -g -R thrift.spec
94 mv ../thrift-*.tar.gz $rpmbuild/SOURCES/
95 rpmbuild --define "_topdir $rpmbuild" -ba thrift.spec --define "without_ruby 1" --define "without-php 1"
101 # This is a library for capnproto in C. Not to be confused with
102 # the capnproto provided by the repos
103 function build_capnproto(){
105 git clone https://github.com/opensourcerouting/c-capnproto
107 git checkout 332076e52257
109 ./configure --without-gtest
112 cp ${BUILD_ROOT}/rpm_specs/c_capnproto.spec $rpmbuild/SPECS/
113 cp c-capnproto-*.tar.gz $rpmbuild/SOURCES/
114 rpmbuild --define "_topdir $rpmbuild" -ba $rpmbuild/SPECS/c_capnproto.spec
121 sudo yum -y install $rpmbuild/RPMS/x86_64/*.rpm
122 git clone https://github.com/6WIND/quagga.git
123 pushd quagga > /dev/null
124 # checkout the parent of the bellow patch.
125 # Once the issue addressed by the patch is fixed
126 # these two lines can be removed.
127 git checkout 95bb0f4a
128 patch -p1 < ${PATCHES_DIR}/fix_quagga_make_dist.patch
130 ./configure --with-zeromq --with-ccapnproto --enable-user=quagga \
131 --enable-group=quagga --enable-vty-group=quagga \
132 --disable-doc --enable-multipath=64
136 cp ${BUILD_ROOT}/rpm_specs/quagga.spec $rpmbuild/SPECS/
137 cp quagga*.tar.gz $rpmbuild/SOURCES/
138 cat > $rpmbuild/SOURCES/bgpd.conf <<EOF
150 rpmbuild --define "_topdir $rpmbuild" -ba $rpmbuild/SPECS/quagga.spec
156 sudo yum -y install $rpmbuild/RPMS/x86_64/*.rpm
158 git clone https://github.com/6WIND/zrpcd.git
159 pushd zrpcd > /dev/null
161 export QUAGGA_CFLAGS='-I/usr/include/quagga/'
162 # checkout the parent of the bellow patch.
163 # Once the issue addressed by the patch is fixed
164 # these two lines can be removed.
165 git checkout 9bd1ee8e
166 patch -p1 < ${PATCHES_DIR}/fix_zrpcd_make_dist.patch
167 patch -p1 < ${PATCHES_DIR}/zrpcd_hardcoded_paths.patch
171 ./configure --enable-zrpcd \
172 --enable-user=quagga --enable-group=quagga \
173 --enable-vty-group=quagga
176 cat > $rpmbuild/SOURCES/zrpcd.service <<EOF
178 Description=ZRPC daemon for quagga
179 After=network.service
182 ExecStart=/usr/sbin/zrpcd
184 ExecStartPre=-/usr/bin/mkdir /var/run/quagga/
185 ExecStartPre=/usr/bin/chown -R quagga:quagga /var/run/quagga/
186 PIDFile=/var/run/zrpcd.pid
189 WantedBy=default.target
191 cp zrpcd-*.tar.gz $rpmbuild/SOURCES/
192 cp ${BUILD_ROOT}/rpm_specs/zrpc.spec $rpmbuild/SPECS/
193 rpmbuild --define "_topdir $rpmbuild" -ba $rpmbuild/SPECS/zrpc.spec
200 if [ -z "$QUAGGA_BUILD_DIR" ]; then
201 echo "ERROR: You must set QUAGGA_BUILD_DIR env variable as the location to build!"
203 elif [ -z "$QUAGGA_RPMS_DIR" ]; then
204 echo "WARN: QUAGGA_RPMS_DIR env var is not set, will default to QUAGGA_BUILD_DIR/rpmbuild"
205 rpmbuild=${QUAGGA_BUILD_DIR}/rpmbuild
207 rpmbuild=${QUAGGA_RPMS_DIR}
210 if [ -z "$BUILD_ROOT" ]; then
211 echo "WARN: BUILD_ROOT env var not set, will default to $(pwd)"
215 if [ -z "$PATCHES_DIR" ]; then
216 echo "WARN: PATCHES_DIR env var not set, will default to ${BUILD_ROOT}/patches"
217 PATCHES_DIR=${BUILD_ROOT}/patches
220 if [ -n "$CLEAN" ]; then
224 install_quagga_build_deps
226 mkdir -p ${QUAGGA_BUILD_DIR}
227 mkdir -p $rpmbuild $rpmbuild/SOURCES $rpmbuild/SPECS $rpmbuild/RPMS
228 pushd $QUAGGA_BUILD_DIR > /dev/null