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