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
56 make ${koutput} defconfig
61 sed -i "s/CONFIG_CC_STACKPROTECTOR_STRONG=y/# CONFIG_CC_STACKPROTECTOR_STRONG is not set/g" "${outdir}"/.config
63 # Don't try to sign modules
64 sed -i "s/CONFIG_MODULE_SIG=y/# CONFIG_MODULE_SIG is not set/g" "${outdir}"/.config
66 # Enable CONFIG_KALLSYMS_ALL
67 echo "CONFIG_KPROBES=y" >> "${outdir}"/.config
68 echo "CONFIG_FTRACE=y" >> "${outdir}"/.config
69 echo "CONFIG_BLK_DEV_IO_TRACE=y" >> "${outdir}"/.config
70 echo "CONFIG_TRACEPOINTS=y" >> "${outdir}"/.config
71 echo "CONFIG_KALLSYMS_ALL=y" >> "${outdir}"/.config
74 make ${koutput} silentoldconfig
75 make ${koutput} modules_prepare
77 # Version specific tasks
80 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
81 ABINUM
=$
(echo $kversion |
grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')
82 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> ${outdir}/include
/generated
/utsrelease.h
86 # On powerpc this object is required to link modules
87 if [ "${karch}" = "powerpc" ]; then
88 make ${koutput} arch
/powerpc
/lib
/crtsavres.o
99 # Get kernel version from source tree
101 kversion
=$
(make kernelversion
)
103 # Enter lttng-modules source dir
106 # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
107 # timekeeping subsystem. We want those build to fail.
108 if { vergte
"$kversion" "3.10" && verlte
"$kversion" "3.10.13"; } || \
109 { vergte
"$kversion" "3.11" && verlte
"$kversion" "3.11.2"; }; then
114 KERNELDIR
="${kdir}" make -j${NPROC} V
=1
116 # We expect this build to fail, if it doesn't, fail the job.
117 if [ "$?" -eq 0 ]; then
121 # We have to publish at least one file or the build will fail
122 echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${bdir}/BROKEN.txt.ko"
126 KERNELDIR
="${kdir}" make clean
130 # Build modules against full kernel sources
131 KERNELDIR
="${kdir}" make -j${NPROC} V
=1
133 # Install modules to build dir
134 KERNELDIR
="${kdir}" make INSTALL_MOD_PATH
="${bdir}" modules_install
137 KERNELDIR
="${kdir}" make clean
147 LTTSRCDIR
="${WORKSPACE}/src/lttng-modules"
148 LNXSRCDIR
="${WORKSPACE}/src/linux"
150 LNXBUILDDIR
="${WORKSPACE}/build/linux"
151 LNXHDRDIR
="${WORKSPACE}/build/linux-headers"
153 LTTBUILKSRCDDIR
="${WORKSPACE}/build/lttng-modules-ksrc"
154 LTTBUILDKHDRDIR
="${WORKSPACE}/build/lttng-modules-khdr"
157 # Setup cross compile env if available
158 if [ "x${cross_arch:-}" != "x" ]; then
160 case "$cross_arch" in
163 cross_compile
="arm-linux-gnueabihf-"
164 ubuntu_config
="armhf-config.flavour.generic"
169 cross_compile
="aarch64-linux-gnu-"
170 ubuntu_config
="arm64-config.flavour.generic"
175 cross_compile
="powerpc-linux-gnu-"
176 ubuntu_config
="powerpc-config.flavour.powerpc-smp"
181 cross_compile
="powerpc64le-linux-gnu-"
182 ubuntu_config
="ppc64el-config.flavour.generic"
186 echo "Unsupported cross arch $arch"
191 # Export variables used by Kbuild for cross compilation
192 export ARCH
="${karch}"
193 export CROSS_COMPILE
="${cross_compile}"
196 # Set arch specific values if we are not cross compiling
197 elif [ "x${arch:-}" != "x" ]; then
201 ubuntu_config
="i386-config.flavour.generic"
206 ubuntu_config
="amd64-config.flavour.generic"
211 ubuntu_config
="armhf-config.flavour.generic"
216 ubuntu_config
="arm64-config.flavour.generic"
221 ubuntu_config
="powerpc-config.flavour.powerpc-smp"
226 ubuntu_config
="ppc64el-config.flavour.generic"
230 echo "Unsupported arch $arch"
235 echo "Not arch or cross_arch specified"
242 # Create build directories
243 mkdir
-p "${LNXBUILDDIR}" "${LNXHDRDIR}" "${LTTBUILKSRCDDIR}" "${LTTBUILDKHDRDIR}"
247 ## PREPARE DISTRO STYLE KERNEL HEADERS / DEVEL
249 # Enter linux source dir
252 prepare_lnx_sources
"."
254 # For RT kernels, copy version file
255 if [ -s localversion-rt
]; then
256 cp -a localversion-rt
"${LNXHDRDIR}"
259 # Copy all Makefile related stuff
260 find .
-path './include/*' -prune \
261 -o -path './scripts/*' -prune -o -type f \
262 \
( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
263 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \
) \
264 -print |
cpio -pd --preserve-modification-time "${LNXHDRDIR}"
266 # Copy base scripts and include dirs
267 cp -a scripts include
"${LNXHDRDIR}"
270 (find arch
-name include
-type d
-print | \
271 xargs -n1 -i: find : -type f
) | \
272 cpio -pd --preserve-modification-time "${LNXHDRDIR}"
275 (find arch
-name scripts
-type d
-print | \
276 xargs -n1 -i: find : -type f
) | \
277 cpio -pd --preserve-modification-time "${LNXHDRDIR}"
280 rm -f "${LNXHDRDIR}/scripts/*.o"
281 rm -f "${LNXHDRDIR}/scripts/*/*.o"
283 # On powerpc this object is required to link modules
284 if [ "${karch}" = "powerpc" ]; then
285 cp -a --parents arch
/powerpc
/lib
/crtsavres.
[So
] "${LNXHDRDIR}/"
288 # Copy modules related stuff, if available
289 if [ -s Module.symvers
]; then
290 cp Module.symvers
"${LNXHDRDIR}"
293 if [ -s System.map
]; then
294 cp System.map
"${LNXHDRDIR}"
297 if [ -s Module.markers
]; then
298 cp Module.markers
"${LNXHDRDIR}"
302 cp .config
"${LNXHDRDIR}"
304 # Make sure the Makefile and version.h have a matching timestamp so that
305 # external modules can be built
306 if [ -s "${LNXHDRDIR}/include/generated/uapi/linux/version.h" ]; then
307 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/generated/uapi/linux/version.h"
308 elif [ -s "${LNXHDRDIR}/include/linux/version.h" ]; then
309 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/linux/version.h"
311 echo "Missing version.h"
314 touch -r "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/generated/autoconf.h"
316 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
317 cp "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/config/auto.conf"
322 ## PREPARE FULL LINUX SOURCE TREE
324 # Enter linux source dir
327 # Make sure linux source dir is clean
330 prepare_lnx_sources
"${LNXBUILDDIR}"
335 # Build modules against full kernel sources
336 build_modules
"${LNXBUILDDIR}" "${LTTBUILKSRCDDIR}"
338 # Build modules against kernel headers
339 build_modules
"${LNXHDRDIR}" "${LTTBUILDKHDRDIR}"
341 # Make sure modules were built
342 if [ "x$(find "${LTTBUILKSRCDDIR}" -name "*.ko
" -printf yes -quit)" != "xyes" ]; then
343 echo "No modules built!"
347 if [ "x$(find "${LTTBUILDKHDRDIR}" -name "*.ko
" -printf yes -quit)" != "xyes" ]; then
348 echo "No modules built!"
This page took 0.05846 seconds and 4 git commands to generate.