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