Commit | Line | Data |
---|---|---|
51c9c62d | 1 | #!/bin/sh |
598af463 MJ |
2 | # |
3 | # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
4 | # 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 | ||
51c9c62d MJ |
19 | set -exu |
20 | ||
9351982a MJ |
21 | # Kernel version compare functions |
22 | verlte() { | |
23 | [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ] | |
24 | } | |
25 | ||
26 | verlt() { | |
27 | [ "$1" = "$2" ] && return 1 || verlte $1 $2 | |
28 | } | |
29 | ||
30 | vergte() { | |
31 | [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ] | |
32 | } | |
33 | ||
34 | vergt() { | |
35 | [ "$1" = "$2" ] && return 1 || vergte $1 $2 | |
36 | } | |
37 | ||
38 | ||
598af463 MJ |
39 | # Use all CPU cores |
40 | NPROC=$(nproc) | |
41 | ||
7e942863 | 42 | SRCDIR="${WORKSPACE}/src/lttng-modules" |
598af463 | 43 | BUILDDIR="${WORKSPACE}/build" |
7e942863 | 44 | LNXSRCDIR="${WORKSPACE}/src/linux" |
598af463 MJ |
45 | LNXBINDIR="${WORKSPACE}/deps/linux/build" |
46 | ||
47 | # Create build directory | |
48 | rm -rf "${BUILDDIR}" | |
49 | mkdir -p "${BUILDDIR}" | |
50 | ||
51 | # Enter source dir | |
52 | cd "${SRCDIR}" | |
53 | ||
9351982a | 54 | # Fix path to linux src in builddir Makefile |
598af463 MJ |
55 | sed -i "s#MAKEARGS := -C .*#MAKEARGS := -C ${LNXSRCDIR}#" "${LNXBINDIR}"/Makefile |
56 | ||
9351982a MJ |
57 | # Get kernel version from source tree |
58 | cd "${LNXBINDIR}" | |
59 | KVERSION=$(make kernelversion) | |
60 | cd - | |
61 | ||
62 | # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the | |
63 | # timekeeping subsystem. We want those build to fail. | |
64 | if { vergte "$KVERSION" "3.10" && verlte "$KVERSION" "3.10.13"; } || \ | |
65 | { vergte "$KVERSION" "3.11" && verlte "$KVERSION" "3.11.2"; }; then | |
66 | ||
67 | set +e | |
68 | ||
69 | # Build modules | |
2c1d386a | 70 | KERNELDIR="${LNXBINDIR}" make -j${NPROC} V=1 CONFIG_LTTNG=m |
9351982a MJ |
71 | |
72 | # We expect this build to fail, if it doesn't, fail the job. | |
73 | if [ "$?" -eq 0 ]; then | |
74 | exit 1 | |
75 | fi | |
76 | ||
77 | # We have to publish at least one file or the build will fail | |
78 | echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${BUILDDIR}/BROKEN.txt" | |
79 | ||
80 | set -e | |
81 | ||
82 | else # Regular build | |
83 | ||
84 | # Build modules | |
2c1d386a | 85 | KERNELDIR="${LNXBINDIR}" make -j${NPROC} V=1 CONFIG_LTTNG=m |
598af463 | 86 | |
9351982a | 87 | # Install modules to build dir |
2c1d386a | 88 | KERNELDIR="${LNXBINDIR}" make INSTALL_MOD_PATH="${BUILDDIR}" modules_install |
9351982a | 89 | fi |
598af463 MJ |
90 | |
91 | # EOF |