opencontrail-builder/JuniperControllerBuild
Egon Rijpkema b18ca6cf63 Trying to make debian packages
So far i have teh controler, ifmap server and web core.
2017-07-21 13:52:56 +02:00

351 lines
11 KiB
Bash
Executable File

#!/bin/bash -ex
# printout debug info when running this script.
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
#
# Gemaakt voor RuG-CIT 2017-06-10 Door: Rein van Weerden
# ======================================================================
# JuniperControllerBuild Copyright dVR H&S Sys. 2017
# ======================================================================
#
# JuniperControllerBuild is used
# go and build a Contrail Controlller in a virtualbox
#
# ____
# <. .\
# \..|
# \ |___(\--/)
# __/ ( . . )
# "'._. '-.O.'
# '-. \ "|\
# '.,,/'., dVR
#
#https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ -n ${DX} ]]
then
exec 1>>/tmp/${0##*/}.log 2>&1
set -${DX} # Are you going to debug? (DX is set to 'x' (set DX='x') or unset)
fi
#
date > $HOME/JuniperControllerBuild.run.time
rm -Rf .repo
rm -Rf ~/.repo*
cd $HOME
echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections
sudo apt-get update
sudo apt-get -y install pkgconf libcurl4-openssl-dev autoconf automake bison debhelper flex libexpat-dev \
libgettextpo0 libtool libxml2-utils make python-all python-dev python-lxml python-setuptools python-sphinx \
ruby-ronn scons unzip vim-common libsnmp-python libfixbuf3 libfixbuf3-dev zlib1g-dev glibc-source libsslcommon2 libssl-dev
cd ~/src
# sudo cp /media/sf_VM-sfolder/build/openssl-1.0.2d.tar.gz .
# sudo chown rein:rein openssl-1.0.2d.tar.gz
# tar xzf openssl-1.0.2d.tar.gz
# cd openssl-1.0.2d
# ./config --prefix=/usr threads zlib shared
# make all > make.all.lst 2>&1
# find /usr -name "libssl.*" -exec rm -f {} \;
# find /usr -name "libcrypto.*" -exec rm -f {} \;
# sudo make install > make.install.lst 2>&1
cd /usr/lib/x86_64-linux-gnu
# sudo ln -s libssl.so.1.0.0 libssl.so.1.0.0
# sudo ln -s libssl.so.1.0.0 libssl.so.1.0.2
# sudo ln -s libssl.so.1.0.0 libssl.so
# sudo ln -s libcrypto.so.1.0.0 libcrypto.so.1.0.0
# sudo ln -s libcrypto.so.1.0.0 libcrypto.so.1.0.2
# sudo ln -s libcrypto.so.1.0.0 libcrypto.so
sudo cp -a libssl.* libcrypto.* /lib/x86_64-linux-gnu/
mkdir -p ~/src/Juniper/build/lib
sudo cp -a libssl.* libcrypto.* ~/src/Juniper/build/lib
sudo ldconfig
cd ~/src
sudo apt-get -y install 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 google-mock libgoogle-perftools-dev liblog4cplus-dev libtbb-dev libhttp-parser-dev libxml2-dev libicu-dev libpcap-dev libsasl2-dev
sudo apt-get -y install libcurl4-gnutls-dev
sudo apt-get -y install libzookeeper-java libzookeeper2 libzookeeper-mt2 libzookeeper-mt-dev
sudo apt-get -y install cmake cmake-data cmake-extras
sudo apt-get -y install python-virtualenv python-libxml2 libxslt1-dev
sudo apt-get -y install w3m
sudo apt-get -y install nmon
sudo apt-get -y install python3-pip
sudo pip3 install pip --upgrade
sudo apt-get -y install python-pip
sudo pip2 install pip --upgrade
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y autoremove
#sudo ln -s /usr/bin/libtoolize /usr/bin/libtool
cd ~/src
# git clone https://github.com/tubav/libipfix.git
#sudo cp /media/sf_VM-sfolder/build/libipfix_110209.tgz # staat er al
#sudo chown rein:rein libipfix_110209.tgz
tar xzf libipfix_110209.tgz
cd libipfix_110209/
./configure --prefix=/usr > configure.lst 2>&1
make all > make.all.lst 2>&1
sudo make install > make.install.lst 2>&1
cd ~/src
if [ ! -d librdkafka ] ; then
git clone https://github.com/edenhill/librdkafka.git
fi
cd librdkafka
./configure --prefix=/usr
make all > make.all.lst 2>&1
sudo make install > make.install.lst 2>&1
sudo ldconfig
cd /usr/lib
if [[ ! -f libnl-3.so ]]
then
sudo ln -s /lib/x86_64-linux-gnu/libnl-3.so.200 libnl-3.so
fi
if [[ ! -f libnl-genl-3.so ]]
then
sudo ln -s /lib/x86_64-linux-gnu/libnl-genl-3.so.200 libnl-genl-3.so
fi
cd ~/src
sudo ldconfig
cat << EOF > ~/.gitconfig.new
[user]
name = plReynaerde
email = plreynaerde@dvrhss.net
[push]
default = simple
[filter "media"]
clean = git media clean %f
smudge = git media smudge %f
required = true
[http]
sslVerify = false
EOF
sudo mv -f ~/.gitconfig.new ~/.gitconfig
cd ~/src
if [ ! -d protobuf ] ; then
git clone https://github.com/google/protobuf.git -b 3.3.x
fi
cd protobuf
# Copied from autogen.sh and modified.
if [ ! -d gmock ]; then
curl -L -O http://pkgs.fedoraproject.org/repo/pkgs/gmock/gmock-1.7.0.zip/073b984d8798ea1594f5e44d85b20d66/gmock-1.7.0.zip
unzip gmock-1.7.0.zip
sudo cp -r gmock-1.7.0 gmock
sudo chown $USER: gmock
mv gmock-1.7.0 gtest
rm gmock-1.7.0.zip
fi
sudo chown -R $USER: .
autoreconf -f -i -Wall
rm -rf autom4te.cache config.h.in~
./configure --prefix=/usr
make > make.all.lst 2>&1
sudo make install > make.install.lst 2>&1
mkdir -p ~/src/Juniper/build/lib
cd ~/src/Juniper/build/lib/
cp -a ~/src/protobuf/src/.libs/* .
rm -f libprotobuf.la libprotobuf-lite.la libprotoc.la
cp -a ~/src/protobuf/src/libprotobuf.la .
cp -a ~/src/protobuf/src/libprotobuf-lite.la .
cp -a ~/src/protobuf/src/libprotoc.la .
sudo ldconfig
cd ~/src
mkdir -p casdrvr
cd casdrvr
DISTRO=$(sudo lsb_release -is|tr '[:upper:]' '[:lower:]')
THISONE=$(sudo lsb_release -rs)
ALIST=$(w3m -dump -no-graph http://downloads.datastax.com/cpp-driver/${DISTRO}/${THISONE}/dependencies/libuv/|tail -n +6|head -n -2|cut -f2 -d'v'|sed 's/\/.*$//'|tr -d '.')
for ALN in ${ALIST}
do
if [[ $((${ALNO})) -lt $((${ALN})) ]]
then
export ALNO=${ALN}
fi
done
export ALNN=v
for ((i=0; i<${#ALNO}; i++))
do
if [[ i -ne 1 ]]
then
export ALNN+="${ALNO:$i:1}."
else
export ALNN+="${ALNO:$i:1}"
fi
done
ALEN=$((${#ALNN} - 1))
AVN=${ALNN:0:${ALEN}}
ADRVLST=$(w3m -dump -no-graph http://downloads.datastax.com/cpp-driver/${DISTRO}/${THISONE}/dependencies/libuv/${AVN}/|tail -n +7|head -n -2|awk -F ' ' '{ print $3 }'|grep -v dbg)
for AFN in ${ADRVLST}
do
wget http://downloads.datastax.com/cpp-driver/${DISTRO}/${THISONE}/dependencies/libuv/${AVN}/${AFN}
done
sudo dpkg --force-all --install libuv_*
sudo dpkg --force-all --install libuv-dev_*
cd ~/src
test -d cpp-driver || git clone https://github.com/datastax/cpp-driver.git
mkdir -p cpp-driver/build
cd cpp-driver
cd build
cmake .. > cmake..lst 2>&1
make > make.all.lst 2>&1
sudo make install > make.install.lst 2>&1
mkdir -p ~/src/Juniper/build/lib/
cd ~/src/Juniper/build/lib/
cp ~/src/cpp-driver/build/libcassandra.so.2.7.0 .
cp ~/src/cpp-driver/build/libcassandra_static.a .
rm libcassandra.so.2 libcassandra.so
ln -s libcassandra.so.2.7.0 libcassandra.so.2
ln -s libcassandra.so.2 libcassandra.so
sudo ldconfig
cd ~/src
test -d git-repo || git clone https://gerrit.googlesource.com/git-repo
cd git-repo
sudo cp repo /usr/bin/
cd ~/src
mkdir -p Juniper
cd Juniper
#repo init -u https://github.com/Juniper/contrail-vnc -b R4.0
yes | repo init -u git@github.com:Juniper/contrail-vnc -b R4.0
#find .repo/manifests -iname "*.xml" -exec sed -i 's/project name="/project name="Juniper\//' {} \;
repo sync
#sed -i 's#third_party/rapidjson#build/third_party/rapidjson#' controller/lib/rapidjson/SConscript
# <package>
# <name>Apache Thrift 0.8</name>
# <url>http://archive.apache.org/dist/thrift/0.8.0/thrift-0.8.0.tar.gz</url>
# <patches>
# <patch strip="2">thrift_patch1.diff</patch>
# <patch strip="2">thrift_autoconf.patch</patch>
# </patches>
# <format>tgz</format>
# <md5>d29dfcd38d476cbc420b6f4d80ab966c</md5>
# <autoreconf>true</autoreconf>
# </package>
cd third_party
cp packages.xml packages.xml.org
# sed -i 's/0.8.0\/thrift-0.8.0.tar.gz/0.10.0\/thrift-0.10.0.tar.gz/' packages.xml
# sed -i 's/d29dfcd38d476cbc420b6f4d80ab966c/795c5dd192e310ffff38cfd9430d6b29/' packages.xml
# sed -i '/thrift_patch1.diff/d' packages.xml
# sed -i '/thrift_autoconf.patch/d' packages.xml
# sed -i '/autoreconf/d' packages.xml
sudo mkdir -p /tmp/cache/$USER/third_party
sudo chown $USER: /tmp/cache/$USER/third_party
curl https://github.com/redis/hiredis/archive/v0.11.0.tar.gz -o /tmp/cache/$USER/third_party/hiredis-v0.11.0.tar.gz
python fetch_packages.py --file packages.xml
# mv thrift-0.10.0 thrift-0.8.0
cd thrift-0.8.0
autoconf
# sudo cp /media/sf_VM-sfolder/build/THRIFT-2039-thrift_config_h.patch .
# sudo chown rein:rein THRIFT-2039-thrift_config_h.patch
# patch -p1 < THRIFT-2039-thrift_config_h.patch
mkdir -p ~/src/Juniper/build/include/
cd ~/src/Juniper/build/include/
# sudo cp /media/sf_VM-sfolder/build/thrift_include.txz .
# sudo chown rein:rein thrift_include.txz
# tar xJf thrift_include.txz
mkdir -p ~/src/Juniper/third_party/thrift-0.8.0/compiler/cpp
cd ~/src/Juniper/third_party/thrift-0.8.0/compiler/cpp
# sudo cp /media/sf_VM-sfolder/build/thrift_include.txz .
# sudo chown rein:rein thrift_include.txz
# tar xJf thrift_include.txz
cd ~/src/Juniper
if [[ -f third_party/.cache/vijava55b20130927src.jar ]]
then
if [[ -d ~/src/Juniper/third_party/vijava ]]
then
cd ~/src/Juniper/third_party/vijava
if [[ ! -f README.txt ]]
then
unzip ../.cache/vijava55b20130927src.jar
cd ~/src/Juniper
patch -p1 < third_party/vijava_patch1.diff
fi
fi
fi
cd ~/src/Juniper
if [[ -f third_party/.cache/pugixml-1.2.tar.gz ]]
then
if [[ -d ~/src/Juniper/third_party/pugixml ]]
then
cd ~/src/Juniper/third_party/pugixml
if [[ ! -f readme.txt ]]
then
tar xzf ../.cache/pugixml-1.2.tar.gz
fi
fi
fi
cd ~/src/Juniper/third_party
tar xvf $DIR/sharespot.tar
python fetch_packages.py --file mpackages.xml
export GOROOT=$HOME/src/Juniper/third_party/go
export GOPATH=$HOME/go
export GO=${GOROOT}/bin/go
mkdir -p ${GOPATH}/src/github.com/containernetworking
cd ${GOPATH}/src/github.com/containernetworking
rm -Rf cni
test -d cni || git clone https://github.com/containernetworking/cni.git
test -d plugins || git clone https://github.com/containernetworking/plugins.git
cd -
${GO} get "github.com/docker/docker/client"
${GO} get "github.com/natefinch/lumberjack"
${GO} get "github.com/vishvananda/netlink"
mkdir -p ~/src/Juniper/third_party/go/src
cd ~/src/Juniper/third_party/go/src
ln -s ~/go/src/github.com github.com
mkdir -p ~/src/Juniper/third_party/go/pkg/linux_amd64
cd ~/src/Juniper/third_party/go/pkg/linux_amd64
ln -s ~/go/pkg/linux_amd64/github.com github.com
cd ~/src/Juniper/controller/src/container/cni/cni/common
sudo cp ~/src/Juniper/third_party/{macvlan.go,interface.go,veth.go} .
sudo chown -R $USER: .
# cd ~/src
# git clone https://github.com/Juniper/contrail-controller.git
# cd ~/src/Juniper/controller/src
# rm -Rf analytics
# cp -a ~/src/contrail-controller/src/analytics .
cd ~/src/Juniper/controller/src/analytics
# ln -s ../../../build/debug/analytics/analytics_request_skeleton.cpp analytics_request_skeleton.cpp # analytics_request_skeleton.cpp not present
sed -i "s/ 'nodeinfo',/ 'nodeinfo',\n 'dl',/" SConscript
cd ~/src/Juniper
sudo -H pip install generateDS --upgrade
echo "doScons" > ~/next
# should fix "scons: *** [build/packages/contrail/usr/bin/contrail-k8s-cni] build/production/container/cni/bin/kube_cni: No such file or directory"
# taken from here: https://github.com/zioc/contrail-devstack-plugin/issues/27
CONTRAIL_PATCHES='cd $CONTRAIL_DEST/controller && git fetch https://review.opencontrail.org/Juniper/contrail-controller refs/changes/52/32652/4 && git cherry-pick FETCH_HEAD'
make -f packages.make all