Commit | Line | Data |
---|---|---|
f3d8604b MJ |
1 | #!/bin/sh -exu |
2 | # | |
3 | # Copyright (C) 2016 - Michael Jeanson <mjeanson@efficios.com> | |
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation, either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | # Kernel version compare functions | |
19 | verlte() { | |
20 | [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ] | |
21 | } | |
22 | ||
23 | verlt() { | |
24 | [ "$1" = "$2" ] && return 1 || verlte $1 $2 | |
25 | } | |
26 | ||
27 | vergte() { | |
28 | [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ] | |
29 | } | |
30 | ||
31 | vergt() { | |
32 | [ "$1" = "$2" ] && return 1 || vergte $1 $2 | |
33 | } | |
34 | ||
35 | # Use all CPU cores | |
36 | NPROC=$(nproc) | |
37 | ||
38 | SRCDIR="${WORKSPACE}/lttng-modules" | |
39 | BUILDDIR="${WORKSPACE}/build" | |
40 | LNXSRCDIR="${WORKSPACE}/linux" | |
41 | LNXBUILDDIR="${WORKSPACE}/linux-build" | |
42 | ||
43 | # Create build directory | |
44 | mkdir -p "${BUILDDIR}" "${LNXBUILDDIR}" | |
45 | ||
46 | # Enter linux source dir | |
47 | cd "${LNXSRCDIR}" | |
48 | ||
49 | # Prepare linux sources for modules OOT build | |
50 | make O="${LNXBUILDDIR}" defconfig | |
51 | ||
52 | # Enable CONFIG_KALLSYMS_ALL | |
53 | sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" "${LNXBUILDDIR}"/.config | |
54 | ||
55 | # Build to out of tree dir | |
56 | make O="${LNXBUILDDIR}" modules_prepare | |
57 | ||
58 | case "$kversion" in | |
59 | Ubuntu*) | |
60 | #fakeroot debian/rules clean | |
61 | #fakeroot debian/rules genconfigs | |
62 | #cp CONFIGS/amd64-config.flavour.generic .config | |
63 | ||
64 | # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code | |
65 | ABINUM=$(echo $kversion | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)') | |
66 | echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> ${LNXBUILDDIR}/include/generated/utsrelease.h | |
67 | ;; | |
68 | esac | |
69 | ||
70 | # Get kernel version from source tree | |
71 | cd "${LNXBUILDDIR}" | |
72 | KVERSION=$(make kernelversion) | |
73 | ||
74 | # Enter source dir | |
75 | cd "${SRCDIR}" | |
76 | ||
77 | # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the | |
78 | # timekeeping subsystem. We want those build to fail. | |
79 | if { vergte "$KVERSION" "3.10" && verlte "$KVERSION" "3.10.13"; } || \ | |
80 | { vergte "$KVERSION" "3.11" && verlte "$KVERSION" "3.11.2"; }; then | |
81 | ||
82 | set +e | |
83 | ||
84 | # Build modules | |
2c1d386a | 85 | KERNELDIR="${LNXBUILDDIR}" make -j${NPROC} V=1 |
f3d8604b MJ |
86 | |
87 | # We expect this build to fail, if it doesn't, fail the job. | |
88 | if [ "$?" -eq 0 ]; then | |
89 | exit 1 | |
90 | fi | |
91 | ||
92 | # We have to publish at least one file or the build will fail | |
93 | echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${BUILDDIR}/BROKEN.txt" | |
94 | ||
95 | set -e | |
96 | ||
97 | else # Regular build | |
98 | ||
99 | # Build modules | |
2c1d386a | 100 | KERNELDIR="${LNXBUILDDIR}" make -j${NPROC} V=1 |
f3d8604b MJ |
101 | |
102 | # Install modules to build dir | |
2c1d386a | 103 | KERNELDIR="${LNXBUILDDIR}" make INSTALL_MOD_PATH="${BUILDDIR}" modules_install |
f3d8604b MJ |
104 | fi |
105 | ||
106 | # EOF |