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
43 # Get kernel version from source tree
45 kversion
=$
(make kernelversion
)
47 # Enter lttng-modules source dir
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
58 KERNELDIR
="${kdir}" make -j${NPROC} V
=1
60 # We expect this build to fail, if it doesn't, fail the job.
61 if [ "$?" -eq 0 ]; then
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"
72 # Build modules against full kernel sources
73 KERNELDIR
="${kdir}" make -j${NPROC} V
=1
75 # Install modules to build dir
76 KERNELDIR
="${kdir}" make INSTALL_MOD_PATH
="${bdir}" modules_install
79 KERNELDIR
="${kdir}" make clean
89 LTTSRCDIR
="${WORKSPACE}/src/lttng-modules"
90 LNXSRCDIR
="${WORKSPACE}/src/linux"
92 LNXBUILDDIR
="${WORKSPACE}/build/linux"
93 LNXHDRDIR
="${WORKSPACE}/build/linux-headers"
95 LTTBUILKSRCDDIR
="${WORKSPACE}/build/lttng-modules-ksrc"
96 LTTBUILDKHDRDIR
="${WORKSPACE}/build/lttng-modules-khdr"
99 # Set arch specific values
126 echo "Unsupported arch $arch"
132 # Create build directories
133 mkdir
-p "${LNXBUILDDIR}" "${LNXHDRDIR}"
136 ## PREPARE DISTRO STYLE KERNEL HEADERS / DEVEL
138 # Enter linux source dir
141 # Prepare linux sources for headers install
144 # Enable CONFIG_KALLSYMS_ALL
145 sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" .config
149 # first copy everything
150 cp --parents `find -type f -name "Makefile*" -o -name "Kconfig*"` "${LNXHDRDIR}"
152 if [ -s Module.symvers
]; then
153 cp Module.symvers
"${LNXHDRDIR}"
156 if [ -s System.map
]; then
157 cp System.map
"${LNXHDRDIR}"
160 if [ -s Module.markers
]; then
161 cp Module.markers
"${LNXHDRDIR}"
164 # then drop all but the needed Makefiles/Kconfig files
165 rm -rf "${LNXHDRDIR}/Documentation"
166 rm -rf "${LNXHDRDIR}/scripts"
167 rm -rf "${LNXHDRDIR}/include"
169 cp .config
"${LNXHDRDIR}"
170 cp -a scripts
"${LNXHDRDIR}"
172 if [ -d arch
/${karch}/scripts
]; then
173 cp -a arch
/${karch}/scripts "${LNXHDRDIR}/arch/${karch}/" || :
176 if [ -f arch/${karch}/*lds ]; then
177 cp -a arch/${karch}/*lds "${LNXHDRDIR}/arch/${karch}/" ||
:
180 rm -f "${LNXHDRDIR}/scripts/*.o"
181 rm -f "${LNXHDRDIR}/scripts/*/*.o"
183 if [ "${karch}" = "powerpc" ]; then
184 cp -a --parents arch
/powerpc
/lib
/crtsavres.
[So
] "${LNXHDRDIR}/"
187 if [ -d arch
/${karch}/include
]; then
188 cp -a --parents arch
/${karch}/include
"${LNXHDRDIR}/"
191 cp -a include
"${LNXHDRDIR}/include"
193 # Make sure the Makefile and version.h have a matching timestamp so that
194 # external modules can be built
195 if [ -s "${LNXHDRDIR}/include/generated/uapi/linux/version.h" ]; then
196 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/generated/uapi/linux/version.h"
197 elif [ -s "${LNXHDRDIR}/include/linux/version.h" ]; then
198 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/linux/version.h"
200 echo "Missing version.h"
203 touch -r "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/generated/autoconf.h"
205 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
206 cp "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/config/auto.conf"
211 ## PREPARE FULL LINUX SOURCE TREE
213 # Enter linux source dir
216 # Make sure linux source dir is clean
219 # Prepare linux sources for modules OOT build
220 make O
="${LNXBUILDDIR}" defconfig
222 # Enable CONFIG_KALLSYMS_ALL
223 sed -i "s/# CONFIG_KALLSYMS_ALL is not set/CONFIG_KALLSYMS_ALL=y/g" "${LNXBUILDDIR}"/.config
225 # Prepare out of tree dir for modules build
226 make O
="${LNXBUILDDIR}" modules_prepare
228 # Version specific tasks
231 #fakeroot debian/rules clean
232 #fakeroot debian/rules genconfigs
233 #cp CONFIGS/amd64-config.flavour.generic .config
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
241 # Build modules against full kernel sources
242 build_modules
"${LNXBUILDDIR}" "${LTTBUILKSRCDDIR}"
244 # Build modules against kernel headers
245 build_modules
"${LNXHDRDIR}" "${LTTBUILDKHDRDIR}"
This page took 0.034857 seconds and 5 git commands to generate.