Use preconf setting for maven and enable global local
[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
339db64d
MJ
18## FUNCTIONS ##
19
f3d8604b
MJ
20# Kernel version compare functions
21verlte() {
22 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
23}
24
25verlt() {
26 [ "$1" = "$2" ] && return 1 || verlte $1 $2
27}
28
29vergte() {
30 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
31}
32
33vergt() {
34 [ "$1" = "$2" ] && return 1 || vergte $1 $2
35}
36
339db64d
MJ
37
38build_modules() {
39
40 kdir="$1"
41 bdir="$2"
42
43 # Get kernel version from source tree
44 cd "${kdir}"
45 kversion=$(make kernelversion)
46
47 # Enter lttng-modules source dir
48 cd "${LTTSRCDIR}"
49
50 # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
51 # timekeeping subsystem. We want those build to fail.
52 if { vergte "$kversion" "3.10" && verlte "$kversion" "3.10.13"; } || \
53 { vergte "$kversion" "3.11" && verlte "$kversion" "3.11.2"; }; then
54
55 set +e
56
57 # Build modules
58 KERNELDIR="${kdir}" make -j${NPROC} V=1
59
60 # We expect this build to fail, if it doesn't, fail the job.
61 if [ "$?" -eq 0 ]; then
62 exit 1
63 fi
64
65 # We have to publish at least one file or the build will fail
66 echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${bdir}/BROKEN.txt"
67
68 set -e
69
70 else # Regular build
71
72 # Build modules against full kernel sources
73 KERNELDIR="${kdir}" make -j${NPROC} V=1
74
75 # Install modules to build dir
76 KERNELDIR="${kdir}" make INSTALL_MOD_PATH="${bdir}" modules_install
77
78 # Clean build dir
79 KERNELDIR="${kdir}" make clean
80 fi
81}
82
83
84## MAIN ##
85
f3d8604b
MJ
86# Use all CPU cores
87NPROC=$(nproc)
88
339db64d
MJ
89LTTSRCDIR="${WORKSPACE}/src/lttng-modules"
90LNXSRCDIR="${WORKSPACE}/src/linux"
91
92LNXBUILDDIR="${WORKSPACE}/build/linux"
93LNXHDRDIR="${WORKSPACE}/build/linux-headers"
94
95LTTBUILKSRCDDIR="${WORKSPACE}/build/lttng-modules-ksrc"
96LTTBUILDKHDRDIR="${WORKSPACE}/build/lttng-modules-khdr"
97
98
99# Set arch specific values
100case "$arch" in
101 "x86-32")
102 karch="x86"
103 ;;
104
105 "x86-64")
106 karch="x86"
107 ;;
108
109 "armhf")
110 karch="arm"
111 ;;
112
113 "arm64")
114 karch="arm64"
115 ;;
116
117 "powerpc")
118 karch="powerpc"
119 ;;
120
121 "ppc64|ppc64el")
122 karch="powerpc"
123 ;;
124
125 *)
126 echo "Unsupported arch $arch"
127 exit 1
128 ;;
129esac
130
131
132# Create build directories
133mkdir -p "${LNXBUILDDIR}" "${LNXHDRDIR}"
134
135
136## PREPARE DISTRO STYLE KERNEL HEADERS / DEVEL
137
138# Enter linux source dir
139cd "${LNXSRCDIR}"
140
141# Prepare linux sources for headers install
142make defconfig
f3d8604b 143
339db64d
MJ
144# Enable CONFIG_KALLSYMS_ALL
145sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" .config
146
147make modules_prepare
148
149# first copy everything
150cp --parents `find -type f -name "Makefile*" -o -name "Kconfig*"` "${LNXHDRDIR}"
151
152if [ -s Module.symvers ]; then
153 cp Module.symvers "${LNXHDRDIR}"
154fi
155
156if [ -s System.map ]; then
157 cp System.map "${LNXHDRDIR}"
158fi
159
160if [ -s Module.markers ]; then
161 cp Module.markers "${LNXHDRDIR}"
162fi
163
164# then drop all but the needed Makefiles/Kconfig files
165rm -rf "${LNXHDRDIR}/Documentation"
166rm -rf "${LNXHDRDIR}/scripts"
167rm -rf "${LNXHDRDIR}/include"
168
169cp .config "${LNXHDRDIR}"
170cp -a scripts "${LNXHDRDIR}"
171
172if [ -d arch/${karch}/scripts ]; then
173 cp -a arch/${karch}/scripts "${LNXHDRDIR}/arch/${karch}/" || :
174fi
175
176if [ -f arch/${karch}/*lds ]; then
177 cp -a arch/${karch}/*lds "${LNXHDRDIR}/arch/${karch}/" || :
178fi
179
180rm -f "${LNXHDRDIR}/scripts/*.o"
181rm -f "${LNXHDRDIR}/scripts/*/*.o"
182
183if [ "${karch}" = "powerpc" ]; then
184 cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LNXHDRDIR}/"
185fi
186
187if [ -d arch/${karch}/include ]; then
188 cp -a --parents arch/${karch}/include "${LNXHDRDIR}/"
189fi
190
191cp -a include "${LNXHDRDIR}/include"
192
193# Make sure the Makefile and version.h have a matching timestamp so that
194# external modules can be built
195if [ -s "${LNXHDRDIR}/include/generated/uapi/linux/version.h" ]; then
196 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/generated/uapi/linux/version.h"
197elif [ -s "${LNXHDRDIR}/include/linux/version.h" ]; then
198 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/linux/version.h"
199else
200 echo "Missing version.h"
201 exit 1
202fi
203touch -r "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/generated/autoconf.h"
204
205# Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
206cp "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/config/auto.conf"
207
208
209
210
211## PREPARE FULL LINUX SOURCE TREE
f3d8604b
MJ
212
213# Enter linux source dir
214cd "${LNXSRCDIR}"
215
339db64d
MJ
216# Make sure linux source dir is clean
217make mrproper
218
f3d8604b
MJ
219# Prepare linux sources for modules OOT build
220make O="${LNXBUILDDIR}" defconfig
221
222# Enable CONFIG_KALLSYMS_ALL
223sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" "${LNXBUILDDIR}"/.config
224
339db64d 225# Prepare out of tree dir for modules build
f3d8604b
MJ
226make O="${LNXBUILDDIR}" modules_prepare
227
339db64d 228# Version specific tasks
f3d8604b
MJ
229case "$kversion" in
230 Ubuntu*)
231 #fakeroot debian/rules clean
232 #fakeroot debian/rules genconfigs
233 #cp CONFIGS/amd64-config.flavour.generic .config
234
235 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
236 ABINUM=$(echo $kversion | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')
237 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> ${LNXBUILDDIR}/include/generated/utsrelease.h
238 ;;
239esac
240
339db64d
MJ
241# Build modules against full kernel sources
242build_modules "${LNXBUILDDIR}" "${LTTBUILKSRCDDIR}"
f3d8604b 243
339db64d
MJ
244# Build modules against kernel headers
245build_modules "${LNXHDRDIR}" "${LTTBUILDKHDRDIR}"
f3d8604b
MJ
246
247# EOF
This page took 0.036948 seconds and 4 git commands to generate.