Replace modules and kernel jobs with new design
[lttng-ci.git] / scripts / lttng-modules / param-build.sh
CommitLineData
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
19verlte() {
20 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
21}
22
23verlt() {
24 [ "$1" = "$2" ] && return 1 || verlte $1 $2
25}
26
27vergte() {
28 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
29}
30
31vergt() {
32 [ "$1" = "$2" ] && return 1 || vergte $1 $2
33}
34
35# Use all CPU cores
36NPROC=$(nproc)
37
38SRCDIR="${WORKSPACE}/lttng-modules"
39BUILDDIR="${WORKSPACE}/build"
40LNXSRCDIR="${WORKSPACE}/linux"
41LNXBUILDDIR="${WORKSPACE}/linux-build"
42
43# Create build directory
44mkdir -p "${BUILDDIR}" "${LNXBUILDDIR}"
45
46# Enter linux source dir
47cd "${LNXSRCDIR}"
48
49# Prepare linux sources for modules OOT build
50make O="${LNXBUILDDIR}" defconfig
51
52# Enable CONFIG_KALLSYMS_ALL
53sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" "${LNXBUILDDIR}"/.config
54
55# Build to out of tree dir
56make O="${LNXBUILDDIR}" modules_prepare
57
58case "$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 ;;
68esac
69
70# Get kernel version from source tree
71cd "${LNXBUILDDIR}"
72KVERSION=$(make kernelversion)
73
74# Enter source dir
75cd "${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.
79if { 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
85 make -j${NPROC} -C "${LNXBUILDDIR}" M="$(pwd)" V=1 CONFIG_LTTNG=m
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
97else # Regular build
98
99 # Build modules
100 make -j${NPROC} -C "${LNXBUILDDIR}" M="$(pwd)" V=1 CONFIG_LTTNG=m
101
102 # Install modules to build dir
103 make INSTALL_MOD_PATH="${BUILDDIR}" -C "${LNXBUILDDIR}" M="$(pwd)" modules_install
104fi
105
106# EOF
This page took 0.02574 seconds and 4 git commands to generate.