blob: 78d6c30b07c133f2cc30f178abec150ea50de8fe [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit linux-kernel-base kernel-module-split
2
Brad Bishop316dfdd2018-06-25 12:45:53 -04003KERNEL_PACKAGE_NAME ??= "kernel"
4KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"
5
6PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }"
7DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native bison-native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05008PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009
10do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot"
11
12CVE_PRODUCT ?= "linux_kernel"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013
14S = "${STAGING_KERNEL_DIR}"
15B = "${WORKDIR}/build"
16KBUILD_OUTPUT = "${B}"
17OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT"
18
19# we include gcc above, we dont need virtual/libc
20INHIBIT_DEFAULT_DEPS = "1"
21
22KERNEL_IMAGETYPE ?= "zImage"
23INITRAMFS_IMAGE ?= ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025INITRAMFS_TASK ?= ""
26INITRAMFS_IMAGE_BUNDLE ?= ""
27
He Zhefe76b1e2016-05-25 04:47:16 -040028# KERNEL_VERSION is extracted from source code. It is evaluated as
29# None for the first parsing, since the code has not been fetched.
30# After the code is fetched, it will be evaluated as real version
31# number and cause kernel to be rebuilt. To avoid this, make
32# KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on
33# LINUX_VERSION which is a constant.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or ""}"
He Zhefe76b1e2016-05-25 04:47:16 -040035KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}"
He Zhefe76b1e2016-05-25 04:47:16 -040037KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
38
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039python __anonymous () {
Brad Bishop316dfdd2018-06-25 12:45:53 -040040 pn = d.getVar("PN")
41 kpn = d.getVar("KERNEL_PACKAGE_NAME")
42
43 # XXX Remove this after bug 11905 is resolved
44 # FILES_${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
45 if kpn == pn:
46 bb.warn("Some packages (E.g. *-dev) might be missing due to "
47 "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
48
49 # The default kernel recipe builds in a shared location defined by
50 # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
51 # Set these variables to directories under ${WORKDIR} in alternate
52 # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
53 # may build in parallel with the default kernel without clobbering.
54 if kpn != "kernel":
55 workdir = d.getVar("WORKDIR")
56 sourceDir = os.path.join(workdir, 'kernel-source')
57 artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
58 d.setVar("STAGING_KERNEL_DIR", sourceDir)
59 d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060
He Zhefe76b1e2016-05-25 04:47:16 -040061 # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 type = d.getVar('KERNEL_IMAGETYPE') or ""
63 alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
64 types = d.getVar('KERNEL_IMAGETYPES') or ""
Brad Bishop316dfdd2018-06-25 12:45:53 -040065 kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
He Zhefe76b1e2016-05-25 04:47:16 -040066 if type not in types.split():
67 types = (type + ' ' + types).strip()
68 if alttype not in types.split():
69 types = (alttype + ' ' + types).strip()
70 d.setVar('KERNEL_IMAGETYPES', types)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072 # some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
73 # typeformake lists only valid kernel make targets, and post processing can be done after the kernel
74 # is built (such as using gzip to compress vmlinux)
75 typeformake = types.replace('vmlinux.gz', 'vmlinux')
He Zhefe76b1e2016-05-25 04:47:16 -040076 d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
77
Brad Bishop37a0e4d2017-12-04 01:01:44 -050078 for type in types.split():
He Zhefe76b1e2016-05-25 04:47:16 -040079 typelower = type.lower()
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080 imagedest = d.getVar('KERNEL_IMAGEDEST')
He Zhefe76b1e2016-05-25 04:47:16 -040081
Brad Bishop316dfdd2018-06-25 12:45:53 -040082 d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
He Zhefe76b1e2016-05-25 04:47:16 -040083
Brad Bishop316dfdd2018-06-25 12:45:53 -040084 d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
He Zhefe76b1e2016-05-25 04:47:16 -040085
Brad Bishop316dfdd2018-06-25 12:45:53 -040086 d.appendVar('RDEPENDS_%s-image' % kname, ' %s-image-%s' % (kname, typelower))
He Zhefe76b1e2016-05-25 04:47:16 -040087
Brad Bishop316dfdd2018-06-25 12:45:53 -040088 d.setVar('PKG_%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
He Zhefe76b1e2016-05-25 04:47:16 -040089
Brad Bishop316dfdd2018-06-25 12:45:53 -040090 d.setVar('ALLOW_EMPTY_%s-image-%s' % (kname, typelower), '1')
He Zhefe76b1e2016-05-25 04:47:16 -040091
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092 image = d.getVar('INITRAMFS_IMAGE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 if image:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050094 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095
96 # NOTE: setting INITRAMFS_TASK is for backward compatibility
97 # The preferred method is to set INITRAMFS_IMAGE, because
98 # this INITRAMFS_TASK has circular dependency problems
99 # if the initramfs requires kernel modules
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500100 image_task = d.getVar('INITRAMFS_TASK')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101 if image_task:
102 d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
103}
104
105# Here we pull in all various kernel image types which we support.
106#
107# In case you're wondering why kernel.bbclass inherits the other image
108# types instead of the other way around, the reason for that is to
109# maintain compatibility with various currently existing meta-layers.
110# By pulling in the various kernel image types here, we retain the
111# original behavior of kernel.bbclass, so no meta-layers should get
112# broken.
113#
114# KERNEL_CLASSES by default pulls in kernel-uimage.bbclass, since this
115# used to be the default behavior when only uImage was supported. This
116# variable can be appended by users who implement support for new kernel
117# image types.
118
119KERNEL_CLASSES ?= " kernel-uimage "
120inherit ${KERNEL_CLASSES}
121
122# Old style kernels may set ${S} = ${WORKDIR}/git for example
123# We need to move these over to STAGING_KERNEL_DIR. We can't just
124# create the symlink in advance as the git fetcher can't cope with
125# the symlink.
126do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
127do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
128base_do_unpack_append () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500129 s = d.getVar("S")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130 if s[-1] == '/':
131 # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as directory name and fail
132 s=s[:-1]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500133 kernsrc = d.getVar("STAGING_KERNEL_DIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134 if s != kernsrc:
135 bb.utils.mkdirhier(kernsrc)
136 bb.utils.remove(kernsrc, recurse=True)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 if d.getVar("EXTERNALSRC"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138 # With EXTERNALSRC S will not be wiped so we can symlink to it
139 os.symlink(s, kernsrc)
140 else:
141 import shutil
142 shutil.move(s, kernsrc)
143 os.symlink(kernsrc, s)
144}
145
146inherit kernel-arch deploy
147
Brad Bishop316dfdd2018-06-25 12:45:53 -0400148PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
149PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
150PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151
152export OS = "${TARGET_OS}"
153export CROSS_COMPILE = "${TARGET_PREFIX}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400154export KBUILD_BUILD_VERSION = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500155export KBUILD_BUILD_USER = "oe-user"
156export KBUILD_BUILD_HOST = "oe-host"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158KERNEL_RELEASE ?= "${KERNEL_VERSION}"
159
He Zhefe76b1e2016-05-25 04:47:16 -0400160# The directory where built kernel lies in the kernel tree
161KERNEL_OUTPUT_DIR ?= "arch/${ARCH}/boot"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162KERNEL_IMAGEDEST = "boot"
163
164#
165# configuration
166#
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE") or "ttyS0"}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168
169KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"
170
171KERNEL_LOCALVERSION ?= ""
172
173# kernels are generally machine specific
174PACKAGE_ARCH = "${MACHINE_ARCH}"
175
176# U-Boot support
177UBOOT_ENTRYPOINT ?= "20008000"
178UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
179
180# Some Linux kernel configurations need additional parameters on the command line
181KERNEL_EXTRA_ARGS ?= ""
182
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500183EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184KERNEL_ALT_IMAGETYPE ??= ""
185
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186copy_initramfs() {
187 echo "Copying initramfs into ./usr ..."
188 # In case the directory is not created yet from the first pass compile:
189 mkdir -p ${B}/usr
190 # Find and use the first initramfs image archive type we find
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500191 rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500192 for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz; do
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500193 if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then
194 cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195 case $img in
196 *gz)
197 echo "gzip decompressing image"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500198 gunzip -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500199 break
200 ;;
201 *lz4)
202 echo "lz4 decompressing image"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500203 lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500204 break
205 ;;
206 *lzo)
207 echo "lzo decompressing image"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500208 lzop -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500209 break
210 ;;
211 *lzma)
212 echo "lzma decompressing image"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500213 lzma -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500214 break
215 ;;
216 *xz)
217 echo "xz decompressing image"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500218 xz -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500219 break
220 ;;
221 esac
222 fi
223 done
224 echo "Finished copy of initramfs into ./usr"
225}
226
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600227INITRAMFS_BASE_NAME ?= "initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500228INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME"
229do_bundle_initramfs () {
230 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
231 echo "Creating a kernel image with a bundled initramfs..."
232 copy_initramfs
He Zhefe76b1e2016-05-25 04:47:16 -0400233 # Backing up kernel image relies on its type(regular file or symbolic link)
234 tmp_path=""
Brad Bishop316dfdd2018-06-25 12:45:53 -0400235 for type in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
He Zhefe76b1e2016-05-25 04:47:16 -0400236 if [ -h ${KERNEL_OUTPUT_DIR}/$type ] ; then
237 linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$type`
238 realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$type`
239 mv -f $realpath $realpath.bak
240 tmp_path=$tmp_path" "$type"#"$linkpath"#"$realpath
241 elif [ -f ${KERNEL_OUTPUT_DIR}/$type ]; then
242 mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.bak
243 tmp_path=$tmp_path" "$type"##"
244 fi
245 done
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500246 use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500247 kernel_do_compile
He Zhefe76b1e2016-05-25 04:47:16 -0400248 # Restoring kernel image
249 for tp in $tmp_path ; do
250 type=`echo $tp|cut -d "#" -f 1`
251 linkpath=`echo $tp|cut -d "#" -f 2`
252 realpath=`echo $tp|cut -d "#" -f 3`
253 if [ -n "$realpath" ]; then
254 mv -f $realpath $realpath.initramfs
255 mv -f $realpath.bak $realpath
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600256 ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs
He Zhefe76b1e2016-05-25 04:47:16 -0400257 else
258 mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.initramfs
259 mv -f ${KERNEL_OUTPUT_DIR}/$type.bak ${KERNEL_OUTPUT_DIR}/$type
260 fi
261 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500262 fi
263}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600264do_bundle_initramfs[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500265
266python do_devshell_prepend () {
267 os.environ["LDFLAGS"] = ''
268}
269
270addtask bundle_initramfs after do_install before do_deploy
271
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500272get_cc_option () {
273 # Check if KERNEL_CC supports the option "file-prefix-map".
274 # This option allows us to build images with __FILE__ values that do not
275 # contain the host build path.
276 if ${KERNEL_CC} -Q --help=joined | grep -q "\-ffile-prefix-map=<old=new>"; then
277 echo "-ffile-prefix-map=${S}=/kernel-source/"
278 fi
279}
280
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281kernel_do_compile() {
282 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
Brad Bishop316dfdd2018-06-25 12:45:53 -0400283 if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500284 # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
285 # be set....
286 if [ "$SOURCE_DATE_EPOCH" = "0" ]; then
287 olddir=`pwd`
288 cd ${S}
289 SOURCE_DATE_EPOCH=`git log -1 --pretty=%ct`
290 # git repo not guaranteed, so fall back to REPRODUCIBLE_TIMESTAMP_ROOTFS
291 if [ $? -ne 0 ]; then
292 SOURCE_DATE_EPOCH=${REPRODUCIBLE_TIMESTAMP_ROOTFS}
293 fi
294 cd $olddir
295 fi
296
297 ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH`
298 export KBUILD_BUILD_TIMESTAMP="$ts"
299 export KCONFIG_NOTIMESTAMP=1
300 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
301 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500302 # The $use_alternate_initrd is only set from
303 # do_bundle_initramfs() This variable is specifically for the
304 # case where we are making a second pass at the kernel
305 # compilation and we want to force the kernel build to use a
306 # different initramfs image. The way to do that in the kernel
307 # is to specify:
308 # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
309 if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then
310 # The old style way of copying an prebuilt image and building it
311 # is turned on via INTIRAMFS_TASK != ""
312 copy_initramfs
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500313 use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500314 fi
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500315 cc_extra=$(get_cc_option)
He Zhefe76b1e2016-05-25 04:47:16 -0400316 for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500317 oe_runmake ${typeformake} CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
He Zhefe76b1e2016-05-25 04:47:16 -0400318 done
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500319 # vmlinux.gz is not built by kernel
320 if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
321 mkdir -p "${KERNEL_OUTPUT_DIR}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500322 gzip -9cn < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500323 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500324}
325
326do_compile_kernelmodules() {
327 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
328 if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500329 cc_extra=$(get_cc_option)
330 oe_runmake -C ${B} ${PARALLEL_MAKE} modules CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500331
332 # Module.symvers gets updated during the
333 # building of the kernel modules. We need to
334 # update this in the shared workdir since some
335 # external kernel modules has a dependency on
336 # other kernel modules and will look at this
337 # file to do symbol lookups
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600338 cp ${B}/Module.symvers ${STAGING_KERNEL_BUILDDIR}/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500339 else
340 bbnote "no modules to compile"
341 fi
342}
343addtask compile_kernelmodules after do_compile before do_strip
344
345kernel_do_install() {
346 #
347 # First install the modules
348 #
349 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
350 if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500351 oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install
352 rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
353 rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354 # If the kernel/ directory is empty remove it to prevent QA issues
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500355 rmdir --ignore-fail-on-non-empty "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500356 else
357 bbnote "no modules to install"
358 fi
359
360 #
361 # Install various kernel output (zImage, map file, config, module support files)
362 #
363 install -d ${D}/${KERNEL_IMAGEDEST}
364 install -d ${D}/boot
He Zhefe76b1e2016-05-25 04:47:16 -0400365 for type in ${KERNEL_IMAGETYPES} ; do
366 install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400367 if [ "${KERNEL_PACKAGE_NAME}" = "kernel" ]; then
368 ln -sf ${type}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${type}
369 fi
He Zhefe76b1e2016-05-25 04:47:16 -0400370 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500371 install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
372 install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
373 install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
374 [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
375 install -d ${D}${sysconfdir}/modules-load.d
376 install -d ${D}${sysconfdir}/modprobe.d
377}
378do_install[prefuncs] += "package_get_auto_pr"
379
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600380# Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile
381do_kernel_version_sanity_check() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500382 if [ "x${KERNEL_VERSION_SANITY_SKIP}" = "x1" ]; then
383 exit 0
384 fi
385
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600386 # The Makefile determines the kernel version shown at runtime
387 # Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile
388 VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//)
389 PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
390 SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
391 EXTRAVERSION=$(grep "^EXTRAVERSION =" ${S}/Makefile | sed s/.*=\ *//)
392
393 # Build a string for regex and a plain version string
394 reg="^${VERSION}\.${PATCHLEVEL}"
395 vers="${VERSION}.${PATCHLEVEL}"
396 if [ -n "${SUBLEVEL}" ]; then
397 # Ignoring a SUBLEVEL of zero is fine
398 if [ "${SUBLEVEL}" = "0" ]; then
399 reg="${reg}(\.${SUBLEVEL})?"
400 else
401 reg="${reg}\.${SUBLEVEL}"
402 vers="${vers}.${SUBLEVEL}"
403 fi
404 fi
405 vers="${vers}${EXTRAVERSION}"
406 reg="${reg}${EXTRAVERSION}"
407
408 if [ -z `echo ${PV} | grep -E "${reg}"` ]; then
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500409 bbfatal "Package Version (${PV}) does not match of kernel being built (${vers}). Please update the PV variable to match the kernel source or set KERNEL_VERSION_SANITY_SKIP=\"1\" in your recipe."
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600410 fi
411 exit 0
412}
413
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500414addtask shared_workdir after do_compile before do_compile_kernelmodules
415addtask shared_workdir_setscene
416
417do_shared_workdir_setscene () {
418 exit 1
419}
420
421emit_depmod_pkgdata() {
422 # Stash data for depmod
Brad Bishop316dfdd2018-06-25 12:45:53 -0400423 install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
424 echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
425 cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500426}
427
428PACKAGEFUNCS += "emit_depmod_pkgdata"
429
Brad Bishop316dfdd2018-06-25 12:45:53 -0400430do_shared_workdir[cleandirs] += " ${STAGING_KERNEL_BUILDDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500431do_shared_workdir () {
432 cd ${B}
433
434 kerneldir=${STAGING_KERNEL_BUILDDIR}
435 install -d $kerneldir
436
437 #
438 # Store the kernel version in sysroots for module-base.bbclass
439 #
440
Brad Bishop316dfdd2018-06-25 12:45:53 -0400441 echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500442
443 # Copy files required for module builds
444 cp System.map $kerneldir/System.map-${KERNEL_VERSION}
445 cp Module.symvers $kerneldir/
446 cp .config $kerneldir/
447 mkdir -p $kerneldir/include/config
448 cp include/config/kernel.release $kerneldir/include/config/kernel.release
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600449 if [ -e certs/signing_key.pem ]; then
450 # The signing_key.* files are stored in the certs/ dir in
451 # newer Linux kernels
452 mkdir -p $kerneldir/certs
453 cp certs/signing_key.* $kerneldir/certs/
454 elif [ -e signing_key.priv ]; then
455 cp signing_key.* $kerneldir/
456 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500457
458 # We can also copy over all the generated files and avoid special cases
459 # like version.h, but we've opted to keep this small until file creep starts
460 # to happen
461 if [ -e include/linux/version.h ]; then
462 mkdir -p $kerneldir/include/linux
463 cp include/linux/version.h $kerneldir/include/linux/version.h
464 fi
465
466 # As of Linux kernel version 3.0.1, the clean target removes
467 # arch/powerpc/lib/crtsavres.o which is present in
468 # KBUILD_LDFLAGS_MODULE, making it required to build external modules.
469 if [ ${ARCH} = "powerpc" ]; then
Brad Bishop316dfdd2018-06-25 12:45:53 -0400470 if [ -e arch/powerpc/lib/crtsavres.o ]; then
471 mkdir -p $kerneldir/arch/powerpc/lib/
472 cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
473 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500474 fi
475
476 if [ -d include/generated ]; then
477 mkdir -p $kerneldir/include/generated/
478 cp -fR include/generated/* $kerneldir/include/generated/
479 fi
480
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500481 if [ -d arch/${ARCH}/include/generated ]; then
482 mkdir -p $kerneldir/arch/${ARCH}/include/generated/
483 cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500484 fi
485}
486
487# We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware
488sysroot_stage_all () {
489 :
490}
491
Brad Bishop316dfdd2018-06-25 12:45:53 -0400492KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500493
He Zhefe76b1e2016-05-25 04:47:16 -0400494python check_oldest_kernel() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500495 oldest_kernel = d.getVar('OLDEST_KERNEL')
496 kernel_version = d.getVar('KERNEL_VERSION')
497 tclibc = d.getVar('TCLIBC')
He Zhefe76b1e2016-05-25 04:47:16 -0400498 if tclibc == 'glibc':
499 kernel_version = kernel_version.split('-', 1)[0]
500 if oldest_kernel and kernel_version:
501 if bb.utils.vercmp_string(kernel_version, oldest_kernel) < 0:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500502 bb.warn('%s: OLDEST_KERNEL is "%s" but the version of the kernel you are building is "%s" - therefore %s as built may not be compatible with this kernel. Either set OLDEST_KERNEL to an older version, or build a newer kernel.' % (d.getVar('PN'), oldest_kernel, kernel_version, tclibc))
He Zhefe76b1e2016-05-25 04:47:16 -0400503}
504
505check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION"
506do_configure[prefuncs] += "check_oldest_kernel"
507
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500508kernel_do_configure() {
509 # fixes extra + in /lib/modules/2.6.37+
510 # $ scripts/setlocalversion . => +
511 # $ make kernelversion => 2.6.37
512 # $ make kernelrelease => 2.6.37+
513 touch ${B}/.scmversion ${S}/.scmversion
514
515 if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then
516 mv "${S}/.config" "${B}/.config"
517 fi
518
519 # Copy defconfig to .config if .config does not exist. This allows
520 # recipes to manage the .config themselves in do_configure_prepend().
521 if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
522 cp "${WORKDIR}/defconfig" "${B}/.config"
523 fi
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500524
525 ${KERNEL_CONFIG_COMMAND}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500526}
527
528do_savedefconfig() {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600529 bbplain "Saving defconfig to:\n${B}/defconfig"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500530 oe_runmake -C ${B} savedefconfig
531}
532do_savedefconfig[nostamp] = "1"
533addtask savedefconfig after do_configure
534
535inherit cml1
536
Brad Bishop316dfdd2018-06-25 12:45:53 -0400537KCONFIG_CONFIG_COMMAND_append = " HOSTLDFLAGS='${BUILD_LDFLAGS}'"
538
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500539EXPORT_FUNCTIONS do_compile do_install do_configure
540
541# kernel-base becomes kernel-${KERNEL_VERSION}
He Zhefe76b1e2016-05-25 04:47:16 -0400542# kernel-image becomes kernel-image-${KERNEL_VERSION}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400543PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500544FILES_${PN} = ""
Brad Bishop316dfdd2018-06-25 12:45:53 -0400545FILES_${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
546FILES_${KERNEL_PACKAGE_NAME}-image = ""
547FILES_${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
548FILES_${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
549FILES_${KERNEL_PACKAGE_NAME}-modules = ""
550RDEPENDS_${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base"
He Zhefe76b1e2016-05-25 04:47:16 -0400551# Allow machines to override this dependency if kernel image files are
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500552# not wanted in images as standard
Brad Bishop316dfdd2018-06-25 12:45:53 -0400553RDEPENDS_${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image"
554PKG_${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
555RDEPENDS_${KERNEL_PACKAGE_NAME}-image += "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux', '', d)}"
556PKG_${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name('${KERNEL_VERSION}')}"
557RPROVIDES_${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
558ALLOW_EMPTY_${KERNEL_PACKAGE_NAME} = "1"
559ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-base = "1"
560ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-image = "1"
561ALLOW_EMPTY_${KERNEL_PACKAGE_NAME}-modules = "1"
562DESCRIPTION_${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500563
Brad Bishop316dfdd2018-06-25 12:45:53 -0400564pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500565 if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
566 mkdir -p $D/lib/modules/${KERNEL_VERSION}
567 fi
568 if [ -n "$D" ]; then
569 depmodwrapper -a -b $D ${KERNEL_VERSION}
570 else
571 depmod -a ${KERNEL_VERSION}
572 fi
573}
574
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500575PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
576
577python split_kernel_packages () {
Brad Bishop316dfdd2018-06-25 12:45:53 -0400578 do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500579}
580
581# Many scripts want to look in arch/$arch/boot for the bootable
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600582# image. This poses a problem for vmlinux and vmlinuz based
583# booting. This task arranges to have vmlinux and vmlinuz appear
584# in the normalized directory location.
585do_kernel_link_images() {
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500586 if [ ! -d "${B}/arch/${ARCH}/boot" ]; then
587 mkdir ${B}/arch/${ARCH}/boot
588 fi
589 cd ${B}/arch/${ARCH}/boot
590 ln -sf ../../../vmlinux
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600591 if [ -f ../../../vmlinuz ]; then
592 ln -sf ../../../vmlinuz
593 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500594 if [ -f ../../../vmlinuz.bin ]; then
595 ln -sf ../../../vmlinuz.bin
596 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500597}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500598addtask kernel_link_images after do_compile before do_strip
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500599
600do_strip() {
601 if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then
He Zhefe76b1e2016-05-25 04:47:16 -0400602 if ! (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux"); then
603 bbwarn "image type(s) will not be stripped (not supported): ${KERNEL_IMAGETYPES}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500604 return
605 fi
606
607 cd ${B}
He Zhefe76b1e2016-05-25 04:47:16 -0400608 headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_DIR}/vmlinux | \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500609 grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \
610 sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \
611 gawk '{print $1}'`
612
613 for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500614 if ! (echo "$headers" | grep -q "^$str$"); then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500615 bbwarn "Section not found: $str";
616 fi
617
He Zhefe76b1e2016-05-25 04:47:16 -0400618 "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_DIR}/vmlinux
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500619 }; done
620
621 bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \
622 "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}"
623 fi;
624}
625do_strip[dirs] = "${B}"
626
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500627addtask strip before do_sizecheck after do_kernel_link_images
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500628
629# Support checking the kernel size since some kernels need to reside in partitions
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500630# with a fixed length or there is a limit in transferring the kernel to memory.
631# If more than one image type is enabled, warn on any that don't fit but only fail
632# if none fit.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500633do_sizecheck() {
634 if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
635 invalid=`echo ${KERNEL_IMAGE_MAXSIZE} | sed 's/[0-9]//g'`
636 if [ -n "$invalid" ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500637 die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integer (The unit is Kbytes)"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500638 fi
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500639 at_least_one_fits=
He Zhefe76b1e2016-05-25 04:47:16 -0400640 for type in ${KERNEL_IMAGETYPES} ; do
641 size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$type | awk '{print $1}'`
642 if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500643 bbwarn "This kernel $type (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device."
644 else
645 at_least_one_fits=y
He Zhefe76b1e2016-05-25 04:47:16 -0400646 fi
647 done
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500648 if [ -z "$at_least_one_fits" ]; then
649 die "All kernel images are too big for your device. Please reduce the size of the kernel by making more of it modular."
650 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500651 fi
652}
653do_sizecheck[dirs] = "${B}"
654
655addtask sizecheck before do_install after do_strip
656
He Zhefe76b1e2016-05-25 04:47:16 -0400657KERNEL_IMAGE_BASE_NAME ?= "${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500658# Don't include the DATETIME variable in the sstate package signatures
659KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
He Zhefe76b1e2016-05-25 04:47:16 -0400660KERNEL_IMAGE_SYMLINK_NAME ?= "${MACHINE}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500661MODULE_IMAGE_BASE_NAME ?= "modules-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
662MODULE_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
663MODULE_TARBALL_BASE_NAME ?= "${MODULE_IMAGE_BASE_NAME}.tgz"
664# Don't include the DATETIME variable in the sstate package signatures
665MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
666MODULE_TARBALL_DEPLOY ?= "1"
667
668kernel_do_deploy() {
Brad Bishop316dfdd2018-06-25 12:45:53 -0400669 deployDir="${DEPLOYDIR}"
670 if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
671 deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
672 mkdir "$deployDir"
673 fi
674
He Zhefe76b1e2016-05-25 04:47:16 -0400675 for type in ${KERNEL_IMAGETYPES} ; do
676 base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400677 install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} $deployDir/${base_name}.bin
He Zhefe76b1e2016-05-25 04:47:16 -0400678 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500679 if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
680 mkdir -p ${D}/lib
Brad Bishop316dfdd2018-06-25 12:45:53 -0400681 tar -cvzf $deployDir/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
682 ln -sf ${MODULE_TARBALL_BASE_NAME} $deployDir/${MODULE_TARBALL_SYMLINK_NAME}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500683 fi
684
He Zhefe76b1e2016-05-25 04:47:16 -0400685 for type in ${KERNEL_IMAGETYPES} ; do
686 base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
687 symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400688 ln -sf ${base_name}.bin $deployDir/${symlink_name}.bin
689 ln -sf ${base_name}.bin $deployDir/${type}
He Zhefe76b1e2016-05-25 04:47:16 -0400690 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500691
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500692 cd ${B}
693 # Update deploy directory
He Zhefe76b1e2016-05-25 04:47:16 -0400694 for type in ${KERNEL_IMAGETYPES} ; do
695 if [ -e "${KERNEL_OUTPUT_DIR}/${type}.initramfs" ]; then
696 echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
697 initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
698 initramfs_symlink_name=${type}-initramfs-${MACHINE}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400699 install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs $deployDir/${initramfs_base_name}.bin
700 ln -sf ${initramfs_base_name}.bin $deployDir/${initramfs_symlink_name}.bin
He Zhefe76b1e2016-05-25 04:47:16 -0400701 fi
702 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500703}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500704do_deploy[cleandirs] = "${DEPLOYDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500705do_deploy[dirs] = "${DEPLOYDIR} ${B}"
706do_deploy[prefuncs] += "package_get_auto_pr"
707
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500708addtask deploy after do_populate_sysroot do_packagedata
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500709
710EXPORT_FUNCTIONS do_deploy
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500711
712# Add using Device Tree support
713inherit kernel-devicetree