jjb: Use the https protocol for checkouts on Github, it's faster
[lttng-ci.git] / scripts / lttng-tools / release.sh
CommitLineData
c95cf818
MJ
1#!/bin/bash -exu
2#
3# Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4# Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19# Version compare functions
20vercomp () {
21 set +u
22 if [[ "$1" == "$2" ]]; then
23 return 0
24 fi
25 local IFS=.
26 local i ver1=($1) ver2=($2)
27 # fill empty fields in ver1 with zeros
28 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
29 ver1[i]=0
30 done
31 for ((i=0; i<${#ver1[@]}; i++)); do
32 if [[ -z ${ver2[i]} ]]; then
33 # fill empty fields in ver2 with zeros
34 ver2[i]=0
35 fi
36 if ((10#${ver1[i]} > 10#${ver2[i]})); then
37 return 1
38 fi
39 if ((10#${ver1[i]} < 10#${ver2[i]})); then
40 return 2
41 fi
42 done
43 set -u
44 return 0
45}
46
47verlte() {
48 vercomp "$1" "$2"; local res="$?"
49 [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
50}
51
52verlt() {
53 vercomp "$1" "$2"; local res="$?"
54 [ "$res" -eq "2" ]
55}
56
57vergte() {
58 vercomp "$1" "$2"; local res="$?"
59 [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
60}
61
62vergt() {
63 vercomp "$1" "$2"; local res="$?"
64 [ "$res" -eq "1" ]
65}
66
67verne() {
68 vercomp "$1" "$2"; local res="$?"
69 [ "$res" -ne "0" ]
70}
71
72export TERM="xterm-256color"
73
a7f915c4
MJ
74# Required variables
75WORKSPACE=${WORKSPACE:-}
76
c95cf818
MJ
77DEPS_INC="$WORKSPACE/deps/build/include"
78DEPS_LIB="$WORKSPACE/deps/build/lib"
79DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig"
80DEPS_BIN="$WORKSPACE/deps/build/bin"
81DEPS_JAVA="$WORKSPACE/deps/build/share/java"
82
83export PATH="$DEPS_BIN:$PATH"
84export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
85export PKG_CONFIG_PATH="$DEPS_PKGCONFIG"
86export CPPFLAGS="-I$DEPS_INC"
87export LDFLAGS="-L$DEPS_LIB"
88
89export JAVA_HOME="/usr/lib/jvm/default-java"
90export CLASSPATH="$DEPS_JAVA/*:/usr/share/java/*"
91
92SRCDIR="$WORKSPACE/src/lttng-tools"
a7f915c4 93OUTDIR="$WORKSPACE/out"
c95cf818 94TAPDIR="$WORKSPACE/tap"
a7f915c4
MJ
95
96failed_tests=0
c95cf818
MJ
97
98# Create tmp directory
99TMPDIR="$WORKSPACE/tmp"
100mkdir -p "$TMPDIR"
101
102# Use a symlink in /tmp to point to the the tmp directory
103# inside the workspace, this is to work around the path length
104# limit of unix sockets which are created by the test suite.
105tmpdir="$(mktemp)"
106ln -sf "$TMPDIR" "$tmpdir"
107export TMPDIR="$tmpdir"
108
109# Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
110# This is a temporary workaround until lttng-tools either allows the override of
111# the trace reader in its test suite or that we move to only supporting
112# babeltrace2
113if [ -x "$DEPS_BIN/babeltrace2" ]; then
114 ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
115fi
116
117# When using babeltrace2 make sure that it finds its plugins and
118# plugin-providers.
119export BABELTRACE_PLUGIN_PATH="$DEPS_LIB/babeltrace2/plugins/"
120export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="$DEPS_LIB/babeltrace2/plugin-providers/"
121
122PYTHON2=python2
123PYTHON3=python3
124
125# Set default python to python3 for the bindings
126export PYTHON="$PYTHON3"
127export PYTHON_CONFIG="/usr/bin/$PYTHON3-config"
128
129P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])")
130P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])")
131
132UST_PYTHON2="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages"
133UST_PYTHON3="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages"
134
135export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3"
136
137
138
139# Create build and tmp directories
a7f915c4
MJ
140rm -rf "$OUTDIR" "$TAPDIR"
141mkdir -p "$OUTDIR" "$TAPDIR"
c95cf818
MJ
142
143
144
145
146# Enter the source directory
147cd "$SRCDIR"
148
149# Run bootstrap in the source directory prior to configure
150./bootstrap
151
152# Get source version from configure script
153eval "$(grep '^PACKAGE_VERSION=' ./configure)"
a7f915c4
MJ
154PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/}
155
156CONF_OPTS=("--enable-python-bindings" "--enable-test-java-agent-all" "--enable-test-python-agent-all")
c95cf818
MJ
157
158TARBALL_FILE="lttng-tools-$PACKAGE_VERSION.tar.bz2"
159
160# Make sure the reported version matches the current git tag
a7f915c4 161GIT_TAG="$(git describe --exact-match --tags "$(git log -n1 --pretty='%h')" || echo 'undefined')"
c95cf818
MJ
162
163if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then
164 echo "Git checkout is not tagged or doesn't match the reported version."
165 exit 1
166fi
167
168# Generate release tarball
169./configure
170make dist
a7f915c4 171cp "./$TARBALL_FILE" "$OUTDIR/"
c95cf818
MJ
172
173
174# Allow core dumps
175ulimit -c unlimited
176
177# Force the lttng-sessiond path to /bin/true to prevent the spawing of a
178# lttng-sessiond --daemonize on "lttng create"
179export LTTNG_SESSIOND_PATH="/bin/true"
180
181
a7f915c4 182## Do an in-tree test build
c95cf818
MJ
183mkdir "$WORKSPACE/intree"
184cd "$WORKSPACE/intree" || exit 1
a7f915c4
MJ
185
186tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1
187./configure --prefix="$(mktemp -d)" "${CONF_OPTS[@]}"
188
189# BUILD!
c95cf818 190make -j "$(nproc)" V=1
a7f915c4 191
c95cf818 192make install
a7f915c4
MJ
193
194# Run tests, don't fail now, we want to run the archiving steps
195make --keep-going check || failed_tests=1
196
197# Copy tap logs for the jenkins tap parser before cleaning the build dir
198rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/intree"
199
200# Clean the build directory
c95cf818
MJ
201make clean
202
a7f915c4
MJ
203
204## Do an out-of-tree test build
c95cf818
MJ
205mkdir "$WORKSPACE/oot"
206mkdir "$WORKSPACE/oot/src"
207mkdir "$WORKSPACE/oot/build"
208cd "$WORKSPACE/oot/src" || exit 1
a7f915c4
MJ
209
210tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1
c95cf818 211cd "$WORKSPACE/oot/build" || exit 1
a7f915c4
MJ
212"$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" "${CONF_OPTS[@]}"
213
214# BUILD!
c95cf818 215make -j "$(nproc)" V=1
a7f915c4 216
c95cf818 217make install
a7f915c4
MJ
218
219# Run tests, don't fail now, we want to run the archiving steps
220make --keep-going check || failed_tests=1
221
222# Copy tap logs for the jenkins tap parser before cleaning the build dir
223rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/oot"
224
225# Clean the build directory
c95cf818
MJ
226make clean
227
a7f915c4
MJ
228
229# Exit with failure if any of the tests failed
230exit $failed_tests
231
c95cf818 232# EOF
This page took 0.050882 seconds and 4 git commands to generate.