Install pypcap package for CentOS
[ci-management.git] / packer / provision / basebuild.sh
1 #!/bin/bash
2
3 # vim: ts=4 sw=4 sts=4 et tw=72 :
4
5 rh_systems() {
6
7     # RH Install build tools
8     echo "---> Installing RH build tools $(date +'%Y%m%dT%H%M%S')"
9     RH_TOOLS_PKGS="@development redhat-lsb glibc-static \
10       java-1.8.0-openjdk-devel yum-utils openssl-devel apr-devel indent rpm"
11     yum install -y ${RH_TOOLS_PKGS}
12
13     # Memory leakage checks
14     yum install -y valgrind
15
16     # RH Install Python dependencies
17     ###REMOVED mysql-devel
18     echo "---> Installing RH Python dependencies $(date +'%Y%m%dT%H%M%S')"
19     RH_PYTHON_PKGS="python-devel python-virtualenv python-setuptools \
20       python-pip kernel-devel epel-rpm-macros"
21     pip install --upgrade pip
22     yum install -y ${RH_PYTHON_PKGS}
23     pip install pypcap
24
25     # RH Install Documentation packages
26     ###Removed python-pyparsing
27     echo "---> Installing RH documentation packages $(date +'%Y%m%dT%H%M%S')"
28     RH_DOC_PKGS="doxygen graphviz python-jinja2 asciidoc \
29       dblatex source-highlight python-sphinx libxml2 libffi-devel python-cffi"
30     yum install -y install ${RH_DOC_PKGS}
31
32     # RH Install GCC packages
33     echo "---> Installing RH GCC packages $(date +'%Y%m%dT%H%M%S')"
34     RH_GCC_PKGS="cpp gcc c++ cmake make"
35     yum install -y ${RH_GCC_PKGS}
36
37     # RH Install components to build Ganglia modules
38     echo "---> Installing RH components $(date +'%Y%m%dT%H%M%S')"
39     RH_GANGLIA_MODS="libconfuse-devel ganglia-devel mock"
40     yum install -y --enablerepo=epel ${RH_GANGLIA_MODS}
41
42     # RH Install module for VPP project
43     echo uio_pci_generic >> /etc/modules
44
45     # RH Install VPP packages to shorten build times
46     echo "---> Installing VPP dependencies $(date +'%Y%m%dT%H%M%S')"
47     RH_VPP_PKGS="curl autoconf automake bison ccache dkms git libtool \
48       libconfuse-dev git-review cscope"
49     yum install -y ${RH_VPP_PKGS}
50
51     yum groupinstall "Development Tools"
52     # RH Install TLDK dependencies
53     RH_TLKD_PKGS="libpcap-devel libcap-devel scapy"
54     yum install -y ${RH_TLKD_PKGS}
55
56     # RH Install Puppet packages
57     PUPPET_PKGS="libxml2-devel libxslt-devel ruby-devel zlib-devel"
58     yum install -y ${PUPPET_PKGS}
59
60     # RH Install debuginfo packages
61     #echo "---> Installing debug packages $(date +'%Y%m%dT%H%M%S')"
62     #RH_DEBUG_PKGS="glibc openssl-libs zlib"
63     #debuginfo-install -y ${RH_DEBUG_PKGS}
64
65     # # RH Packer builds happen from the centos flavor images
66     # PACKERDIR=$(mktemp -d)
67     # # disable double quote checking
68     # # shellcheck disable=SC2086
69     # cd $PACKERDIR
70     # wget https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_linux_amd64.zip
71     # unzip packer_0.10.1_linux_amd64.zip -d /usr/local/bin/
72     # # rename packer to avoid conflicts with cracklib
73     # mv /usr/local/bin/packer /usr/local/bin/packer.io
74
75     # # cleanup from the installation
76     # # disable double quote checking
77     # # shellcheck disable=SC2086
78     # rm -rf $PACKERDIR
79     # # cleanup from previous install process
80     # if [ -d /tmp/packer ]
81     # then
82     #     rm -rf /tmp/packer
83     # fi
84 }
85
86 ubuntu_systems() {
87
88     # DEB add Toolchain repo
89     sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
90
91     #Configuring thirdparty Nexus repo
92     echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/thirdparty ./" > /etc/apt/sources.list.d/FD.io.thirdparty.list
93
94     # DEB Install PPA packages
95     echo "---> Adding '$1' PPA $(date +'%Y%m%dT%H%M%S')"
96     dpkg -l software-properties-common > /dev/null 2>&1 || software-properties-common
97
98     listfile=$(perl -e "print(q{$1} =~ m{^ppa:(.+)/ppa})")-ppa-${CODENAME}.list
99       if [ ! -f /etc/apt/sources.list.d/${listfile} ]
100       then
101         do_retry sudo apt-add-repository -y $1
102       fi
103
104     apt-get update
105
106     # DEB cloud packages
107     echo "---> Installing cloud packages $(date +'%Y%m%dT%H%M%S')"
108     CLOUD_PKGS="cloud-initramfs-dyn-netconf cloud-initramfs-growroot \
109       cloud-initramfs-rescuevol"
110     apt install -y ${CLOUD_PKGS}
111
112     # DEB Install Python dependencies
113     echo "---> Installing Python dependencies $(date +'%Y%m%dT%H%M%S')"
114     PYTHON_PKGS="python-dev python-virtualenv python-setuptools python-pip \
115       libssl-dev libmysqlclient-dev python2.7 libffi-dev python-cffi"
116     apt install -y ${PYTHON_PKGS}
117
118     # Memory leakage checks
119     apt install -y valgrind
120
121     # DEB Install Documentation packages
122     echo "---> Installing documentation packages $(date +'%Y%m%dT%H%M%S')"
123     DOC_PKGS="doxygen graphviz python-pyparsing python-jinja2 asciidoc \
124       dblatex source-highlight"
125     apt install -y ${DOC_PKGS}
126
127     # DEB Install the correct version of toolchain packages
128     echo "---> Installing latest toolchain packages from PPA $(date +'%Y%m%dT%H%M%S')"
129
130     #Retry to prevent timeout failure
131     #echo "---> Updating package index $(date +'%Y%m%dT%H%M%S')"
132     #do_retry sudo apt-get update
133     #echo "<--- Updating package index $(date +'%Y%m%dT%H%M%S')"
134     #echo "<--- Adding '$1' PPA $(date +'%Y%m%dT%H%M%S')"
135
136     # DEB Install GCC packages
137     echo "---> Installing GCC-5 packages $(date +'%Y%m%dT%H%M%S')"
138     GCC_PKGS="cpp gcc g++ cmake lcov gcc-multilib"
139     apt install -y ${GCC_PKGS}
140
141     # DEB Install VPP packages to shorten build times
142     echo "---> Installing VPP DEB_DEPENDS packages $(date +'%Y%m%dT%H%M%S')"
143     VPP_PKGS="curl build-essential autoconf automake bison libssl-dev ccache \
144       debhelper dkms git libtool libganglia1-dev libapr1-dev dh-systemd \
145       libconfuse-dev git-review exuberant-ctags cscope indent pkg-config emacs"
146     apt install -y ${VPP_PKGS}
147
148     # DEB Install CSIT packages
149     CSIT_PKGS="libxml2 libxml2-dev libxslt-dev zlib1g-dev bc unzip"
150     apt install -y ${CSIT_PKGS}
151
152     # DEB Install latest kernel and uio
153     echo "---> Installing kernel image and header packages $(date +'%Y%m%dT%H%M%S')"
154     DEB_PKGS="linux-image-extra-virtual linux-headers-virtual linux-headers-`uname -r`"
155     apt install -y ${DEB_PKGS}
156
157     # DEB Install deb_dpdk packages to shorten build times
158     ###REMOVED sphinx-rtd-theme
159     echo "---> Installing deb_dpdk packages $(date +'%Y%m%dT%H%M%S')"
160     DEB_DPDK_PKGS="google-mock lsb-release dpkg-dev debian-xcontrol devscripts \
161       pristine-tar dh-python python-sphinx libpcap0.8-dev libstdc++5 \
162       python-scapy inkscape libxen-dev libxenstore3.0 python-sphinx-rtd-theme"
163     apt install -y ${DEB_DPDK_PKGS}
164
165     sudo apt install -y libcap-dev libpcap-dev
166
167     TEXLIVE_PKGS="texlive-fonts-recommended tex-common texlive-base \
168       texlive-binaries texlive-pictures texlive-latex-recommended \
169       preview-latex-style texlive-latex-extra"
170     apt install -y ${TEXLIVE_PKGS}
171     echo "<--- Installing deb_dpdk packages $(date +'%Y%m%dT%H%M%S')"
172
173     # DEB Manipulation tools, edits debugger, and LSB
174     echo "---> Installing tools packages $(date +'%Y%m%dT%H%M%S')"
175     TOOL_PKGS="iproute2 ethtool vlan bridge-utils vim gdb lsb-release gdbserver"
176     apt install -y ${TOOL_PKGS}
177
178     # DEB Updating CA certificates
179     echo "---> Forcing CA certificate update $(date +'%Y%m%dT%H%M%S')"
180       sudo update-ca-certificates -f > /dev/null 2>&1
181     echo "<--- Forcing CA certificate update $(date +'%Y%m%dT%H%M%S')"
182 }
183
184 all_systems() {
185
186     echo 'Configure keep alive to prevent timeout during testing'
187     local SSH_CFG=/etc/ssh/ssh_config
188     echo "TCPKeepAlive        true" | sudo tee -a ${SSH_CFG} >/dev/null 2>&1
189     echo "ServerAliveCountMax 30"   | sudo tee -a ${SSH_CFG} >/dev/null 2>&1
190     echo "ServerAliveInterval 10"   | sudo tee -a ${SSH_CFG} >/dev/null 2>&1
191
192     # Following installs hashicorp's packer binary which is required  for
193     # ci-management-{verify,merge}-packer jobs
194     mkdir /tmp/packer.io
195     cd /tmp/packer.io
196     wget https://releases.hashicorp.com/packer/0.12.2/packer_0.12.2_linux_amd64.zip
197     unzip packer_0.12.2_linux_amd64.zip -d /usr/local/bin/
198     # note: rename to packer.io to avoid conflict with cracklib packer
199     mv /usr/local/bin/packer /usr/local/bin/packer.io
200
201     # Install packagecloud.io
202     gem install package_cloud
203 }
204
205 echo "---> Detecting OS"
206 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
207
208 case "${ORIGIN}" in
209     fedora|centos|redhat)
210         echo "---> RH type system detected"
211         rh_systems
212     ;;
213     ubuntu)
214         echo "---> Ubuntu system detected"
215         ubuntu_systems
216     ;;
217     *)
218         echo "---> Unknown operating system"
219     ;;
220 esac
221
222 # execute steps for all systems
223 all_systems