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
113 cross_compile
="arm-linux-gnueabihf-"
118 cross_compile
="aarch64-linux-gnu-"
123 cross_compile
="powerpc-linux-gnu-"
128 cross_compile
="powerpc64le-linux-gnu-"
132 echo "Unsupported arch $arch"
137 # Setup cross compile env if required
138 if [ "${cross_build:-}" = "true" ]; then
139 export ARCH
="${karch}"
140 export CROSS_COMPILE
="${cross_compile}"
144 # Create build directories
145 mkdir
-p "${LNXBUILDDIR}" "${LNXHDRDIR}"
148 ## PREPARE DISTRO STYLE KERNEL HEADERS / DEVEL
150 # Enter linux source dir
153 # Prepare linux sources for headers install
155 sed -i "s/CONFIG_MODULE_SIG=y/# CONFIG_MODULE_SIG is not set/g" .config
159 # Version specific tasks
162 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
163 ABINUM
=$
(echo $kversion |
grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')
164 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> include
/generated
/utsrelease.h
168 # For RT kernels, copy version file
169 if [ -s localversion-rt
]; then
170 cp -a localversion-rt
"${LNXHDRDIR}"
173 # Copy all Makefile related stuff
174 find .
-path './include/*' -prune \
175 -o -path './scripts/*' -prune -o -type f \
176 \
( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
177 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \
) \
178 -print |
cpio -pd --preserve-modification-time "${LNXHDRDIR}"
180 # Copy base scripts and include dirs
181 cp -a scripts include
"${LNXHDRDIR}"
184 (find arch
-name include
-type d
-print | \
185 xargs -n1 -i: find : -type f
) | \
186 cpio -pd --preserve-modification-time "${LNXHDRDIR}"
189 (find arch
-name scripts
-type d
-print | \
190 xargs -n1 -i: find : -type f
) | \
191 cpio -pd --preserve-modification-time "${LNXHDRDIR}"
194 rm -f "${LNXHDRDIR}/scripts/*.o"
195 rm -f "${LNXHDRDIR}/scripts/*/*.o"
197 # On powerpc this object is required to link modules
198 if [ "${karch}" = "powerpc" ]; then
199 make arch
/powerpc
/lib
/crtsavres.o
200 cp -a --parents arch
/powerpc
/lib
/crtsavres.
[So
] "${LNXHDRDIR}/"
203 # Copy modules related stuff, if available
204 if [ -s Module.symvers
]; then
205 cp Module.symvers
"${LNXHDRDIR}"
208 if [ -s System.map
]; then
209 cp System.map
"${LNXHDRDIR}"
212 if [ -s Module.markers
]; then
213 cp Module.markers
"${LNXHDRDIR}"
217 cp .config
"${LNXHDRDIR}"
219 # Make sure the Makefile and version.h have a matching timestamp so that
220 # external modules can be built
221 if [ -s "${LNXHDRDIR}/include/generated/uapi/linux/version.h" ]; then
222 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/generated/uapi/linux/version.h"
223 elif [ -s "${LNXHDRDIR}/include/linux/version.h" ]; then
224 touch -r "${LNXHDRDIR}/Makefile" "${LNXHDRDIR}/include/linux/version.h"
226 echo "Missing version.h"
229 touch -r "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/generated/autoconf.h"
231 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
232 cp "${LNXHDRDIR}/.config" "${LNXHDRDIR}/include/config/auto.conf"
237 ## PREPARE FULL LINUX SOURCE TREE
239 # Enter linux source dir
242 # Make sure linux source dir is clean
245 # Prepare linux sources for modules OOT build
246 make O
="${LNXBUILDDIR}" allyesconfig
247 sed -i "s/CONFIG_MODULE_SIG=y/# CONFIG_MODULE_SIG is not set/g" "${LNXBUILDDIR}"/.config
248 make O
="${LNXBUILDDIR}" silentoldconfig
249 make O
="${LNXBUILDDIR}" modules_prepare
251 # On powerpc this object is required to link modules
252 if [ "${karch}" = "powerpc" ]; then
253 make O
="${LNXBUILDDIR}" arch
/powerpc
/lib
/crtsavres.o
256 # Version specific tasks
259 #fakeroot debian/rules clean
260 #fakeroot debian/rules genconfigs
261 #cp CONFIGS/amd64-config.flavour.generic .config
263 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
264 ABINUM
=$
(echo $kversion |
grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')
265 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> ${LNXBUILDDIR}/include
/generated
/utsrelease.h
269 # Build modules against full kernel sources
270 build_modules
"${LNXBUILDDIR}" "${LTTBUILKSRCDDIR}"
272 # Build modules against kernel headers
273 build_modules
"${LNXHDRDIR}" "${LTTBUILDKHDRDIR}"
275 # Make sure modules were built
276 find "${LNXBUILDDIR}" -name "*.ko"
277 find "${LNXHDRDIR}" -name "*.ko"
This page took 0.052123 seconds and 4 git commands to generate.