blob: bf3038dd8cd90406d82cb1c90180424c8c3ae7fc [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
Zack Williams4cfdf202018-05-07 09:58:12 -070036 # rm -rf /var/cache/oracle-jdk8-installer
Luca Prete31860c52018-03-06 17:54:38 -080037
38 # set up ansible repo
Zack Williams85249ce2018-04-01 19:54:44 -070039 apt-add-repository -y ppa:ansible/ansible
Luca Prete31860c52018-03-06 17:54:38 -080040
41 # set up docker repo
Zack Williams85249ce2018-04-01 19:54:44 -070042 apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
43 add-apt-repository \
Luca Prete31860c52018-03-06 17:54:38 -080044 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
45 $(lsb_release -cs) \
46 stable"
47
Zack Williams6ecb83c2018-08-29 13:22:21 -070048 # set up golang repo
49 add-apt-repository ppa:gophers/archive
50
Zack Williams7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ugfba43nqhkbNpJ47YXsIa+YL6eEE9emSmQt
67jrSWIiY+2YJYwsDgsgckF3duqkb02OdBQlh6IbHPoXB6H//b1PgZYsomB+841XW1LSJPYlYb
68IrWfwDfQvtkFQI90r6NknVTQlpqQh5GLNWNYqRNrGQPmsB+NrUYrkl1nUt1LRGu+rCe4bSaS
69mNbwKMQKkROE4kTiB72DPk7zH4Lm0uo0YFFWG4qsMIuqEihJ/9KNX8GYBr+tWgyLooLlsdK3
70l+4dVqd8cjkJM1ExABEBAAG0QEdvb2dsZSBDbG91ZCBQYWNrYWdlcyBBdXRvbWF0aWMgU2ln
71bmluZyBLZXkgPGdjLXRlYW1AZ29vZ2xlLmNvbT6JAT4EEwECACgFAlrBaNsCGy8FCQWjmoAG
72CwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEGoDCyG6B/T78e8H/1WH2LN/nVNhm5TS1VYJ
73G8B+IW8zS4BqyozxC9iJAJqZIVHXl8g8a/Hus8RfXR7cnYHcg8sjSaJfQhqO9RbKnffiuQgG
74rqwQxuC2jBa6M/QKzejTeP0Mgi67pyrLJNWrFI71RhritQZmzTZ2PoWxfv6b+Tv5v0rPaG+u
75t1J47pn+kYgtUaKdsJz1umi6HzK6AacDf0C0CksJdKG7MOWsZcB4xeOxJYuy6NuO6KcdEz8/
76XyEUjIuIOlhYTd0hH8E/SEBbXXft7/VBQC5wNq40izPi+6WFK/e1O42DIpzQ749ogYQ1eode
77xPNhLzekKR3XhGrNXJ95r5KO10VrsLFNd8KwAgAD
78EOF
79
80 sudo apt-key add /tmp/k8s-apt-key.gpg
81 echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
82
83 # update after adding apt repos to sources
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080084 apt-get update
Luca Prete31860c52018-03-06 17:54:38 -080085
86 # install basic sofware requirements
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080087 apt-get install -y \
Zack Williams85249ce2018-04-01 19:54:44 -070088 "docker-ce=17.06*" \
Andy Bavierb781c4c2018-09-20 08:16:52 -070089 apt-transport-https \
Luca Prete31860c52018-03-06 17:54:38 -080090 ansible \
Luca Prete31860c52018-03-06 17:54:38 -080091 build-essential \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080092 bzip2 \
93 curl \
Andy Bavierb781c4c2018-09-20 08:16:52 -070094 ebtables \
95 ethtool \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080096 git \
Zack Williams6ecb83c2018-08-29 13:22:21 -070097 golang-1.10-go \
Kailash Khalasi4b42e6c2018-10-18 13:43:52 -070098 httpie \
Andy Bavierb781c4c2018-09-20 08:16:52 -070099 jq \
Kailash3be4df02019-02-05 12:43:00 -0800100 kafkacat \
Andy Bavierb781c4c2018-09-20 08:16:52 -0700101 "kubeadm=1.12.4-*" \
102 "kubelet=1.12.4-*" \
103 "kubectl=1.12.4-*" \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800104 less \
Zack Williams9d661a42018-10-01 15:43:21 -0700105 libmysqlclient-dev \
Zack Williams68f43102018-07-07 12:57:13 -0700106 libpcap-dev \
Zack Williamscfe0b942018-04-12 11:47:57 -0700107 libxml2-utils \
Kailash Khalasi1ddc7c62018-04-20 08:47:56 -0700108 maven \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800109 nodejs \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800110 npm \
Zack Williams85249ce2018-04-01 19:54:44 -0700111 python \
Zack Williams9754a832018-04-13 11:01:59 -0700112 python-certifi \
113 python-cryptography \
Luca Prete31860c52018-03-06 17:54:38 -0800114 python-dev \
Zack Williams9754a832018-04-13 11:01:59 -0700115 python-idna \
Luca Prete31860c52018-03-06 17:54:38 -0800116 python-netaddr \
Zack Williams9754a832018-04-13 11:01:59 -0700117 python-openssl \
Luca Prete31860c52018-03-06 17:54:38 -0800118 python-pip \
Zack Williams9754a832018-04-13 11:01:59 -0700119 python-urllib3 \
Zack Williams40c06f02018-04-15 20:31:34 -0700120 ruby \
Zack Williamseb842ae2018-05-15 17:07:32 -0700121 socat \
Zack Williams85249ce2018-04-01 19:54:44 -0700122 ssh \
Luca Prete31860c52018-03-06 17:54:38 -0800123 sshpass \
Zack Williams85249ce2018-04-01 19:54:44 -0700124 zip
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800125 # end of apt-get install list
Luca Prete31860c52018-03-06 17:54:38 -0800126
127 # install python modules
Zack Williams85249ce2018-04-01 19:54:44 -0700128 pip install \
129 Jinja2 \
130 ansible-lint \
Zack Williamsac922962018-07-24 13:02:26 -0700131 astroid==1.* \
Zack Williams958bc4e2018-10-18 21:08:25 -0700132 coverage \
Zack Williams85249ce2018-04-01 19:54:44 -0700133 docker-compose==1.20.1 \
134 docker==3.2.1 \
Luca Prete31860c52018-03-06 17:54:38 -0800135 gitpython \
Luca Prete90bfa5e2018-03-06 20:41:56 -0800136 graphviz \
Kailash Khalasie15b27a2018-06-26 13:28:20 -0700137 grpcio-tools \
Zack Williams85249ce2018-04-01 19:54:44 -0700138 isort \
Zack Williams6828f822018-04-12 16:13:33 -0700139 linkchecker \
Zack Williams958bc4e2018-10-18 21:08:25 -0700140 mock \
141 nose2 \
Zack Williams85249ce2018-04-01 19:54:44 -0700142 pexpect \
Zack Williamse9af4c42018-07-24 14:29:02 -0700143 pylint==1.* \
Zack Williams85249ce2018-04-01 19:54:44 -0700144 pyyaml \
Luca Prete31860c52018-03-06 17:54:38 -0800145 robotframework \
Kailash Khalasicb327c62018-04-03 10:41:38 -0700146 robotframework-httplibrary \
Kailash Khalasia1917682018-08-20 10:34:39 -0700147 robotframework-kafkalibrary \
Zack Williams85249ce2018-04-01 19:54:44 -0700148 robotframework-requests \
Zack Williamsfd8a0042018-04-12 14:34:17 -0700149 robotframework-sshlibrary \
Zack Williamsa31016a2018-10-22 13:00:04 -0700150 tox \
Zack Williams5aa37e12019-02-13 13:28:29 -0700151 twine \
Zack Williamsfd8a0042018-04-12 14:34:17 -0700152 virtualenv
Zack Williams85249ce2018-04-01 19:54:44 -0700153 # end of pip install list
Luca Prete31860c52018-03-06 17:54:38 -0800154
Zack Williams40c06f02018-04-15 20:31:34 -0700155 # install ruby gems
156 gem install \
157 mdl
158 # end of gem install list
159
Luca Prete31860c52018-03-06 17:54:38 -0800160 # install npm modules
161 npm install -g \
Zack Williams85249ce2018-04-01 19:54:44 -0700162 gitbook-cli \
163 markdownlint \
Luca Prete31860c52018-03-06 17:54:38 -0800164 typings
Zack Williams85249ce2018-04-01 19:54:44 -0700165 # end of npm install list
Luca Prete31860c52018-03-06 17:54:38 -0800166
Zack Williams6ecb83c2018-08-29 13:22:21 -0700167 # install golang packages in /usr/local/go
168 # Set PATH=$PATH:/usr/local/go/bin` to use these
169 export GOPATH=/usr/local/go
170 mkdir -p $GOPATH
171 export PATH=$PATH:/usr/lib/go-1.10/bin:$GOPATH/bin
172 # converters for unit/coverage test
173 go get -v github.com/t-yuki/gocover-cobertura
174 go get -v github.com/jstemmer/go-junit-report
175
Zack Williams142ba6b2018-11-20 15:23:39 -0700176 # dep for go package dependencies w/versioning, version v0.5.0, adapted from:
177 # https://golang.github.io/dep/docs/installation.html#install-from-source
178 go get -d -u github.com/golang/dep
179 pushd $(go env GOPATH)/src/github.com/golang/dep
180 git checkout "v0.5.0"
181 go install -ldflags="-X main.version=v0.5.0" ./cmd/dep
182 popd
183
Zack Williams6828f822018-04-12 16:13:33 -0700184 # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks
185 # tools that expect it to be named just `node`. Symlink it to fix
186 ln -s /usr/bin/nodejs /usr/local/bin/node
187
Luca Prete31860c52018-03-06 17:54:38 -0800188 # install repo
Zack Williams85249ce2018-04-01 19:54:44 -0700189 REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda"
Luca Prete31860c52018-03-06 17:54:38 -0800190 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 -0700191 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
192 mv /tmp/repo /usr/local/bin/repo
193 chmod a+x /usr/local/bin/repo
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800194
Zack Williams85249ce2018-04-01 19:54:44 -0700195 # install sonarqube scanner
Zack Williams891922a2018-07-07 10:33:24 -0700196 # dl link: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
197 SONAR_SCANNER_CLI_VERSION="3.2.0.1227"
198 SONAR_SCANNER_CLI_SHA256SUM="07a50ec270a36cb83f26fe93233819c53c145248c638f4591880f1bd36e331d6"
Zack Williams02e301e2018-10-08 12:09:58 -0700199 curl -L -o /tmp/sonarscanner.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip"
Zack Williams85249ce2018-04-01 19:54:44 -0700200 echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c -
201 pushd /opt
202 unzip /tmp/sonarscanner.zip
203 mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner
Zack Williams4cfdf202018-05-07 09:58:12 -0700204 rm -f /tmp/sonarscanner.zip
Zack Williams85249ce2018-04-01 19:54:44 -0700205 popd
206
Zack Williams4cfdf202018-05-07 09:58:12 -0700207 # install helm
Zack Williams7722ef22018-10-16 14:08:29 -0700208 HELM_VERSION="2.11.0"
209 HELM_SHA256SUM="02a4751586d6a80f6848b58e7f6bd6c973ffffadc52b4c06652db7def02773a1"
Zack Williams8aa52822018-04-05 09:22:15 -0700210 HELM_PLATFORM="linux-amd64"
Zack Williams4cfdf202018-05-07 09:58:12 -0700211 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
Zack Williams8aa52822018-04-05 09:22:15 -0700212 echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c -
213 pushd /tmp
214 tar -xzvf helm.tgz
215 mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
216 chmod a+x /usr/local/bin/helm
Zack Williams4cfdf202018-05-07 09:58:12 -0700217 rm -rf helm.tgz ${HELM_PLATFORM}
218 popd
219
220 # install minikube
Zack Williams7722ef22018-10-16 14:08:29 -0700221 MINIKUBE_VERSION="0.30.0"
Zack Williams4cfdf202018-05-07 09:58:12 -0700222 MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')"
Zack Williams7722ef22018-10-16 14:08:29 -0700223 MINIKUBE_SHA256SUM="c6c5aa5956f8ad5f61d426e9b8601ba95965a9c30bb80a9fe7525c64e6dd12fd"
Zack Williams4cfdf202018-05-07 09:58:12 -0700224 curl -L -o /tmp/minikube.deb "https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube_${MINIKUBE_DEB_VERSION}.deb"
225 echo "$MINIKUBE_SHA256SUM /tmp/minikube.deb" | sha256sum -c -
226 pushd /tmp
227 dpkg -i minikube.deb
228 rm -f minikube.deb
Zack Williams8aa52822018-04-05 09:22:15 -0700229 popd
230
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700231 # install protobufs
Zack Williamscab43ba2018-09-19 09:58:25 -0700232 PROTOC_VERSION="3.6.1"
233 PROTOC_SHA256SUM="6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807"
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700234 curl -L -o /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
235 echo "$PROTOC_SHA256SUM /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip" | sha256sum -c -
Kailash Khalasic4ff32d2018-06-28 18:24:52 -0700236 unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700237 mv /tmp/protoc3/bin/* /usr/local/bin/
238 mv /tmp/protoc3/include/* /usr/local/include/
Zack Williams3fc47ab2018-10-08 11:22:29 -0700239 # fix permissions on include files
240 chmod -R a+r /usr/local/include/
Zack Williamscab43ba2018-09-19 09:58:25 -0700241
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700242 # give sudo permissions on minikube and protoc to jenkins user
243 cat <<EOF >/etc/sudoers.d/88-jenkins-minikube-protoc
244Cmnd_Alias CMDS = /usr/local/bin/protoc, /usr/bin/minikube
Zack Williams81739772018-05-14 16:35:47 -0700245Defaults:jenkins !requiretty
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700246jenkins ALL=(ALL) NOPASSWD:SETENV: CMDS
Zack Williams81739772018-05-14 16:35:47 -0700247EOF
248
Andy Bavierb781c4c2018-09-20 08:16:52 -0700249 # remove apparmor
250 service apparmor stop
251 update-rc.d -f apparmor remove
252 apt-get remove apparmor-utils libapparmor-perl apparmor
253 update-grub
254
Zack Williams85249ce2018-04-01 19:54:44 -0700255 # clean up
256 apt-get clean
257 apt-get purge -y
258 apt-get autoremove -y
259 rm -rf /var/lib/apt/lists/*
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800260}
Zack Williams85249ce2018-04-01 19:54:44 -0700261
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800262all_systems() {
263 echo 'No common distribution configuration to perform'
264}
265
266echo "---> Detecting OS"
267ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
268
269case "${ORIGIN}" in
270 fedora|centos|redhat)
271 echo "---> RH type system detected"
272 rh_systems
273 ;;
274 ubuntu)
275 echo "---> Ubuntu system detected"
276 ubuntu_systems
277 ;;
278 *)
279 echo "---> Unknown operating system"
280 ;;
281esac
282
283# execute steps for all systems
284all_systems