Install Python3.6 for Ubuntu basebuild 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 # force any errors to cause the script and job to end in failure
6 set -xeu -o pipefail
7
8 rh_systems() {
9     # Install python dependencies
10     yum install -y python-{devel,virtualenv,setuptools,pip}
11
12     # Build dependencies for Python packages
13     yum install -y openssl-devel mysql-devel gcc
14
15     # Autorelease support packages
16     yum install -y firefox python-tox xmlstarlet xvfb
17
18     # Install chrome to support ChromeDriver
19     cat <<EOF > /etc/yum.repos.d/google-chrome.repo
20 [google-chrome]
21 name=google-chrome
22 baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
23 enabled=1
24 gpgcheck=1
25 gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
26 EOF
27
28     yum -y update
29     yum -y install google-chrome-stable
30
31     # Additional libraries for Python ncclient
32     yum install -y libxml2 libxslt libxslt-devel libffi libffi-devel
33
34     # Packer builds happen from the centos flavor images
35     PACKERDIR=$(mktemp -d)
36     # disable double quote checking
37     # shellcheck disable=SC2086
38     cd $PACKERDIR
39     wget https://releases.hashicorp.com/packer/0.12.2/packer_0.12.2_linux_amd64.zip
40     unzip packer_0.12.2_linux_amd64.zip -d /usr/local/bin/
41     # rename packer to avoid conflicts with cracklib
42     mv /usr/local/bin/packer /usr/local/bin/packer.io
43
44     # cleanup from the installation
45     # disable double quote checking
46     # shellcheck disable=SC2086
47     rm -rf $PACKERDIR
48     # cleanup from previous install process
49     if [ -d /tmp/packer ]
50     then
51         rm -rf /tmp/packer
52     fi
53 }
54
55 ubuntu_systems() {
56     # Install python3.6
57     sudo add-apt-repository -y ppa:jonathonf/python-3.6
58     sudo apt-get update
59     sudo apt-get install -y python3.6
60
61     # Install python dependencies
62     apt-get install -y python-{dev,virtualenv,setuptools,pip}
63
64     # Build dependencies for Python packages
65     apt-get install -y libssl-dev libmysqlclient-dev gcc
66
67     # Autorelease support packages
68     apt-get install -y firefox python-tox xmlstarlet xvfb
69
70     # Install chrome to support ChromeDriver
71     wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
72     echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
73     apt-get update -y
74     apt-get install -y google-chrome-stable
75
76     # Additional libraries for Python ncclient
77     apt-get install -y wget unzip python-ncclient
78
79     # Add graphviz for documentation building
80     apt-get install -y graphviz
81
82     # Erlang and Rebar packages needed for DCAEGEN2
83     apt-get install -y libwxgtk3.0-0v5 libsctp1
84     wget https://packages.erlang-solutions.com/erlang/esl-erlang/FLAVOUR_1_general/esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
85     dpkg -i esl-erlang_19.3.6-1~ubuntu~trusty_amd64.deb
86     apt-get install -y libwxbase3.0-0v5
87     apt-get -f install -y
88     git clone https://github.com/erlang/rebar3.git
89     cd rebar3
90     ./bootstrap
91     mv rebar3 /usr/bin/rebar3
92     cd ..
93 }
94
95 all_systems() {
96     echo 'No common distribution configuration to perform'
97 }
98
99 echo "---> Detecting OS"
100 ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
101
102 case "${ORIGIN}" in
103     fedora|centos|redhat)
104         echo "---> RH type system detected"
105         rh_systems
106     ;;
107     ubuntu)
108         echo "---> Ubuntu system detected"
109         ubuntu_systems
110     ;;
111     *)
112         echo "---> Unknown operating system"
113     ;;
114 esac
115
116 # execute steps for all systems
117 all_systems