| 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 | export TERM="xterm-256color" |
| 73 | |
| 74 | DEPS_INC="$WORKSPACE/deps/build/include" |
| 75 | DEPS_LIB="$WORKSPACE/deps/build/lib" |
| 76 | DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig" |
| 77 | DEPS_BIN="$WORKSPACE/deps/build/bin" |
| 78 | DEPS_JAVA="$WORKSPACE/deps/build/share/java" |
| 79 | |
| 80 | export PATH="$DEPS_BIN:$PATH" |
| 81 | export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}" |
| 82 | export PKG_CONFIG_PATH="$DEPS_PKGCONFIG" |
| 83 | export CPPFLAGS="-I$DEPS_INC" |
| 84 | export LDFLAGS="-L$DEPS_LIB" |
| 85 | |
| 86 | export JAVA_HOME="/usr/lib/jvm/default-java" |
| 87 | export CLASSPATH="$DEPS_JAVA/*:/usr/share/java/*" |
| 88 | |
| 89 | SRCDIR="$WORKSPACE/src/lttng-tools" |
| 90 | TAPDIR="$WORKSPACE/tap" |
| 91 | PREFIX="$WORKSPACE/out" |
| 92 | |
| 93 | # Create tmp directory |
| 94 | TMPDIR="$WORKSPACE/tmp" |
| 95 | mkdir -p "$TMPDIR" |
| 96 | |
| 97 | # Use a symlink in /tmp to point to the the tmp directory |
| 98 | # inside the workspace, this is to work around the path length |
| 99 | # limit of unix sockets which are created by the test suite. |
| 100 | tmpdir="$(mktemp)" |
| 101 | ln -sf "$TMPDIR" "$tmpdir" |
| 102 | export TMPDIR="$tmpdir" |
| 103 | |
| 104 | # Create a symlink to "babeltrace" when the "babeltrace2" executable is found. |
| 105 | # This is a temporary workaround until lttng-tools either allows the override of |
| 106 | # the trace reader in its test suite or that we move to only supporting |
| 107 | # babeltrace2 |
| 108 | if [ -x "$DEPS_BIN/babeltrace2" ]; then |
| 109 | ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace" |
| 110 | fi |
| 111 | |
| 112 | # When using babeltrace2 make sure that it finds its plugins and |
| 113 | # plugin-providers. |
| 114 | export BABELTRACE_PLUGIN_PATH="$DEPS_LIB/babeltrace2/plugins/" |
| 115 | export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="$DEPS_LIB/babeltrace2/plugin-providers/" |
| 116 | |
| 117 | PYTHON2=python2 |
| 118 | PYTHON3=python3 |
| 119 | |
| 120 | # Set default python to python3 for the bindings |
| 121 | export PYTHON="$PYTHON3" |
| 122 | export PYTHON_CONFIG="/usr/bin/$PYTHON3-config" |
| 123 | |
| 124 | P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])") |
| 125 | P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])") |
| 126 | |
| 127 | UST_PYTHON2="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages" |
| 128 | UST_PYTHON3="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages" |
| 129 | |
| 130 | export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3" |
| 131 | |
| 132 | |
| 133 | |
| 134 | # Create build and tmp directories |
| 135 | rm -rf "$PREFIX" |
| 136 | mkdir -p "$PREFIX" |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | # Enter the source directory |
| 142 | cd "$SRCDIR" |
| 143 | |
| 144 | # Run bootstrap in the source directory prior to configure |
| 145 | ./bootstrap |
| 146 | |
| 147 | # Get source version from configure script |
| 148 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" |
| 149 | |
| 150 | TARBALL_FILE="lttng-tools-$PACKAGE_VERSION.tar.bz2" |
| 151 | |
| 152 | # Make sure the reported version matches the current git tag |
| 153 | GIT_TAG="$(git describe --exact-match --tags $(git log -n1 --pretty='%h')|| echo 'undefined')" |
| 154 | |
| 155 | if [ "v$PACKAGE_VERSION" != "$GIT_TAG" ]; then |
| 156 | echo "Git checkout is not tagged or doesn't match the reported version." |
| 157 | exit 1 |
| 158 | fi |
| 159 | |
| 160 | # Generate release tarball |
| 161 | ./configure |
| 162 | make dist |
| 163 | cp "./$TARBALL_FILE" "$PREFIX/" |
| 164 | |
| 165 | |
| 166 | # Allow core dumps |
| 167 | ulimit -c unlimited |
| 168 | |
| 169 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a |
| 170 | # lttng-sessiond --daemonize on "lttng create" |
| 171 | export LTTNG_SESSIOND_PATH="/bin/true" |
| 172 | |
| 173 | |
| 174 | # Do an in-tree test build |
| 175 | mkdir "$WORKSPACE/intree" |
| 176 | cd "$WORKSPACE/intree" || exit 1 |
| 177 | tar xvf "$PREFIX/$TARBALL_FILE" --strip 1 |
| 178 | ./configure --prefix="$(mktemp -d)" --enable-python-bindings --enable-test-java-agent-all --enable-test-python-agent-all |
| 179 | make -j "$(nproc)" V=1 |
| 180 | make check |
| 181 | make install |
| 182 | make clean |
| 183 | |
| 184 | # do an out-of-tree test build |
| 185 | mkdir "$WORKSPACE/oot" |
| 186 | mkdir "$WORKSPACE/oot/src" |
| 187 | mkdir "$WORKSPACE/oot/build" |
| 188 | cd "$WORKSPACE/oot/src" || exit 1 |
| 189 | tar xvf "$PREFIX/$TARBALL_FILE" --strip 1 |
| 190 | cd "$WORKSPACE/oot/build" || exit 1 |
| 191 | "$WORKSPACE/oot/src/configure" --prefix="$(mktemp -d)" --enable-python-bindings --enable-test-java-agent-all --enable-test-python-agent-all |
| 192 | make -j "$(nproc)" V=1 |
| 193 | make check |
| 194 | make install |
| 195 | make clean |
| 196 | |
| 197 | # EOF |