blob: 9d095048245084ba775889f89e64852f8d6a9655 [file] [log] [blame]
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -08001#!/bin/bash
2# Ubuntu base build
3
4# vim: ts=4 sw=4 sts=4 et tw=72 :
5
6# force any errors to cause the script and job to end in failure
7set -xeu -o pipefail
8
9rh_systems() {
10 echo 'No changes to apply'
11}
12
Zack Williams85249ce2018-04-01 19:54:44 -070013ubuntu_install_java_setup() {
14
15 echo "debconf shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
16
17 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
18
19 DISTRO=$(lsb_release -cs)
20
21 apt-add-repository \
22 "deb http://ppa.launchpad.net/webupd8team/java/ubuntu $DISTRO main"
23}
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080024
25ubuntu_systems() {
26 apt-get clean
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080027
Zack Williams85249ce2018-04-01 19:54:44 -070028 # get prereqs for PPA and apt-over-HTTPS support
29 apt-get update
30 apt-get install -y apt-transport-https software-properties-common
31
32 # install java (not needed as SonarQube includes this)
33 # ubuntu_install_java_setup
34 # apt-get update
35 # apt-get install -y oracle-java8-installer
Luca Prete31860c52018-03-06 17:54:38 -080036
37 # set up ansible repo
Zack Williams85249ce2018-04-01 19:54:44 -070038 apt-add-repository -y ppa:ansible/ansible
Luca Prete31860c52018-03-06 17:54:38 -080039
40 # set up docker repo
Zack Williams85249ce2018-04-01 19:54:44 -070041 apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
42 add-apt-repository \
Luca Prete31860c52018-03-06 17:54:38 -080043 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
44 $(lsb_release -cs) \
45 stable"
46
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080047 apt-get update
Luca Prete31860c52018-03-06 17:54:38 -080048
49 # install basic sofware requirements
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080050 apt-get install -y \
Zack Williams85249ce2018-04-01 19:54:44 -070051 "docker-ce=17.06*" \
Luca Prete31860c52018-03-06 17:54:38 -080052 ansible \
Luca Prete31860c52018-03-06 17:54:38 -080053 build-essential \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080054 bzip2 \
55 curl \
56 git \
57 less \
Zack Williamscfe0b942018-04-12 11:47:57 -070058 libxml2-utils \
Kailash Khalasi1ddc7c62018-04-20 08:47:56 -070059 maven \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080060 nodejs \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080061 npm \
Zack Williams85249ce2018-04-01 19:54:44 -070062 python \
Zack Williams9754a832018-04-13 11:01:59 -070063 python-certifi \
64 python-cryptography \
Luca Prete31860c52018-03-06 17:54:38 -080065 python-dev \
Zack Williams9754a832018-04-13 11:01:59 -070066 python-idna \
Luca Prete31860c52018-03-06 17:54:38 -080067 python-netaddr \
Zack Williams9754a832018-04-13 11:01:59 -070068 python-openssl \
Luca Prete31860c52018-03-06 17:54:38 -080069 python-pip \
Zack Williams9754a832018-04-13 11:01:59 -070070 python-urllib3 \
Zack Williams40c06f02018-04-15 20:31:34 -070071 ruby \
Zack Williams85249ce2018-04-01 19:54:44 -070072 ssh \
Luca Prete31860c52018-03-06 17:54:38 -080073 sshpass \
Zack Williams85249ce2018-04-01 19:54:44 -070074 zip
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080075 # end of apt-get install list
Luca Prete31860c52018-03-06 17:54:38 -080076
77 # install python modules
Zack Williams85249ce2018-04-01 19:54:44 -070078 pip install \
79 Jinja2 \
80 ansible-lint \
81 astroid \
82 docker-compose==1.20.1 \
83 docker==3.2.1 \
Luca Prete31860c52018-03-06 17:54:38 -080084 gitpython \
Luca Prete90bfa5e2018-03-06 20:41:56 -080085 graphviz \
Zack Williams85249ce2018-04-01 19:54:44 -070086 isort \
Zack Williams6828f822018-04-12 16:13:33 -070087 linkchecker \
Zack Williams85249ce2018-04-01 19:54:44 -070088 pexpect \
89 pylint \
90 pyyaml \
Luca Prete31860c52018-03-06 17:54:38 -080091 robotframework \
Kailash Khalasicb327c62018-04-03 10:41:38 -070092 robotframework-httplibrary \
Zack Williams85249ce2018-04-01 19:54:44 -070093 robotframework-requests \
Zack Williamsfd8a0042018-04-12 14:34:17 -070094 robotframework-sshlibrary \
95 virtualenv
Zack Williams85249ce2018-04-01 19:54:44 -070096 # end of pip install list
Luca Prete31860c52018-03-06 17:54:38 -080097
Zack Williams40c06f02018-04-15 20:31:34 -070098 # install ruby gems
99 gem install \
100 mdl
101 # end of gem install list
102
Luca Prete31860c52018-03-06 17:54:38 -0800103 # install npm modules
104 npm install -g \
Zack Williams85249ce2018-04-01 19:54:44 -0700105 gitbook-cli \
106 markdownlint \
Luca Prete31860c52018-03-06 17:54:38 -0800107 typings
Zack Williams85249ce2018-04-01 19:54:44 -0700108 # end of npm install list
Luca Prete31860c52018-03-06 17:54:38 -0800109
Zack Williams6828f822018-04-12 16:13:33 -0700110 # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks
111 # tools that expect it to be named just `node`. Symlink it to fix
112 ln -s /usr/bin/nodejs /usr/local/bin/node
113
Luca Prete31860c52018-03-06 17:54:38 -0800114 # install repo
Zack Williams85249ce2018-04-01 19:54:44 -0700115 REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda"
Luca Prete31860c52018-03-06 17:54:38 -0800116 curl -o /tmp/repo 'https://gerrit.opencord.org/gitweb?p=repo.git;a=blob_plain;f=repo;hb=refs/heads/stable'
Zack Williams85249ce2018-04-01 19:54:44 -0700117 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
118 mv /tmp/repo /usr/local/bin/repo
119 chmod a+x /usr/local/bin/repo
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800120
Zack Williams85249ce2018-04-01 19:54:44 -0700121 # install sonarqube scanner
122 SONAR_SCANNER_CLI_VERSION="3.1.0.1141"
123 SONAR_SCANNER_CLI_SHA256SUM="efbe7d1a274bbed220846eccc5b36db853a6bab3ee576aebf93ddc604a89ced4"
124 curl -L -o /tmp/sonarscanner.zip https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip
125 echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c -
126 pushd /opt
127 unzip /tmp/sonarscanner.zip
128 mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner
129 popd
130
Zack Williams8aa52822018-04-05 09:22:15 -0700131 # install helm (for lint)
132 HELM_VERSION="2.8.2"
133 HELM_SHA256SUM="614b5ac79de4336b37c9b26d528c6f2b94ee6ccacb94b0f4b8d9583a8dd122d3"
134 HELM_PLATFORM="linux-amd64"
135 curl -L -o /tmp/helm.tgz https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz
136 echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c -
137 pushd /tmp
138 tar -xzvf helm.tgz
139 mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
140 chmod a+x /usr/local/bin/helm
141 popd
142
Zack Williams85249ce2018-04-01 19:54:44 -0700143 # clean up
144 apt-get clean
145 apt-get purge -y
146 apt-get autoremove -y
147 rm -rf /var/lib/apt/lists/*
148 rm -rf /var/cache/oracle-jdk8-installer
149 rm -rf /tmp/sonarscanner.zip
Zack Williams8aa52822018-04-05 09:22:15 -0700150 rm -rf /tmp/helm.tgz
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800151}
Zack Williams85249ce2018-04-01 19:54:44 -0700152
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800153all_systems() {
154 echo 'No common distribution configuration to perform'
155}
156
157echo "---> Detecting OS"
158ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
159
160case "${ORIGIN}" in
161 fedora|centos|redhat)
162 echo "---> RH type system detected"
163 rh_systems
164 ;;
165 ubuntu)
166 echo "---> Ubuntu system detected"
167 ubuntu_systems
168 ;;
169 *)
170 echo "---> Unknown operating system"
171 ;;
172esac
173
174# execute steps for all systems
175all_systems