1798b9f505afa752bd54d9a73e5a1ab4ffd172b1
3 # Copyright (C) 2016 - Michael Jeanson <mjeanson@efficios.com>
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.
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.
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/>.
20 # Kernel version compare functions
22 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
26 [ "$1" = "$2" ] && return 1 || verlte
$1 $2
30 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
34 [ "$1" = "$2" ] && return 1 || vergte
$1 $2
38 prepare_lnx_sources
() {
42 if [ "$outdir" = "." ]; then
45 koutput
="O=\"${outdir}\""
48 # Generate kernel configuration
51 fakeroot debian
/rules clean
52 fakeroot debian
/rules genconfigs
53 cp CONFIGS
/${ubuntu_config} "${outdir}"/.config
57 make ${koutput} ${vanilla_config} CC
=$CC
62 sed -i "s/CONFIG_CC_STACKPROTECTOR_STRONG=y/# CONFIG_CC_STACKPROTECTOR_STRONG is not set/g" "${outdir}"/.config
64 # Don't try to sign modules
65 sed -i "s/CONFIG_MODULE_SIG=y/# CONFIG_MODULE_SIG is not set/g" "${outdir}"/.config
67 # Disable kernel stack frame correctness validation, introduced in 4.6.0 and currently fails
68 sed -i "s/CONFIG_STACK_VALIDATION=y/# CONFIG_STACK_VALIDATION is not set/g" "${outdir}"/.config
70 # Enable CONFIG_KALLSYMS_ALL
71 echo "CONFIG_KPROBES=y" >> "${outdir}"/.config
72 echo "CONFIG_FTRACE=y" >> "${outdir}"/.config
73 echo "CONFIG_BLK_DEV_IO_TRACE=y" >> "${outdir}"/.config
74 echo "CONFIG_TRACEPOINTS=y" >> "${outdir}"/.config
75 echo "CONFIG_KALLSYMS_ALL=y" >> "${outdir}"/.config
78 make ${koutput} $oldconf_target CC
=$CC
79 make ${koutput} modules_prepare CC
=$CC
81 # Version specific tasks
84 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
85 ABINUM
=$
(echo $kversion |
grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')
86 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> ${outdir}/include
/generated
/utsrelease.h
90 # On powerpc this object is required to link modules
91 if [ "${karch}" = "powerpc" ]; then
92 make ${koutput} arch
/powerpc
/lib
/crtsavres.o CC
=$CC
103 # Get kernel version from source tree
105 kversion
=$
(make kernelversion
)
107 # Enter lttng-modules source dir
110 # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
111 # timekeeping subsystem. We want those build to fail.
112 if { vergte
"$kversion" "3.10" && verlte
"$kversion" "3.10.13"; } || \
113 { vergte
"$kversion" "3.11" && verlte
"$kversion" "3.11.2"; }; then
118 KERNELDIR
="${kdir}" make -j${NPROC} V
=1 CC
=$CC
120 # We expect this build to fail, if it doesn't, fail the job.
121 if [ "$?" -eq 0 ]; then
122 echo "This build should have failed."
126 # We have to publish at least one file or the build will fail
127 echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${bdir}/BROKEN.txt.ko"
131 KERNELDIR
="${kdir}" make clean CC
=$CC
135 # Build modules against full kernel sources
136 KERNELDIR
="${kdir}" make -j${NPROC} V
=1 CC
=$CC
138 # Install modules to build dir
139 KERNELDIR
="${kdir}" make INSTALL_MOD_PATH
="${bdir}" modules_install CC
=$CC
142 KERNELDIR
="${kdir}" make clean CC
=$CC
152 LTTSRCDIR
="${WORKSPACE}/src/lttng-modules"
153 LNXSRCDIR
="${WORKSPACE}/src/linux"
155 LNXBUILDDIR
="${WORKSPACE}/build/linux"
156 LNXHDRDIR
="${WORKSPACE}/build/linux-headers"
158 LTTBUILDKSRCDIR
="${WORKSPACE}/build/lttng-modules-ksrc"
159 LTTBUILDKHDRDIR
="${WORKSPACE}/build/lttng-modules-khdr"
162 # Setup cross compile env if available
163 if [ "x${cross_arch:-}" != "x" ]; then
165 case "$cross_arch" in
168 cross_compile
="arm-linux-gnueabihf-"
169 vanilla_config
="allyesconfig"
170 ubuntu_config
="armhf-config.flavour.generic"
175 cross_compile
="aarch64-linux-gnu-"
176 vanilla_config
="allyesconfig"
177 ubuntu_config
="arm64-config.flavour.generic"
182 cross_compile
="powerpc-linux-gnu-"
183 vanilla_config
="ppc44x_defconfig"
184 ubuntu_config
="powerpc-config.flavour.powerpc-smp"
189 cross_compile
="powerpc64le-linux-gnu-"
190 vanilla_config
="pseries_le_defconfig"
191 ubuntu_config
="ppc64el-config.flavour.generic"
195 echo "Unsupported cross arch $arch"
200 # Use default gcc when cross-compiling
201 CC
="${cross_compile}gcc"
203 # Export variables used by Kbuild for cross compilation
204 export ARCH
="${karch}"
205 export CROSS_COMPILE
="${cross_compile}"
207 oldconf_target
="olddefconfig"
209 # Set arch specific values if we are not cross compiling
210 elif [ "x${arch:-}" != "x" ]; then
215 vanilla_config
="allyesconfig"
216 ubuntu_config
="i386-config.flavour.generic"
221 vanilla_config
="allyesconfig"
222 ubuntu_config
="amd64-config.flavour.generic"
227 vanilla_config
="allyesconfig"
228 ubuntu_config
="armhf-config.flavour.generic"
233 vanilla_config
="allyesconfig"
234 ubuntu_config
="arm64-config.flavour.generic"
239 vanilla_config
="allyesconfig"
240 ubuntu_config
="powerpc-config.flavour.powerpc-smp"
245 vanilla_config
="allyesconfig"
246 ubuntu_config
="ppc64el-config.flavour.generic"
250 echo "Unsupported arch $arch"
255 # Use gcc 4.9, older kernel don't build with gcc 5
258 oldconf_target
="silentoldconfig"
261 echo "Not arch or cross_arch specified"
268 # Create build directories
269 mkdir
-p "${LNXBUILDDIR}" "${LNXHDRDIR}" "${LTTBUILDKSRCDIR}" "${LTTBUILDKHDRDIR}"
273 ## PREPARE DISTRO STYLE KERNEL HEADERS / DEVEL
275 # Enter linux source dir
278 prepare_lnx_sources
"."
280 # For RT kernels, copy version file
281 if [ -s localversion-rt
]; then
282 cp -a localversion-rt
"${LNXHDRDIR}"
285 # Copy all Makefile related stuff
286 find .
-path './include/*' -prune \
287 -o -path './scripts/*' -prune -o -type f \
288 \
( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
289 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \
) \
290 -print |
cpio -pd --preserve-modification-time "${LNXHDRDIR}"
292 # Copy base scripts and include dirs
293 cp -a scripts include
"${LNXHDRDIR}"
296 (find arch
-name include
-type d
-print | \
297 xargs -n1 -i: find : -type f
) | \
298 cpio -pd --preserve-modification-time "${LNXHDRDIR}"
301 (find arch
-name scripts
-type d
-print | \
302 xargs -n1 -i: find : -type f
) | \
303 cpio -pd --preserve-modification-time "${LNXHDRDIR}"
306 rm -f "${LNXHDRDIR}/scripts/*.o"
307 rm -f "${LNXHDRDIR}/scripts/*/*.o"
309 # On powerpc this object is required to link modules
310 if [ "${karch}" = "powerpc" ]; then
311 cp -a --parents arch
/powerpc
/lib
/crtsavres.
[So
] "${LNXHDRDIR}/"
314 # Copy modules related stuff, if available
315 if [ -s Module.symvers
]; then
316 cp Module.symvers
"${LNXHDRDIR}"
319 if [ -s System.map
]; then
320 cp System.map
"${LNXHDRDIR}"
323 if [ -s Module.markers
]; then
324 cp Module.markers
"${LNXHDRDIR}"
328 cp .config
"${LNXHDRDIR}"
330 # Make sure the Makefile and version.h have a matching timestamp so that
331 # external modules can be built
332 if [ -s "${LNXHDRDIR}/include/generated/uapi/linux/version.h" ]; then
333 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/generated/uapi/linux/version.h"
334 elif [ -s "${LNXHDRDIR}/include/linux/version.h" ]; then
335 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/linux/version.h"
337 echo "Missing version.h"
340 touch -r "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/generated/autoconf.h"
342 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
343 cp "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/config/auto.conf"
348 ## PREPARE FULL LINUX SOURCE TREE
350 # Enter linux source dir
353 # Make sure linux source dir is clean
356 prepare_lnx_sources
"${LNXBUILDDIR}"
361 # Build modules against full kernel sources
362 build_modules
"${LNXBUILDDIR}" "${LTTBUILDKSRCDIR}"
364 # Build modules against kernel headers
365 build_modules
"${LNXHDRDIR}" "${LTTBUILDKHDRDIR}"
367 # Make sure modules were built
368 tree
"${LTTBUILDKSRCDIR}"
369 if [ "x$(find "${LTTBUILDKSRCDIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
370 echo "No modules built!"
374 tree
"${LTTBUILDKHDRDIR}"
375 if [ "x$(find "${LTTBUILDKHDRDIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
376 echo "No modules built!"
This page took 0.036581 seconds and 4 git commands to generate.