2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2018-2019 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
24 # Set build tools versions base on the:
25 # https://github.com/apache/geode-native/blob/develop/docker/Dockerfile
27 GEODE_VERSION="1.10.0"
29 CMAKE_VERSION="3.12.2"
31 # Additional repositories and build 3PPs
32 CLANG_SLES_REPO="https://download.opensuse.org/repositories/devel:/languages:/swift/SLE_15/"
33 GAMES_SLES_REPO="https://download.opensuse.org/repositories/games/SLE_15_SP1/"
34 GEODE_LOCATION="https://www.apache.org/dyn/closer.cgi?action=download&filename=geode/${GEODE_VERSION}/apache-geode-${GEODE_VERSION}.tgz"
35 RAT_LOCATION="https://www.apache.org/dyn/closer.cgi?action=download&filename=creadur/apache-rat-${RAT_VERSION}/apache-rat-${RAT_VERSION}-bin.tar.gz"
36 CMAKE_LOCATION="https://cmake.org/files/v${CMAKE_VERSION%.*}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh"
38 install_dev_packages() {
39 # Add Swift repository with clang6 compiler.
40 if ! zypper lr -n | egrep Swift-Programming-Language > /dev/null ; then
41 sudo zypper addrepo ${CLANG_SLES_REPO} "Swift-Programming-Language(SLES_15)"
43 # Add Games repository with libjsoncpp library.
44 if ! zypper lr -n | egrep Games > /dev/null ; then
45 sudo zypper addrepo ${GAMES_SLES_REPO} "Games(SLE_15_SP1)"
48 echo "Info: Upgrade SLES and install all available patches"
49 echo "-------------------------------------------------------------"
50 sudo zypper --gpg-auto-import-keys refresh ; sudo zypper update -y
51 sudo zypper -q patches
53 echo "Info: Install clang development environment"
54 echo "-------------------------------------------------------------"
55 sudo zypper install -y \
60 clang${CLANG_VERSION:0:1} \
61 clang${CLANG_VERSION:0:1}-checker \
62 clang${CLANG_VERSION:0:1}-devel \
69 java-1_8_0-openjdk-devel \
72 if [[ ! -L /etc/alternatives/clang ]] ; then
73 sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_VERSION} 999
75 if [[ ! -L /etc/alternatives/clang++ ]] ; then
76 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_VERSION} 999
78 if [[ ! -L /etc/alternatives/clang-tidy ]] ; then
79 sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${CLANG_VERSION} 999
81 if [[ ! -L /etc/alternatives/cc ]] ; then
82 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${CLANG_VERSION} 999
84 if [[ ! -L /etc/alternatives/cc++ ]] ; then
85 sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${CLANG_VERSION} 999
89 configure_geode_build() {
90 echo "Info: Install 3PPs required to build geode-native"
91 echo "-------------------------------------------------------------"
92 # The Geode is required on build server to compile geode-native
93 if [[ ! -d /opt/apache-geode-${GEODE_VERSION} ]] ; then
94 wget ${GEODE_LOCATION} -O - | sudo tar xzvf - -C /opt
96 echo "The Geode ${GEODE_VERSION} already installed."
98 echo "-------------------------------------------------------------"
100 # The Rat (Apache Release Audit Tool) is required to compile geode-native
101 if [[ ! -d /opt/apache-rat-${RAT_VERSION} ]] ; then
102 wget ${RAT_LOCATION} -O - | sudo tar xzvf - -C /opt
104 echo "The Apache RAT ${RAT_VERSION} already installed."
106 echo "-------------------------------------------------------------"
108 # cmake is required to generate a build system for geode-native
109 if [[ ! -f /usr/local/bin/cmake ]] ; then
110 wget ${CMAKE_LOCATION} -O /tmp/cmake
111 sudo bash /tmp/cmake --skip-license --prefix=/usr/local
113 elif ! /usr/local/bin/cmake -version | grep -q ${CMAKE_VERSION} ; then
114 echo "ERROR: Incorrect cmake version installed"
117 echo "The CMAKE ${CMAKE_VERSION} already installed."
120 # Export 3PPs location for geode-native build
121 export JAVA_HOME="/usr/lib64/jvm/java-openjdk"
122 export GEODE_HOME="/opt/apache-geode-${GEODE_VERSION}"
123 export RAT_HOME="/opt/apache-rat-${RAT_VERSION}"
124 export PATH="$PATH:$GEODE_HOME/bin"
126 # Update hosts file with ip6-localhost required by geode-native Integration tests
127 sudo sed -i '/ipv6-loopback$/s/$/ ip6-localhost/' /etc/hosts
130 get_geode_build_docker_image() {
131 echo "Info: Start and enable docker on system"
132 echo "-------------------------------------------------------------"
133 sudo systemctl enable docker
134 sudo systemctl start docker
135 echo "Info: Remove all previous stopped docker containers and images"
136 echo "-------------------------------------------------------------"
137 sudo docker container prune -f
138 sudo docker image prune -f
139 echo "Info: Get the latest geode-native build docker image"
140 echo "-------------------------------------------------------------"
141 docker pull ${GEODE_NATIVE_DOCKER_IMAGE:-apachegeode/geode-native-build}
144 # Make sure the build server is SLES15 based
145 source /etc/os-release
148 if [[ "${VERSION}" != "15" ]] ; then
149 echo "ERROR: Incorrect version on SLES on the build server: ${VERSION}"
153 configure_geode_build
154 get_geode_build_docker_image
158 DPKG_LOCK="/var/lib/dpkg/lock-frontend"
159 # Wait for other apt process to finish by checking the dpkg lock file.
161 while sudo lsof ${DPKG_LOCK} > /dev/null 2>&1 ; do
162 echo "DPKG file locked: ${DPKG_LOCK}."
163 echo " Waiting for another pkg installation process to finish ..."
165 if [[ ${try} -gt 60 ]] ; then
166 echo "ERROR: Max number of re-tries reached, exiting..."
171 get_geode_build_docker_image
174 echo "ERROR: Only SLES15 and Ubuntu OS can be use as a build server geode-native"