Refactor: JJB code
[ci-management.git] / jjb / ric-plt-dbaas / setup-dbaas-build-deb.sh
1 #!/bin/bash
2 ##############################################################################
3 #
4 #   Copyright (c) 2020 AT&T Intellectual Property.
5 #   Copyright (c) 2020 Nokia.
6 #   Copyright (c) 2020 HCL Technologies
7 #
8 #   Licensed under the Apache License, Version 2.0 (the "License");
9 #   you may not use this file except in compliance with the License.
10 #   You may obtain a copy of the License at
11 #
12 #       http://www.apache.org/licenses/LICENSE-2.0
13 #
14 #   Unless required by applicable law or agreed to in writing, software
15 #   distributed under the License is distributed on an "AS IS" BASIS,
16 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 #   See the License for the specific language governing permissions and
18 #   limitations under the License.
19 #
20 ##############################################################################
21
22 # Installs prerequisites needed to compile & test SDL code
23 # and build RPM/DEB packages on a Debian/Ubuntu machine.
24
25 echo "--> setup-dbaas-build-deb.sh"
26
27 # Ensure we fail the job if any steps fail.
28 set -eux -o pipefail
29
30 # NOTE: The valgrind false positive problem could also potentially be solved
31 # with valgrind suppression files but that kind of approach may be fragile.
32
33 # install prereqs
34 sudo apt-get update && sudo apt-get -q -y install \
35    automake \
36     autoconf \
37     cmake \
38     curl \
39     g++ \
40     gcc \
41     libtool \
42     make \
43     pkg-config \
44     valgrind \
45     lcov
46
47 # Cpputest built-in memory checks generate false positives in valgrind.
48 # This is solved by compiling cpputest with memory checking disabled.
49
50 mkdir -p cpputest/builddir
51 cd cpputest
52
53 curl -L https://github.com/cpputest/cpputest/releases/download/v3.8/cpputest-3.8.tar.gz | \
54     tar --strip-components=1 -xzf -
55 cd builddir
56 cmake -DMEMORY_LEAK_DETECTION=OFF .. && \
57 sudo make install
58 cd ../..
59 # generate configure script
60 cd redismodule
61 ./autogen.sh && \
62     ./configure && \
63 sudo make test
64
65 # generate configure script with memory checking disabled.
66
67 ./autogen.sh && \
68     ./configure --disable-unit-test-memcheck && \
69 sudo make test
70 cd ..
71
72 #Copy configure to $WORKSPACE
73
74 cp -r cpputest/* .
75
76 echo "--> setup-dbaas-build-deb.sh ends"