Commit | Line | Data |
---|---|---|
8abe9f8a 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 | |
20 | vercomp () { | |
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 | ||
47 | verlte() { | |
48 | vercomp "$1" "$2"; local res="$?" | |
49 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
50 | } | |
51 | ||
52 | verlt() { | |
53 | vercomp "$1" "$2"; local res="$?" | |
54 | [ "$res" -eq "2" ] | |
55 | } | |
56 | ||
57 | vergte() { | |
58 | vercomp "$1" "$2"; local res="$?" | |
59 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
60 | } | |
61 | ||
62 | vergt() { | |
63 | vercomp "$1" "$2"; local res="$?" | |
64 | [ "$res" -eq "1" ] | |
65 | } | |
66 | ||
67 | verne() { | |
68 | vercomp "$1" "$2"; local res="$?" | |
69 | [ "$res" -ne "0" ] | |
70 | } | |
71 | ||
72 | # Required variables | |
73 | WORKSPACE=${WORKSPACE:-} | |
74 | ||
75 | ||
76 | SRCDIR="$WORKSPACE/src/babeltrace" | |
77 | TMPDIR="$WORKSPACE/tmp" | |
78 | OUTDIR="$WORKSPACE/out" | |
79 | TAPDIR="$WORKSPACE/tap" | |
80 | ||
81 | failed_tests=0 | |
82 | ||
83 | # Create build and tmp directories | |
84 | rm -rf "$OUTDIR" "$TMPDIR" "$TAPDIR" | |
85 | mkdir -p "$OUTDIR" "$TMPDIR" "$TAPDIR" | |
86 | ||
87 | export TMPDIR | |
88 | ||
89 | ||
90 | # Enter the source directory | |
91 | cd "$SRCDIR" | |
92 | ||
93 | # Run bootstrap in the source directory prior to configure | |
94 | ./bootstrap | |
95 | ||
96 | # Get source version from configure script | |
97 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" | |
98 | PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/} | |
99 | ||
100 | # Version specific configurations | |
101 | if vergte "$PACKAGE_VERSION" "2.0"; then | |
102 | BASENAME="babeltrace2" | |
103 | CONF_OPTS=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins") | |
104 | ||
105 | # Enable dev mode by default for BT 2.0 builds | |
106 | #export BABELTRACE_DEBUG_MODE=1 | |
107 | #export BABELTRACE_DEV_MODE=1 | |
108 | #export BABELTRACE_MINIMAL_LOG_LEVEL=TRACE | |
109 | else | |
110 | BASENAME="babeltrace" | |
111 | CONF_OPTS=("--enable-python-bindings") | |
112 | fi | |
113 | ||
114 | ||
115 | TARBALL_FILE="$BASENAME-$PACKAGE_VERSION.tar.bz2" | |
116 | ||
117 | ||
118 | # Make sure the reported version matches the current git tag | |
63ffe145 | 119 | GIT_TAG="$(git describe --exact-match --tags "$(git log -n1 --pretty='%h')" || echo 'undefined')" |
8abe9f8a MJ |
120 | |
121 | if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then | |
122 | echo "Git checkout is not tagged or doesn't match the reported version." | |
123 | exit 1 | |
124 | fi | |
125 | ||
126 | # Generate release tarball | |
63ffe145 | 127 | ./configure |
8abe9f8a MJ |
128 | make dist |
129 | cp "./$TARBALL_FILE" "$OUTDIR/" | |
130 | ||
131 | ## Do an in-tree test build | |
132 | mkdir "$WORKSPACE/intree" | |
133 | cd "$WORKSPACE/intree" || exit 1 | |
134 | ||
135 | tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1 | |
136 | ./configure --prefix="$(mktemp -d)" "${CONF_OPTS[@]}" | |
137 | ||
138 | # BUILD! | |
139 | make -j "$(nproc)" V=1 | |
140 | ||
141 | make install | |
142 | ||
143 | # Run tests, don't fail now, we want to run the archiving steps | |
144 | make --keep-going check || failed_tests=1 | |
145 | ||
146 | # Copy tap logs for the jenkins tap parser before cleaning the build dir | |
147 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/intree" | |
148 | ||
149 | # Clean the build directory | |
150 | make clean | |
151 | ||
152 | ||
153 | ## Do an out-of-tree test build | |
154 | mkdir "$WORKSPACE/oot" | |
155 | mkdir "$WORKSPACE/oot/src" | |
156 | mkdir "$WORKSPACE/oot/build" | |
157 | cd "$WORKSPACE/oot/src" || exit 1 | |
158 | ||
159 | tar xvf "$OUTDIR/$TARBALL_FILE" --strip 1 | |
160 | cd "$WORKSPACE/oot/build" || exit 1 | |
161 | "$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" "${CONF_OPTS[@]}" | |
162 | ||
163 | # BUILD! | |
164 | make -j "$(nproc)" V=1 | |
165 | ||
166 | make install | |
167 | ||
168 | # Run tests, don't fail now, we want to run the archiving steps | |
169 | make --keep-going check || failed_tests=1 | |
170 | ||
171 | # Copy tap logs for the jenkins tap parser before cleaning the build dir | |
172 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR/oot" | |
173 | ||
174 | # Clean the build directory | |
175 | make clean | |
176 | ||
177 | ||
178 | # Exit with failure if any of the tests failed | |
179 | exit $failed_tests | |
180 | ||
181 | # EOF |