Dependencies

Build dependencies

Dependencies needed to build Opencontrail.

Actual deps in tools/packages/debian/contrail/debian/builddep.trusty

cat tools/packages/debian/contrail/debian/builddep.trusty|sed s,[\ \\\t],,g|tr -d ','|tr '\n' ' '
libboost-dev libboost-chrono-dev libboost-date-time-dev
libboost-filesystem-dev libboost-program-options-dev libboost-python-dev
libboost-regex-dev libboost-system-dev libboost-thread-dev
libcurl4-openssl-dev google-mock libgoogle-perftools-dev liblog4cplus-dev
libtbb-dev libhttp-parser-dev libxml2-dev libicu-dev

Dependencies for building 3rd party packages:

python-lxml autoconf automake bzip2 libtool patch unzip wget

And a few more, see Build-Depends: section of tools/packages/debian/contrail/debian/control

scons git python-lxml wget gcc patch make unzip flex bison g++ libssl-dev
autoconf automake libtool pkg-config vim python-dev python-setuptools
libprotobuf-dev protobuf-compiler libsnmp-python librdkafka-dev

Note that you need latest librdkafka (version 0.8.6) to provide librdkafka++.so It is not present in Debian or Ubuntu repositories so you need to find it somewhere on Launchpad or build on your own.

You also need libipfix. It’s not in Debian repository so you need to build it on your own or grab it here: https://launchpad.net/~opencontrail/+archive/ubuntu/ppa/+packages

Some more dependencies may be needed, I have found out at least following:

debhelper libxml2-utils python-all python-sphinx ruby-ronn
module-assistant ant default-jdk javahelper libcommons-codec-java
libhttpcore-java liblog4j1.2-java

Cowbuilder

To build debian packages with Cowbuilder/Pbuilder, it will handle dependencies by itself in chrooted environment.

Therefore you need just a few packages to be able to build debian source files.

libxml2-utils
python-lxml
autoconf
automake
libtool
patch
unzip
pkg-config
javahelper
ant
python-setuptools

Install dependencies

To install opencontrail packages, you need to satisfy some dependencies that are not in Ubuntu Trusty installation.

python-geventhttpclient (>= 1.0)
python-certifi
python-backports.ssl-match-hostname
python-ncclient
python-pycassa (>= 1.7.2)
python-xmltodict
python-docker-py (python-opencontrail-vrouter-netns)
python-redis (>= 2.8.0)

Build

Manual

Follow these steps to build Opencontrail manually or skip to building with Jenkins and Cowbuilder.

Get android repo tool
wget https://storage.googleapis.com/git-repo-downloads/repo
chmod +x repo
Initialize sandbox
mkdir build;cd build
repo init -u git@github.com:Juniper/contrail-vnc.git -b ${CONTRAIL_BRANCH:-master}
repo sync
Get and patch 3rd party packages
cd third_party
./fetch_packages.py
Execute the build
# For building into dest root, no debian package
scons -j ${JOBS_COUNT:-$(grep -c processor /proc/cpuinfo || echo 1)}

# Or create Debian packages, they will appear in build/packages/ directory
make -f packages.make all

# You can also build only source packages and build binaries with
# cowbuilder or some better way that will also handle dependencies
make -f packages.make source-all

Jenkins

To automate building with Jenkins, you can use script like this:

#!/bin/bash -xe

export USER=$(whoami)
JOBS_COUNT=${JOBS_COUNT:-$(cat /proc/cpuinfo | grep -c processor || echo 1)}

# Github account is needed to fetch repositories
pgrep -l -u $USER -f | grep -e ssh-agent\$ >/dev/null || ssh-agent|grep -v "Agent pid" > ~/.ssh/ssh-agent.sh
. ~/.ssh/ssh-agent.sh
ssh-add ${SSH_KEY:-"$HOME/.ssh/id_rsa"}
grep github ~/.ssh/known_hosts || ssh-keyscan github.com >> ~/.ssh/known_hosts

if [ ! -d bin ]; then
    mkdir bin
    wget -O bin/repo https://storage.googleapis.com/git-repo-downloads/repo
    chmod +x bin/repo
fi

PATH="$WORKSPACE/bin:$PATH"

[ ! -d build ] && mkdir build
cd build
if [[ "$CONTRAIL_BRANCH" == "default" ]]; then
    repo init -u $CONTRAIL_VNC_REPO
else
    repo init -u $CONTRAIL_VNC_REPO -b $CONTRAIL_BRANCH
fi
repo sync

cd third_party
python fetch_packages.py
cd ..

# Normal build
# scons -j $JOBS_COUNT
# Build debian packages
#  make -f packages.make all
# Build debian source packages for binary build
# unfortunately source-all target doesn't work
#  make -f packages.make source-all
grep '^source-package-.*:' packages.make | cut -d : -f 1 | while read i; do
    make -f packages.make $i
done

You could possibly also use Jenkins repo plugin for SCM management.

Cowbuilder

If you are going to build debian packages, I would advice to use make -f packages.make source-all in the script above.

This will create *.dsc files that can be used as source artifacts for build with Cowbuilder which can create build chroot and handle build dependencies without garbaging your system.

Binary build job can look like this, using jenkins-debian-glue:

#!/bin/bash -xe
for i in *.dsc; do
    pkgname=$(echo $i|cut -d "_" -f 1)
    [ ! -d $pkgname ] && mkdir $pkgname
    mv ${pkgname}_*.gz ${pkgname}_*.dsc ${pkgname}/
    cd $pkgname
    export WORKSPACE=$(pwd)
    /usr/bin/build-and-provide-package
    cd ..
done
export WORKSPACE=$(pwd)

Don’t forget you need to install additional dependencies that are not present in Debian or Ubuntu repositories.

To setup additional repository, update /etc/pbuilderrc:

OTHERMIRROR="deb http://apt.tcpcloud.eu/nightly cloudlab"

Or to use your only own repository for both debootstrap and build, you can use setup similar to this:

MIRRORSITE="http://apt.tcpcloud.eu/nightly"
COMPONENTS="main cloudlab security"
# Debootstrap in Ubuntu is using ubuntu keyring, to use # your own, provide
# default keyring
DEBOOTSTRAPOPTS=(${DEBOOTSTRAPOPTS[@]} "--keyring=/etc/apt/trusted.gpg")
APTKEYRINGS=(${APTKEYRINGS[@]} "/etc/apt/trusted.gpg")

Unfortunately if you have different list of components than are default for your distribution, you need to export COMPONENTS before running build-and-provide-package otherwise jenkins debian glue will override these provided in pbuilderrc.