blob: 8eb6b80ca316462926e2d3d0fb0e956aece6588d [file] [log] [blame]
Matthias Maennich6652d742019-02-01 22:20:44 +00001#!/bin/bash
2
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Usage:
18# build/build.sh <make options>*
19# or:
20# OUT_DIR=<out dir> DIST_DIR=<dist dir> build/build.sh <make options>*
21#
22# Example:
23# OUT_DIR=output DIST_DIR=dist build/build.sh -j24
24#
25#
26# The following environment variables are considered during execution:
27#
28# BUILD_CONFIG
29# Build config file to initialize the build environment from. The location
30# is to be defined relative to the repo root directory.
31# Defaults to 'build.config'.
32#
33# OUT_DIR
34# Base output directory for the kernel build.
35# Defaults to <REPO_ROOT>/out/<BRANCH>.
36#
37# DIST_DIR
38# Base output directory for the kernel distribution.
39# Defaults to <OUT_DIR>/dist
40#
41# EXT_MODULES
42# Space separated list of external kernel modules to be build.
43#
44# UNSTRIPPED_MODULES
45# Space separated list of modules to be copied to <DIST_DIR>/unstripped
46# for debugging purposes.
47#
48# CC
Matthias Maennich0646c8d2019-03-20 11:03:51 +000049# Override compiler to be used. (e.g. CC=clang) Specifying CC=gcc
50# effectively unsets CC to fall back to the default gcc detected by kbuild
51# (including any target triplet). To use a custom 'gcc' from PATH, use an
52# absolute path, e.g. CC=/usr/local/bin/gcc
Matthias Maennich6652d742019-02-01 22:20:44 +000053#
54# LD
55# Override linker (flags) to be used.
56#
Matthias Maennich44509b02019-05-28 12:26:58 +010057# ABI_DEFINITION
58# Location of the abi definition file relative to <REPO_ROOT>/KERNEL_DIR
59# If defined (usually in build.config), also copy that abi definition to
Matthias Maennichd46fd322019-05-29 09:05:38 +010060# <OUT_DIR>/dist/abi.xml when creating the distribution.
Matthias Maennich44509b02019-05-28 12:26:58 +010061#
Matthias Maennich6652d742019-02-01 22:20:44 +000062# Environment variables to influence the stages of the kernel build.
63#
64# SKIP_MRPROPER
65# if defined, skip `make mrproper`
66#
67# SKIP_DEFCONFIG
68# if defined, skip `make defconfig`
69#
Matthias Maenniche4edd6f2019-02-13 12:36:27 +000070# PRE_DEFCONFIG_CMDS
71# Command evaluated before `make defconfig`
72#
Matthias Maennich6652d742019-02-01 22:20:44 +000073# POST_DEFCONFIG_CMDS
74# Command evaluated after `make defconfig` and before `make`.
75#
Matthias Maenniche4edd6f2019-02-13 12:36:27 +000076# POST_KERNEL_BUILD_CMDS
77# Command evaluated after `make`.
78#
Matthias Maennich6652d742019-02-01 22:20:44 +000079# IN_KERNEL_MODULES
80# if defined, install kernel modules
81#
82# SKIP_EXT_MODULES
83# if defined, skip building and installing of external modules
84#
85# EXTRA_CMDS
86# Command evaluated after building and installing kernel and modules.
87#
88# SKIP_CP_KERNEL_HDR
89# if defined, skip installing kernel headers.
90#
Hridya Valsarajue46a9372019-05-13 16:38:14 -070091# BUILD_BOOT_IMG
92# if defined, build a boot.img binary that can be flashed into the 'boot'
93# partition of an Android device. The boot image contains a header as per the
94# format defined by https://source.android.com/devices/bootloader/boot-image-header
95# followed by several components like kernel, ramdisk, DTB etc. The ramdisk
96# component comprises of a GKI ramdisk cpio archive concatenated with a
97# vendor ramdisk cpio archive which is then gzipped. It is expected that
98# all components are present in ${DIST_DIR}.
99#
100# When the BUILD_BOOT_IMG flag is defined, the following flags that point to the
101# various components needed to build a boot.img also need to be defined.
102# - MKBOOTIMG_PATH=<path to the mkbootimg.py script which builds boot.img>
103# - GKI_RAMDISK_PREBUILT_BINARY=<Name of the GKI ramdisk prebuilt which includes
104# the generic ramdisk components like init and the non-device-specific rc files>
105# - VENDOR_RAMDISK_BINARY=<Name of the vendor ramdisk binary which includes the
106# device-specific components of ramdisk like the fstab file and the
107# device-specific rc files.>
108# - KERNEL_BINARY=<name of kernel binary, eg. Image.lz4, Image.gz etc>
109# - BOOT_IMAGE_HEADER_VERSION=<version of the boot image header>
110#
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700111# BUILD_INITRAMFS
112# if defined, build a ramdisk containing all .ko files and resulting depmod artifacts
113#
Matthias Maennich6652d742019-02-01 22:20:44 +0000114# Note: For historic reasons, internally, OUT_DIR will be copied into
115# COMMON_OUT_DIR, and OUT_DIR will be then set to
116# ${COMMON_OUT_DIR}/${KERNEL_DIR}. This has been done to accommodate existing
117# build.config files that expect ${OUT_DIR} to point to the output directory of
118# the kernel build.
119#
120# The kernel is built in ${COMMON_OUT_DIR}/${KERNEL_DIR}.
121# Out-of-tree modules are built in ${COMMON_OUT_DIR}/${EXT_MOD} where
122# ${EXT_MOD} is the path to the module source code.
123
124set -e
125
126# rel_path <to> <from>
127# Generate relative directory path to reach directory <to> from <from>
128function rel_path() {
129 local to=$1
130 local from=$2
131 local path=
132 local stem=
133 local prevstem=
134 [ -n "$to" ] || return 1
135 [ -n "$from" ] || return 1
136 to=$(readlink -e "$to")
137 from=$(readlink -e "$from")
138 [ -n "$to" ] || return 1
139 [ -n "$from" ] || return 1
140 stem=${from}/
141 while [ "${to#$stem}" == "${to}" -a "${stem}" != "${prevstem}" ]; do
142 prevstem=$stem
143 stem=$(readlink -e "${stem}/..")
144 [ "${stem%/}" == "${stem}" ] && stem=${stem}/
145 path=${path}../
146 done
147 echo ${path}${to#$stem}
148}
149
150export ROOT_DIR=$(readlink -f $(dirname $0)/..)
151
152# For module file Signing with the kernel (if needed)
153FILE_SIGN_BIN=scripts/sign-file
154SIGN_SEC=certs/signing_key.pem
155SIGN_CERT=certs/signing_key.x509
156SIGN_ALGO=sha512
157
Alessio Balsinia397d802019-07-24 15:06:20 +0100158# Save environment parameters before being overwritten by sourcing
159# BUILD_CONFIG.
160CC_ARG=${CC}
161
Matthias Maennich6652d742019-02-01 22:20:44 +0000162source "${ROOT_DIR}/build/envsetup.sh"
163
164export MAKE_ARGS=$@
Matthias Maennich6652d742019-02-01 22:20:44 +0000165export MODULES_STAGING_DIR=$(readlink -m ${COMMON_OUT_DIR}/staging)
166export MODULES_PRIVATE_DIR=$(readlink -m ${COMMON_OUT_DIR}/private)
Matthias Maennich6652d742019-02-01 22:20:44 +0000167export UNSTRIPPED_DIR=${DIST_DIR}/unstripped
168export KERNEL_UAPI_HEADERS_DIR=$(readlink -m ${COMMON_OUT_DIR}/kernel_uapi_headers)
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700169export INITRAMFS_STAGING_DIR=${MODULES_STAGING_DIR}/initramfs_staging
Matthias Maennich6652d742019-02-01 22:20:44 +0000170
171cd ${ROOT_DIR}
172
173export CLANG_TRIPLE CROSS_COMPILE CROSS_COMPILE_ARM32 ARCH SUBARCH
174
Alessio Balsinia397d802019-07-24 15:06:20 +0100175# Restore the previously saved CC argument that might have been overridden by
176# the BUILD_CONFIG.
177[ -n "${CC_ARG}" ] && CC=${CC_ARG}
178
Matthias Maennich0646c8d2019-03-20 11:03:51 +0000179# CC=gcc is effectively a fallback to the default gcc including any target
Alessio Balsinia397d802019-07-24 15:06:20 +0100180# triplets. An absolute path (e.g., CC=/usr/bin/gcc) must be specified to use a
181# custom compiler.
182[ "${CC}" == "gcc" ] && unset CC && unset CC_ARG
Matthias Maennich0646c8d2019-03-20 11:03:51 +0000183
Matthias Maennich151047e2019-03-18 15:01:03 +0000184if [ -n "${CC}" ]; then
Matthias Maennich2eb25cc2019-06-24 17:45:18 +0100185 CC_ARG="CC=${CC} HOSTCC=${CC}"
Matthias Maennich151047e2019-03-18 15:01:03 +0000186fi
187
188if [ -n "${LD}" ]; then
189 LD_ARG="LD=${LD}"
190fi
191
192CC_LD_ARG="${CC_ARG} ${LD_ARG}"
193
Matthias Maennich6652d742019-02-01 22:20:44 +0000194mkdir -p ${OUT_DIR}
195echo "========================================================"
196echo " Setting up for build"
197if [ -z "${SKIP_MRPROPER}" ] ; then
198 set -x
Matthias Maennich151047e2019-03-18 15:01:03 +0000199 (cd ${KERNEL_DIR} && make ${CC_LD_ARG} O=${OUT_DIR} mrproper)
Matthias Maennich6652d742019-02-01 22:20:44 +0000200 set +x
201fi
202
Petri Gynther0172f352019-02-12 11:52:50 -0800203if [ "${PRE_DEFCONFIG_CMDS}" != "" ]; then
204 echo "========================================================"
205 echo " Running pre-defconfig command(s):"
206 set -x
207 eval ${PRE_DEFCONFIG_CMDS}
208 set +x
209fi
210
Matthias Maennich6652d742019-02-01 22:20:44 +0000211if [ -z "${SKIP_DEFCONFIG}" ] ; then
212set -x
Matthias Maennich151047e2019-03-18 15:01:03 +0000213(cd ${KERNEL_DIR} && make ${CC_LD_ARG} O=${OUT_DIR} ${DEFCONFIG})
Matthias Maennich6652d742019-02-01 22:20:44 +0000214set +x
215
216if [ "${POST_DEFCONFIG_CMDS}" != "" ]; then
217 echo "========================================================"
218 echo " Running pre-make command(s):"
219 set -x
220 eval ${POST_DEFCONFIG_CMDS}
221 set +x
222fi
223fi
224
225echo "========================================================"
226echo " Building kernel"
227
Matthias Maennich6652d742019-02-01 22:20:44 +0000228set -x
229(cd ${OUT_DIR} && \
Matthias Maennich151047e2019-03-18 15:01:03 +0000230 make O=${OUT_DIR} ${CC_LD_ARG} -j$(nproc) $@)
Matthias Maennich6652d742019-02-01 22:20:44 +0000231set +x
232
Petri Gynther0172f352019-02-12 11:52:50 -0800233if [ "${POST_KERNEL_BUILD_CMDS}" != "" ]; then
234 echo "========================================================"
235 echo " Running post-kernel-build command(s):"
236 set -x
237 eval ${POST_KERNEL_BUILD_CMDS}
238 set +x
239fi
240
Matthias Maennich6652d742019-02-01 22:20:44 +0000241rm -rf ${MODULES_STAGING_DIR}
242mkdir -p ${MODULES_STAGING_DIR}
243
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700244if [ -n "${BUILD_INITRAMFS}" -o -n "${IN_KERNEL_MODULES}" ]; then
Matthias Maennich6652d742019-02-01 22:20:44 +0000245 echo "========================================================"
246 echo " Installing kernel modules into staging directory"
247
248 (cd ${OUT_DIR} && \
Matthias Maennich151047e2019-03-18 15:01:03 +0000249 make O=${OUT_DIR} ${CC_LD_ARG} INSTALL_MOD_STRIP=1 \
Matthias Maennich6652d742019-02-01 22:20:44 +0000250 INSTALL_MOD_PATH=${MODULES_STAGING_DIR} modules_install)
251fi
252
253if [[ -z "${SKIP_EXT_MODULES}" ]] && [[ "${EXT_MODULES}" != "" ]]; then
254 echo "========================================================"
255 echo " Building external modules and installing them into staging directory"
256
257 for EXT_MOD in ${EXT_MODULES}; do
258 # The path that we pass in via the variable M needs to be a relative path
259 # relative to the kernel source directory. The source files will then be
260 # looked for in ${KERNEL_DIR}/${EXT_MOD_REL} and the object files (i.e. .o
261 # and .ko) files will be stored in ${OUT_DIR}/${EXT_MOD_REL}. If we
262 # instead set M to an absolute path, then object (i.e. .o and .ko) files
263 # are stored in the module source directory which is not what we want.
264 EXT_MOD_REL=$(rel_path ${ROOT_DIR}/${EXT_MOD} ${KERNEL_DIR})
265 # The output directory must exist before we invoke make. Otherwise, the
266 # build system behaves horribly wrong.
267 mkdir -p ${OUT_DIR}/${EXT_MOD_REL}
268 set -x
269 make -C ${EXT_MOD} M=${EXT_MOD_REL} KERNEL_SRC=${ROOT_DIR}/${KERNEL_DIR} \
Matthias Maennich151047e2019-03-18 15:01:03 +0000270 O=${OUT_DIR} ${CC_LD_ARG} -j$(nproc) "$@"
Matthias Maennich6652d742019-02-01 22:20:44 +0000271 make -C ${EXT_MOD} M=${EXT_MOD_REL} KERNEL_SRC=${ROOT_DIR}/${KERNEL_DIR} \
Matthias Maennich151047e2019-03-18 15:01:03 +0000272 O=${OUT_DIR} ${CC_LD_ARG} INSTALL_MOD_STRIP=1 \
Matthias Maennich6652d742019-02-01 22:20:44 +0000273 INSTALL_MOD_PATH=${MODULES_STAGING_DIR} modules_install
274 set +x
275 done
276
277fi
278
279if [ "${EXTRA_CMDS}" != "" ]; then
280 echo "========================================================"
281 echo " Running extra build command(s):"
282 set -x
283 eval ${EXTRA_CMDS}
284 set +x
285fi
286
287OVERLAYS_OUT=""
288for ODM_DIR in ${ODM_DIRS}; do
289 OVERLAY_DIR=${ROOT_DIR}/device/${ODM_DIR}/overlays
290
291 if [ -d ${OVERLAY_DIR} ]; then
292 OVERLAY_OUT_DIR=${OUT_DIR}/overlays/${ODM_DIR}
293 mkdir -p ${OVERLAY_OUT_DIR}
294 make -C ${OVERLAY_DIR} DTC=${OUT_DIR}/scripts/dtc/dtc OUT_DIR=${OVERLAY_OUT_DIR}
295 OVERLAYS=$(find ${OVERLAY_OUT_DIR} -name "*.dtbo")
296 OVERLAYS_OUT="$OVERLAYS_OUT $OVERLAYS"
297 fi
298done
299
300mkdir -p ${DIST_DIR}
301echo "========================================================"
302echo " Copying files"
Alessio Balsiniac896332019-07-16 15:20:24 +0100303for FILE in $(cd ${OUT_DIR} && ls -1 ${FILES}); do
Matthias Maennich6652d742019-02-01 22:20:44 +0000304 if [ -f ${OUT_DIR}/${FILE} ]; then
305 echo " $FILE"
306 cp -p ${OUT_DIR}/${FILE} ${DIST_DIR}/
307 else
Alessio Balsiniac896332019-07-16 15:20:24 +0100308 echo " $FILE is not a file, skipping"
Matthias Maennich6652d742019-02-01 22:20:44 +0000309 fi
310done
311
312for FILE in ${OVERLAYS_OUT}; do
313 OVERLAY_DIST_DIR=${DIST_DIR}/$(dirname ${FILE#${OUT_DIR}/overlays/})
314 echo " ${FILE#${OUT_DIR}/}"
315 mkdir -p ${OVERLAY_DIST_DIR}
316 cp ${FILE} ${OVERLAY_DIST_DIR}/
317done
318
319MODULES=$(find ${MODULES_STAGING_DIR} -type f -name "*.ko")
320if [ -n "${MODULES}" ]; then
Matthias Maennich6652d742019-02-01 22:20:44 +0000321 if [ -n "${IN_KERNEL_MODULES}" -o "${EXT_MODULES}" != "" ]; then
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700322 echo "========================================================"
323 echo " Copying modules files"
Matthias Maennich6652d742019-02-01 22:20:44 +0000324 for FILE in ${MODULES}; do
325 echo " ${FILE#${MODULES_STAGING_DIR}/}"
326 cp -p ${FILE} ${DIST_DIR}
327 done
328 fi
Ram Muthiah3a869ac2019-08-08 21:11:56 -0700329 if [ -n "${BUILD_INITRAMFS}" ]; then
330 echo "========================================================"
331 echo " Creating initramfs"
332 set -x
333 rm -rf ${INITRAMFS_STAGING_DIR}
334 mkdir -p ${INITRAMFS_STAGING_DIR}/lib/modules/kernel/
335 cp -r ${MODULES_STAGING_DIR}/lib/modules/*/kernel/* ${INITRAMFS_STAGING_DIR}/lib/modules/kernel/
336 cp ${MODULES_STAGING_DIR}/lib/modules/*/modules.* ${INITRAMFS_STAGING_DIR}/lib/modules/
337 cp ${MODULES_STAGING_DIR}/lib/modules/*/modules.order ${INITRAMFS_STAGING_DIR}/lib/modules/modules.load
338
339 (cd ${INITRAMFS_STAGING_DIR} && find . | cpio -H newc -o > ${MODULES_STAGING_DIR}/initramfs.cpio)
340 gzip -f ${MODULES_STAGING_DIR}/initramfs.cpio
341 mv ${MODULES_STAGING_DIR}/initramfs.cpio.gz ${DIST_DIR}/initramfs.img
342 set +x
343 fi
Matthias Maennich6652d742019-02-01 22:20:44 +0000344fi
345
346if [ "${UNSTRIPPED_MODULES}" != "" ]; then
347 echo "========================================================"
348 echo " Copying unstripped module files for debugging purposes (not loaded on device)"
349 mkdir -p ${UNSTRIPPED_DIR}
350 for MODULE in ${UNSTRIPPED_MODULES}; do
351 find ${MODULES_PRIVATE_DIR} -name ${MODULE} -exec cp {} ${UNSTRIPPED_DIR} \;
352 done
353fi
354
355if [ -z "${SKIP_CP_KERNEL_HDR}" ]; then
356 echo "========================================================"
357 echo " Installing UAPI kernel headers:"
358 mkdir -p "${KERNEL_UAPI_HEADERS_DIR}/usr"
Matthias Maennich151047e2019-03-18 15:01:03 +0000359 make -C ${OUT_DIR} O=${OUT_DIR} ${CC_LD_ARG} INSTALL_HDR_PATH="${KERNEL_UAPI_HEADERS_DIR}/usr" -j$(nproc) headers_install
Matthias Maennich6652d742019-02-01 22:20:44 +0000360 # The kernel makefiles create files named ..install.cmd and .install which
361 # are only side products. We don't want those. Let's delete them.
362 find ${KERNEL_UAPI_HEADERS_DIR} \( -name ..install.cmd -o -name .install \) -exec rm '{}' +
363 KERNEL_UAPI_HEADERS_TAR=${DIST_DIR}/kernel-uapi-headers.tar.gz
364 echo " Copying kernel UAPI headers to ${KERNEL_UAPI_HEADERS_TAR}"
365 tar -czf ${KERNEL_UAPI_HEADERS_TAR} --directory=${KERNEL_UAPI_HEADERS_DIR} usr/
366fi
367
368if [ -z "${SKIP_CP_KERNEL_HDR}" ] ; then
Matthias Maennichbec886a2019-04-15 07:23:47 +0100369 echo "========================================================"
370 KERNEL_HEADERS_TAR=${DIST_DIR}/kernel-headers.tar.gz
371 echo " Copying kernel headers to ${KERNEL_HEADERS_TAR}"
372 pushd $ROOT_DIR/$KERNEL_DIR
373 find arch include $OUT_DIR -name *.h -print0 \
374 | tar -czf $KERNEL_HEADERS_TAR \
375 --absolute-names \
376 --dereference \
377 --transform "s,.*$OUT_DIR,," \
378 --transform "s,^,kernel-headers/," \
379 --null -T -
380 popd
Matthias Maennich6652d742019-02-01 22:20:44 +0000381fi
382
Matthias Maennichd46fd322019-05-29 09:05:38 +0100383# Copy the abi_${arch}.xml file from the sources into the dist dir
Matthias Maennich44509b02019-05-28 12:26:58 +0100384if [ -n "${ABI_DEFINITION}" ]; then
385 echo "========================================================"
Matthias Maennichd46fd322019-05-29 09:05:38 +0100386 echo " Copying abi definition to ${DIST_DIR}/abi.xml"
Matthias Maennich44509b02019-05-28 12:26:58 +0100387 pushd $ROOT_DIR/$KERNEL_DIR
Matthias Maennichd46fd322019-05-29 09:05:38 +0100388 cp "${ABI_DEFINITION}" ${DIST_DIR}/abi.xml
Matthias Maennich44509b02019-05-28 12:26:58 +0100389 popd
390fi
391
Matthias Maennich6652d742019-02-01 22:20:44 +0000392echo "========================================================"
393echo " Files copied to ${DIST_DIR}"
394
Hridya Valsarajue46a9372019-05-13 16:38:14 -0700395if [ ! -z "${BUILD_BOOT_IMG}" ] ; then
396
397 DTB_FILE_LIST=$(find ${DIST_DIR} -name "*.dtb")
398 if [ -z "${DTB_FILE_LIST}" ]; then
399 echo "No *.dtb files found in ${DIST_DIR}"
400 exit 1
401 fi
402 cat $DTB_FILE_LIST > ${DIST_DIR}/dtb.img
403
404 if [ ! -f "${DIST_DIR}/$GKI_RAMDISK_PREBUILT_BINARY" ]; then
405 echo "GKI ramdisk prebuilt binary" \
406 "(GKI_RAMDISK_PREBUILT_BINARY = $GKI_RAMDISK_PREBUILT_BINARY)" \
407 "not present in ${DIST_DIR}"
408 exit 1
409 fi
410 if [ ! -f "${DIST_DIR}/$VENDOR_RAMDISK_BINARY" ]; then
411 echo "vendor ramdisk binary(VENDOR_RAMDISK_BINARY = $VENDOR_RAMDISK_BINARY)" \
412 "not present in ${DIST_DIR}"
413 exit 1
414 fi
415
416 cat ${DIST_DIR}/$GKI_RAMDISK_PREBUILT_BINARY ${DIST_DIR}/$VENDOR_RAMDISK_BINARY \
417 > ${DIST_DIR}/ramdisk.cpio
418 gzip -f ${DIST_DIR}/ramdisk.cpio > ${DIST_DIR}/ramdisk
419
420 if [ ! -x "$MKBOOTIMG_PATH" ]; then
421 echo "mkbootimg.py script not found or not executable. MKBOOTIMG_PATH = $MKBOOTIMG_PATH"
422 exit 1
423 fi
424
425 if [ ! -f "${DIST_DIR}/$KERNEL_BINARY" ]; then
426 echo "kernel binary(KERNEL_BINARY = $KERNEL_BINARY) not present in ${DIST_DIR}"
427 exit 1
428 fi
429
430 if [ -z "${BOOT_IMAGE_HEADER_VERSION}" ]; then
431 echo "BOOT_IMAGE_HEADER_VERSION must specify the boot image header version"
432 exit 1
433 fi
434
435 (set -x; $MKBOOTIMG_PATH --kernel ${DIST_DIR}/$KERNEL_BINARY \
436 --ramdisk ${DIST_DIR}/ramdisk \
437 --dtb ${DIST_DIR}/dtb.img --header_version $BOOT_IMAGE_HEADER_VERSION \
438 -o ${DIST_DIR}/boot.img
439 )
440 set +x
441 echo "boot image created at ${DIST_DIR}/boot.img"
442fi
443
444
Matthias Maennich6652d742019-02-01 22:20:44 +0000445# No trace_printk use on build server build
446if readelf -a ${DIST_DIR}/vmlinux 2>&1 | grep -q trace_printk_fmt; then
447 echo "========================================================"
448 echo "WARN: Found trace_printk usage in vmlinux."
449 echo ""
450 echo "trace_printk will cause trace_printk_init_buffers executed in kernel"
451 echo "start, which will increase memory and lead warning shown during boot."
452 echo "We should not carry trace_printk in production kernel."
453 echo ""
454 if [ ! -z "${STOP_SHIP_TRACEPRINTK}" ]; then
455 echo "ERROR: stop ship on trace_printk usage." 1>&2
456 exit 1
457 fi
458fi