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