Add various packages to Packer images
[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 cloud packages
84     echo "---> Installing cloud packages $(date +'%Y%m%dT%H%M%S')"
85     CLOUD_PKGS="cloud-initramfs-dyn-netconf cloud-initramfs-growroot cloud-initramfs-rescuevol"
86     apt install -y ${CLOUD_PKGS}
87
88     # DEB Install Python dependencies
89     echo "---> Installing Python dependencies $(date +'%Y%m%dT%H%M%S')"
90     PYTHON_PKGS="python-dev python-virtualenv python-setuptools python-pip libssl-dev libmysqlclient-dev python2.7"
91     apt install -y ${PYTHON_PKGS}
92
93     # Memory leakage checks
94     apt install -y valgrind
95
96     # DEB Install Documentation packages
97     echo "---> Installing documentation packages $(date +'%Y%m%dT%H%M%S')"
98     DOC_PKGS="doxygen graphviz python-pyparsing python-jinja2 asciidoc dblatex source-highlight"
99     apt install -y ${DOC_PKGS}
100
101     # DEB Install the correct version of toolchain packages
102     echo "---> Installing latest toolchain packages from PPA $(date +'%Y%m%dT%H%M%S')"
103
104     # DEB Install PPA packages
105     echo "---> Adding '$1' PPA $(date +'%Y%m%dT%H%M%S')"
106     dpkg -l software-properties-common > /dev/null 2>&1 || software-properties-common
107
108     listfile=$(perl -e "print(q{$1} =~ m{^ppa:(.+)/ppa})")-ppa-${CODENAME}.list
109       if [ ! -f /etc/apt/sources.list.d/${listfile} ]
110       then
111         do_retry sudo apt-add-repository -y $1
112       fi
113
114     #Retry to prevent timeout failure
115     echo "---> Updating package index $(date +'%Y%m%dT%H%M%S')"
116     do_retry sudo apt-get update
117     echo "<--- Updating package index $(date +'%Y%m%dT%H%M%S')"
118     echo "<--- Adding '$1' PPA $(date +'%Y%m%dT%H%M%S')"
119
120     # DEB Install GCC packages
121     echo "---> Installing GCC-5 packages $(date +'%Y%m%dT%H%M%S')"
122     GCC_PKGS="cpp gcc g++ cmake lcov gcc-multilib"
123     sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
124     sudo apt-get update
125     apt install -y ${GCC_PKGS}
126
127     # DEB Install VPP packages to shorten build times
128     echo "---> Installing VPP DEB_DEPENDS packages $(date +'%Y%m%dT%H%M%S')"
129     VPP_PKGS="curl build-essential autoconf automake bison libssl-dev ccache \
130     debhelper dkms git libtool libganglia1-dev libapr1-dev dh-systemd \
131     libconfuse-dev git-review exuberant-ctags cscope indent pkg-config emacs"
132     apt install -y ${VPP_PKGS}
133
134     # DEB Install CSIT packages
135     CSIT_PKGS="libxml2 libxml2-dev libxslt-dev zlib1g-dev bc unzip"
136     apt install -y ${CSIT_PKGS}
137     pip install
138
139     # DEB Install latest kernel and uio
140     echo "---> Installing kernel image and header packages $(date +'%Y%m%dT%H%M%S')"
141     DEB_PKGS="linux-image-extra-virtual linux-headers-virtual linux-headers-`uname -r`"
142     apt install -y ${DEB_PKGS}
143
144     #Configuring thirdparty Nexus repo
145     echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/thirdparty ./" > /etc/apt/sources.list.d/FD.io.thirdparty.list
146     apt-get update
147
148     # DEB Install deb_dpdk packages to shorten build times
149     ###REMOVED sphinx-rtd-theme
150     echo "---> Installing deb_dpdk packages $(date +'%Y%m%dT%H%M%S')"
151     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"
152     apt install -y ${DEB_DPDK_PKGS}
153
154     sudo apt install -y libcap-dev libpcap-dev
155
156     TEXLIVE_PKGS="texlive-fonts-recommended tex-common texlive-base texlive-binaries texlive-pictures texlive-latex-recommended preview-latex-style texlive-latex-extra"
157     apt install -y ${TEXLIVE_PKGS}
158     echo "<--- Installing deb_dpdk packages $(date +'%Y%m%dT%H%M%S')"
159
160     # DEB Manipulation tools, edits debugger, and LSB
161     echo "---> Installing tools packages $(date +'%Y%m%dT%H%M%S')"
162     TOOL_PKGS="iproute2 ethtool vlan bridge-utils vim gdb lsb-release gdbserver"
163     apt install -y ${TOOL_PKGS}
164
165     # DEB Clean up packages for a smaller image
166     apt-get update
167
168     # DEB Updating CA certificates
169     echo "---> Forcing CA certificate update $(date +'%Y%m%dT%H%M%S')"
170       sudo update-ca-certificates -f > /dev/null 2>&1
171     echo "<--- Forcing CA certificate update $(date +'%Y%m%dT%H%M%S')"
172 }
173
174 all_systems() {
175
176     echo 'Configure keep alive to prevent timeout during testing'
177     local SSH_CFG=/etc/ssh/ssh_config
178     echo "TCPKeepAlive        true" | sudo tee -a ${SSH_CFG} >/dev/null 2>&1
179     echo "ServerAliveCountMax 30"   | sudo tee -a ${SSH_CFG} >/dev/null 2>&1
180     echo "ServerAliveInterval 10"   | sudo tee -a ${SSH_CFG} >/dev/null 2>&1
181
182 }
183
184 echo "---> Detecting OS"
185 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
186
187 case "${ORIGIN}" in
188     fedora|centos|redhat)
189         echo "---> RH type system detected"
190         rh_systems
191     ;;
192     ubuntu)
193         echo "---> Ubuntu system detected"
194         ubuntu_systems
195     ;;
196     *)
197         echo "---> Unknown operating system"
198     ;;
199 esac
200
201 # execute steps for all systems
202 all_systems