blob: 9c8036f4df015332a7c3fb652de4d005a3153ae0 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit linux-kernel-base kernel-module-split
8
9COMPATIBLE_HOST = ".*-linux"
10
11KERNEL_PACKAGE_NAME ??= "kernel"
12KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"
13
14PROVIDES += "virtual/kernel"
15DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native bison-native"
16DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lzo", "lzop-native", "", d)}"
17DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lz4", "lz4-native", "", d)}"
18DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.zst", "zstd-native", "", d)}"
19PACKAGE_WRITE_DEPS += "depmodwrapper-cross"
20
21do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot gzip-native:do_populate_sysroot"
22do_clean[depends] += "make-mod-scripts:do_clean"
23
24CVE_PRODUCT ?= "linux_kernel"
25
26S = "${STAGING_KERNEL_DIR}"
27B = "${WORKDIR}/build"
28KBUILD_OUTPUT = "${B}"
29OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT"
30
31# we include gcc above, we dont need virtual/libc
32INHIBIT_DEFAULT_DEPS = "1"
33
34KERNEL_IMAGETYPE ?= "zImage"
35INITRAMFS_IMAGE ?= ""
Patrick Williams92b42cb2022-09-03 06:53:57 -050036INITRAMFS_TASK ?= ""
37INITRAMFS_IMAGE_BUNDLE ?= ""
38INITRAMFS_DEPLOY_DIR_IMAGE ?= "${DEPLOY_DIR_IMAGE}"
39INITRAMFS_MULTICONFIG ?= ""
40
41# KERNEL_VERSION is extracted from source code. It is evaluated as
42# None for the first parsing, since the code has not been fetched.
43# After the code is fetched, it will be evaluated as real version
44# number and cause kernel to be rebuilt. To avoid this, make
45# KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on
46# LINUX_VERSION which is a constant.
47KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or ""}"
48KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}"
49KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}"
50KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
51
52python __anonymous () {
53 pn = d.getVar("PN")
54 kpn = d.getVar("KERNEL_PACKAGE_NAME")
55
56 # XXX Remove this after bug 11905 is resolved
57 # FILES:${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly
58 if kpn == pn:
59 bb.warn("Some packages (E.g. *-dev) might be missing due to "
60 "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)")
61
62 # The default kernel recipe builds in a shared location defined by
63 # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR.
64 # Set these variables to directories under ${WORKDIR} in alternate
65 # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they
66 # may build in parallel with the default kernel without clobbering.
67 if kpn != "kernel":
68 workdir = d.getVar("WORKDIR")
69 sourceDir = os.path.join(workdir, 'kernel-source')
70 artifactsDir = os.path.join(workdir, 'kernel-build-artifacts')
71 d.setVar("STAGING_KERNEL_DIR", sourceDir)
72 d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir)
73
74 # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
75 type = d.getVar('KERNEL_IMAGETYPE') or ""
76 alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
77 types = d.getVar('KERNEL_IMAGETYPES') or ""
78 if type not in types.split():
79 types = (type + ' ' + types).strip()
80 if alttype not in types.split():
81 types = (alttype + ' ' + types).strip()
82 d.setVar('KERNEL_IMAGETYPES', types)
83
84 # KERNEL_IMAGETYPES may contain a mixture of image types supported directly
85 # by the kernel build system and types which are created by post-processing
86 # the output of the kernel build system (e.g. compressing vmlinux ->
87 # vmlinux.gz in kernel_do_transform_kernel()).
88 # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported
89 # directly by the kernel build system.
90 if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'):
91 typeformake = set()
92 for type in types.split():
93 if type == 'vmlinux.gz':
94 type = 'vmlinux'
95 typeformake.add(type)
96
97 d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', ' '.join(sorted(typeformake)))
98
99 kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel"
100 imagedest = d.getVar('KERNEL_IMAGEDEST')
101
102 for type in types.split():
103 if bb.data.inherits_class('nopackages', d):
104 continue
105 typelower = type.lower()
106 d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
107 d.setVar('FILES:' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
108 d.appendVar('RDEPENDS:%s-image' % kname, ' %s-image-%s (= ${EXTENDPKGV})' % (kname, typelower))
109 splitmods = d.getVar("KERNEL_SPLIT_MODULES")
110 if splitmods != '1':
111 d.appendVar('RDEPENDS:%s-image' % kname, ' %s-modules (= ${EXTENDPKGV})' % kname)
112 d.appendVar('RDEPENDS:%s-image-%s' % (kname, typelower), ' %s-modules-${KERNEL_VERSION_PKG_NAME} (= ${EXTENDPKGV})' % kname)
113 d.setVar('PKG:%s-modules' % kname, '%s-modules-${KERNEL_VERSION_PKG_NAME}' % kname)
114 d.appendVar('RPROVIDES:%s-modules' % kname, '%s-modules-${KERNEL_VERSION_PKG_NAME}' % kname)
115
116 d.setVar('PKG:%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower))
117 d.setVar('ALLOW_EMPTY:%s-image-%s' % (kname, typelower), '1')
118 d.prependVar('pkg_postinst:%s-image-%s' % (kname,typelower), """set +e
119if [ -n "$D" ]; then
120 ln -sf %s-${KERNEL_VERSION} $D/${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1
121else
122 ln -sf %s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1
123 if [ $? -ne 0 ]; then
124 echo "Filesystem on ${KERNEL_IMAGEDEST}/ doesn't support symlinks, falling back to copied image (%s)."
125 install -m 0644 ${KERNEL_IMAGEDEST}/%s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s
126 fi
127fi
128set -e
129""" % (type, type, type, type, type, type, type))
130 d.setVar('pkg_postrm:%s-image-%s' % (kname,typelower), """set +e
131if [ -f "${KERNEL_IMAGEDEST}/%s" -o -L "${KERNEL_IMAGEDEST}/%s" ]; then
132 rm -f ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1
133fi
134set -e
135""" % (type, type, type))
136
137
138 image = d.getVar('INITRAMFS_IMAGE')
139 # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0,
140 # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built
141 # standalone for use by wic and other tools.
142 if image:
143 if d.getVar('INITRAMFS_MULTICONFIG'):
144 d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc::${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete')
145 else:
146 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
147 if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')):
148 bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
149
150 # NOTE: setting INITRAMFS_TASK is for backward compatibility
151 # The preferred method is to set INITRAMFS_IMAGE, because
152 # this INITRAMFS_TASK has circular dependency problems
153 # if the initramfs requires kernel modules
154 image_task = d.getVar('INITRAMFS_TASK')
155 if image_task:
156 d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
157}
158
159# Here we pull in all various kernel image types which we support.
160#
161# In case you're wondering why kernel.bbclass inherits the other image
162# types instead of the other way around, the reason for that is to
163# maintain compatibility with various currently existing meta-layers.
164# By pulling in the various kernel image types here, we retain the
165# original behavior of kernel.bbclass, so no meta-layers should get
166# broken.
167#
168# KERNEL_CLASSES by default pulls in kernel-uimage.bbclass, since this
169# used to be the default behavior when only uImage was supported. This
170# variable can be appended by users who implement support for new kernel
171# image types.
172
173KERNEL_CLASSES ?= " kernel-uimage "
174inherit ${KERNEL_CLASSES}
175
176# Old style kernels may set ${S} = ${WORKDIR}/git for example
177# We need to move these over to STAGING_KERNEL_DIR. We can't just
178# create the symlink in advance as the git fetcher can't cope with
179# the symlink.
180do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
181do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
182python do_symlink_kernsrc () {
183 s = d.getVar("S")
184 if s[-1] == '/':
185 # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as directory name and fail
186 s=s[:-1]
187 kernsrc = d.getVar("STAGING_KERNEL_DIR")
188 if s != kernsrc:
189 bb.utils.mkdirhier(kernsrc)
190 bb.utils.remove(kernsrc, recurse=True)
191 if d.getVar("EXTERNALSRC"):
192 # With EXTERNALSRC S will not be wiped so we can symlink to it
193 os.symlink(s, kernsrc)
194 else:
195 import shutil
196 shutil.move(s, kernsrc)
197 os.symlink(kernsrc, s)
198}
199# do_patch is normally ordered before do_configure, but
200# externalsrc.bbclass deletes do_patch, breaking the dependency of
201# do_configure on do_symlink_kernsrc.
202addtask symlink_kernsrc before do_patch do_configure after do_unpack
203
204inherit kernel-arch deploy
205
206PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
207PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*"
208PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*"
209
210export OS = "${TARGET_OS}"
211export CROSS_COMPILE = "${TARGET_PREFIX}"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500212
213KERNEL_RELEASE ?= "${KERNEL_VERSION}"
214
215# The directory where built kernel lies in the kernel tree
216KERNEL_OUTPUT_DIR ?= "arch/${ARCH}/boot"
217KERNEL_IMAGEDEST ?= "boot"
Andrew Geissler028142b2023-05-05 11:29:21 -0500218KERNEL_DTBDEST ?= "${KERNEL_IMAGEDEST}"
Patrick Williamse760df82023-05-26 11:10:49 -0500219KERNEL_DTBVENDORED ?= "0"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500220
221#
222# configuration
223#
224export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE") or "ttyS0"}"
225
226KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"
227
228# kernels are generally machine specific
229PACKAGE_ARCH = "${MACHINE_ARCH}"
230
231# U-Boot support
232UBOOT_ENTRYPOINT ?= "20008000"
233UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
234
235# Some Linux kernel configurations need additional parameters on the command line
236KERNEL_EXTRA_ARGS ?= ""
237
Andrew Geissler6aa7eec2023-03-03 12:41:14 -0600238EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}"'
Patrick Williams92b42cb2022-09-03 06:53:57 -0500239EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"'
Patrick Williamsb542dec2023-06-09 01:26:37 -0500240EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}"'
Patrick Williams92b42cb2022-09-03 06:53:57 -0500241
242KERNEL_ALT_IMAGETYPE ??= ""
243
244copy_initramfs() {
245 echo "Copying initramfs into ./usr ..."
246 # In case the directory is not created yet from the first pass compile:
247 mkdir -p ${B}/usr
248 # Find and use the first initramfs image archive type we find
249 rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
250 for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst; do
251 if [ -e "${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then
252 cp ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/.
253 case $img in
254 *gz)
255 echo "gzip decompressing image"
256 gunzip -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
257 break
258 ;;
259 *lz4)
260 echo "lz4 decompressing image"
261 lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
262 break
263 ;;
264 *lzo)
265 echo "lzo decompressing image"
266 lzop -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
267 break
268 ;;
269 *lzma)
270 echo "lzma decompressing image"
271 lzma -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
272 break
273 ;;
274 *xz)
275 echo "xz decompressing image"
276 xz -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
277 break
278 ;;
279 *zst)
280 echo "zst decompressing image"
281 zstd -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
282 break
283 ;;
284 esac
285 break
286 fi
287 done
288 # Verify that the above loop found a initramfs, fail otherwise
289 [ -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio ] && echo "Finished copy of initramfs into ./usr" || die "Could not find any ${INITRAMFS_DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio{.gz|.lz4|.lzo|.lzma|.xz|.zst) for bundling; INITRAMFS_IMAGE_NAME might be wrong."
290}
291
292do_bundle_initramfs () {
293 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
294 echo "Creating a kernel image with a bundled initramfs..."
295 copy_initramfs
296 # Backing up kernel image relies on its type(regular file or symbolic link)
297 tmp_path=""
298 for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
299 if [ -h ${KERNEL_OUTPUT_DIR}/$imageType ] ; then
300 linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$imageType`
301 realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$imageType`
302 mv -f $realpath $realpath.bak
303 tmp_path=$tmp_path" "$imageType"#"$linkpath"#"$realpath
304 elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then
305 mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.bak
306 tmp_path=$tmp_path" "$imageType"##"
307 fi
308 done
309 use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
310 kernel_do_compile
311 # Restoring kernel image
312 for tp in $tmp_path ; do
313 imageType=`echo $tp|cut -d "#" -f 1`
314 linkpath=`echo $tp|cut -d "#" -f 2`
315 realpath=`echo $tp|cut -d "#" -f 3`
316 if [ -n "$realpath" ]; then
317 mv -f $realpath $realpath.initramfs
318 mv -f $realpath.bak $realpath
319 ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs
320 else
321 mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.initramfs
322 mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak ${KERNEL_OUTPUT_DIR}/$imageType
323 fi
324 done
325 fi
326}
327do_bundle_initramfs[dirs] = "${B}"
328
329kernel_do_transform_bundled_initramfs() {
330 # vmlinux.gz is not built by kernel
331 if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
332 gzip -9cn < ${KERNEL_OUTPUT_DIR}/vmlinux.initramfs > ${KERNEL_OUTPUT_DIR}/vmlinux.gz.initramfs
333 fi
334}
335do_transform_bundled_initramfs[dirs] = "${B}"
336
337python do_devshell:prepend () {
338 os.environ["LDFLAGS"] = ''
339}
340
341addtask bundle_initramfs after do_install before do_deploy
342
343KERNEL_DEBUG_TIMESTAMPS ??= "0"
344
345kernel_do_compile() {
346 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
347
348 # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native)
349 export PKG_CONFIG_DIR="${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig"
350 export PKG_CONFIG_PATH="$PKG_CONFIG_DIR:${STAGING_DATADIR_NATIVE}/pkgconfig"
351 export PKG_CONFIG_LIBDIR="$PKG_CONFIG_DIR"
352 export PKG_CONFIG_SYSROOT_DIR=""
353
354 if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
355 # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
356 # be set....
357 if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = "0" ]; then
358 # The source directory is not necessarily a git repository, so we
359 # specify the git-dir to ensure that git does not query a
360 # repository in any parent directory.
361 SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"`
362 fi
363
364 ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH`
365 export KBUILD_BUILD_TIMESTAMP="$ts"
366 export KCONFIG_NOTIMESTAMP=1
367 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
Andrew Geissler517393d2023-01-13 08:55:19 -0600368 else
369 ts=`LC_ALL=C date`
370 export KBUILD_BUILD_TIMESTAMP="$ts"
371 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500372 fi
373 # The $use_alternate_initrd is only set from
374 # do_bundle_initramfs() This variable is specifically for the
375 # case where we are making a second pass at the kernel
376 # compilation and we want to force the kernel build to use a
377 # different initramfs image. The way to do that in the kernel
378 # is to specify:
379 # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
380 if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then
381 # The old style way of copying an prebuilt image and building it
382 # is turned on via INTIRAMFS_TASK != ""
383 copy_initramfs
384 use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
385 fi
386 for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500387 oe_runmake ${PARALLEL_MAKE} ${typeformake} ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
Patrick Williams92b42cb2022-09-03 06:53:57 -0500388 done
389}
390
391kernel_do_transform_kernel() {
392 # vmlinux.gz is not built by kernel
393 if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
394 mkdir -p "${KERNEL_OUTPUT_DIR}"
395 gzip -9cn < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz"
396 fi
397}
398do_transform_kernel[dirs] = "${B}"
399addtask transform_kernel after do_compile before do_install
400
401do_compile_kernelmodules() {
402 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
403 if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then
404 # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not
405 # be set....
406 if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = "0" ]; then
407 # The source directory is not necessarily a git repository, so we
408 # specify the git-dir to ensure that git does not query a
409 # repository in any parent directory.
410 SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"`
411 fi
412
413 ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH`
414 export KBUILD_BUILD_TIMESTAMP="$ts"
415 export KCONFIG_NOTIMESTAMP=1
416 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
Andrew Geissler517393d2023-01-13 08:55:19 -0600417 else
418 ts=`LC_ALL=C date`
419 export KBUILD_BUILD_TIMESTAMP="$ts"
420 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500421 fi
422 if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then
423 oe_runmake -C ${B} ${PARALLEL_MAKE} modules ${KERNEL_EXTRA_ARGS}
424
425 # Module.symvers gets updated during the
426 # building of the kernel modules. We need to
427 # update this in the shared workdir since some
428 # external kernel modules has a dependency on
429 # other kernel modules and will look at this
430 # file to do symbol lookups
431 cp ${B}/Module.symvers ${STAGING_KERNEL_BUILDDIR}/
432 # 5.10+ kernels have module.lds that we need to copy for external module builds
433 if [ -e "${B}/scripts/module.lds" ]; then
434 install -Dm 0644 ${B}/scripts/module.lds ${STAGING_KERNEL_BUILDDIR}/scripts/module.lds
435 fi
436 else
437 bbnote "no modules to compile"
438 fi
439}
440addtask compile_kernelmodules after do_compile before do_strip
441
442kernel_do_install() {
443 #
444 # First install the modules
445 #
446 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
447 if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
448 oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install
449 rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
450 rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
Andrew Geissler517393d2023-01-13 08:55:19 -0600451 # Remove empty module directories to prevent QA issues
452 find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete
Patrick Williams92b42cb2022-09-03 06:53:57 -0500453 else
454 bbnote "no modules to install"
455 fi
456
457 #
458 # Install various kernel output (zImage, map file, config, module support files)
459 #
460 install -d ${D}/${KERNEL_IMAGEDEST}
461
462 #
463 # When including an initramfs bundle inside a FIT image, the fitImage is created after the install task
464 # by do_assemble_fitimage_initramfs.
465 # This happens after the generation of the initramfs bundle (done by do_bundle_initramfs).
466 # So, at the level of the install task we should not try to install the fitImage. fitImage is still not
467 # generated yet.
468 # After the generation of the fitImage, the deploy task copies the fitImage from the build directory to
469 # the deploy folder.
470 #
471
472 for imageType in ${KERNEL_IMAGETYPES} ; do
473 if [ $imageType != "fitImage" ] || [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ] ; then
474 install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType ${D}/${KERNEL_IMAGEDEST}/$imageType-${KERNEL_VERSION}
475 fi
476 done
477
478 install -m 0644 System.map ${D}/${KERNEL_IMAGEDEST}/System.map-${KERNEL_VERSION}
479 install -m 0644 .config ${D}/${KERNEL_IMAGEDEST}/config-${KERNEL_VERSION}
480 install -m 0644 vmlinux ${D}/${KERNEL_IMAGEDEST}/vmlinux-${KERNEL_VERSION}
481 [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/${KERNEL_IMAGEDEST}/Module.symvers-${KERNEL_VERSION}
482 install -d ${D}${sysconfdir}/modules-load.d
483 install -d ${D}${sysconfdir}/modprobe.d
484}
485
486# Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile
487do_kernel_version_sanity_check() {
488 if [ "x${KERNEL_VERSION_SANITY_SKIP}" = "x1" ]; then
489 exit 0
490 fi
491
492 # The Makefile determines the kernel version shown at runtime
493 # Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile
494 VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//)
495 PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
496 SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
497 EXTRAVERSION=$(grep "^EXTRAVERSION =" ${S}/Makefile | sed s/.*=\ *//)
498
499 # Build a string for regex and a plain version string
500 reg="^${VERSION}\.${PATCHLEVEL}"
501 vers="${VERSION}.${PATCHLEVEL}"
502 if [ -n "${SUBLEVEL}" ]; then
503 # Ignoring a SUBLEVEL of zero is fine
504 if [ "${SUBLEVEL}" = "0" ]; then
505 reg="${reg}(\.${SUBLEVEL})?"
506 else
507 reg="${reg}\.${SUBLEVEL}"
508 vers="${vers}.${SUBLEVEL}"
509 fi
510 fi
511 vers="${vers}${EXTRAVERSION}"
512 reg="${reg}${EXTRAVERSION}"
513
514 if [ -z `echo ${PV} | grep -E "${reg}"` ]; then
515 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."
516 fi
517 exit 0
518}
519
520addtask shared_workdir after do_compile before do_compile_kernelmodules
521addtask shared_workdir_setscene
522
523do_shared_workdir_setscene () {
524 exit 1
525}
526
527emit_depmod_pkgdata() {
528 # Stash data for depmod
529 install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/
530 echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion
531 cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION}
532}
533
534PACKAGEFUNCS += "emit_depmod_pkgdata"
535
536do_shared_workdir[cleandirs] += " ${STAGING_KERNEL_BUILDDIR}"
537do_shared_workdir () {
538 cd ${B}
539
540 kerneldir=${STAGING_KERNEL_BUILDDIR}
541 install -d $kerneldir
542
543 #
544 # Store the kernel version in sysroots for module-base.bbclass
545 #
546
547 echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion
548
549 # Copy files required for module builds
550 cp System.map $kerneldir/System.map-${KERNEL_VERSION}
551 [ -e Module.symvers ] && cp Module.symvers $kerneldir/
552 cp .config $kerneldir/
553 mkdir -p $kerneldir/include/config
554 cp include/config/kernel.release $kerneldir/include/config/kernel.release
555 if [ -e certs/signing_key.x509 ]; then
556 # The signing_key.* files are stored in the certs/ dir in
557 # newer Linux kernels
558 mkdir -p $kerneldir/certs
559 cp certs/signing_key.* $kerneldir/certs/
560 elif [ -e signing_key.priv ]; then
561 cp signing_key.* $kerneldir/
562 fi
563
564 # We can also copy over all the generated files and avoid special cases
565 # like version.h, but we've opted to keep this small until file creep starts
566 # to happen
567 if [ -e include/linux/version.h ]; then
568 mkdir -p $kerneldir/include/linux
569 cp include/linux/version.h $kerneldir/include/linux/version.h
570 fi
571
572 # As of Linux kernel version 3.0.1, the clean target removes
573 # arch/powerpc/lib/crtsavres.o which is present in
574 # KBUILD_LDFLAGS_MODULE, making it required to build external modules.
575 if [ ${ARCH} = "powerpc" ]; then
576 if [ -e arch/powerpc/lib/crtsavres.o ]; then
577 mkdir -p $kerneldir/arch/powerpc/lib/
578 cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
579 fi
580 fi
581
582 if [ -d include/generated ]; then
583 mkdir -p $kerneldir/include/generated/
584 cp -fR include/generated/* $kerneldir/include/generated/
585 fi
586
587 if [ -d arch/${ARCH}/include/generated ]; then
588 mkdir -p $kerneldir/arch/${ARCH}/include/generated/
589 cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/
590 fi
591
592 if (grep -q -i -e '^CONFIG_UNWINDER_ORC=y$' $kerneldir/.config); then
593 # With CONFIG_UNWINDER_ORC (the default in 4.14), objtool is required for
594 # out-of-tree modules to be able to generate object files.
595 if [ -x tools/objtool/objtool ]; then
596 mkdir -p ${kerneldir}/tools/objtool
597 cp tools/objtool/objtool ${kerneldir}/tools/objtool/
598 fi
599 fi
Patrick Williams7784c422022-11-17 07:29:11 -0600600
601 # When building with CONFIG_MODVERSIONS=y and CONFIG_RANDSTRUCT=y we need
602 # to copy the build assets generated for the randstruct seed to
603 # STAGING_KERNEL_BUILDDIR, otherwise the out-of-tree modules build will
604 # generate those assets which will result in a different
605 # RANDSTRUCT_HASHED_SEED
606 if [ -d scripts/basic ]; then
607 mkdir -p ${kerneldir}/scripts
608 cp -r scripts/basic ${kerneldir}/scripts
609 fi
610
611 if [ -d scripts/gcc-plugins ]; then
612 mkdir -p ${kerneldir}/scripts
613 cp -r scripts/gcc-plugins ${kerneldir}/scripts
614 fi
615
Patrick Williams92b42cb2022-09-03 06:53:57 -0500616}
617
618# We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware
Patrick Williams2390b1b2022-11-03 13:47:49 -0500619SYSROOT_DIRS = ""
Patrick Williams92b42cb2022-09-03 06:53:57 -0500620
Patrick Williamsb542dec2023-06-09 01:26:37 -0500621KERNEL_LOCALVERSION ??= ""
Patrick Williams92b42cb2022-09-03 06:53:57 -0500622KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} olddefconfig || oe_runmake -C ${S} O=${B} oldnoconfig"
623
624python check_oldest_kernel() {
625 oldest_kernel = d.getVar('OLDEST_KERNEL')
626 kernel_version = d.getVar('KERNEL_VERSION')
627 tclibc = d.getVar('TCLIBC')
628 if tclibc == 'glibc':
629 kernel_version = kernel_version.split('-', 1)[0]
630 if oldest_kernel and kernel_version:
631 if bb.utils.vercmp_string(kernel_version, oldest_kernel) < 0:
632 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))
633}
634
635check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION"
636do_configure[prefuncs] += "check_oldest_kernel"
637
638kernel_do_configure() {
639 # fixes extra + in /lib/modules/2.6.37+
640 # $ scripts/setlocalversion . => +
641 # $ make kernelversion => 2.6.37
642 # $ make kernelrelease => 2.6.37+
Patrick Williamsb542dec2023-06-09 01:26:37 -0500643 if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]; then
644 echo ${KERNEL_LOCALVERSION} > ${B}/.scmversion
645 echo ${KERNEL_LOCALVERSION} > ${S}/.scmversion
646 fi
Patrick Williams92b42cb2022-09-03 06:53:57 -0500647
648 if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then
649 mv "${S}/.config" "${B}/.config"
650 fi
651
652 # Copy defconfig to .config if .config does not exist. This allows
653 # recipes to manage the .config themselves in do_configure:prepend().
654 if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
655 cp "${WORKDIR}/defconfig" "${B}/.config"
656 fi
657
658 ${KERNEL_CONFIG_COMMAND}
659}
660
661do_savedefconfig() {
662 bbplain "Saving defconfig to:\n${B}/defconfig"
663 oe_runmake -C ${B} savedefconfig
664}
665do_savedefconfig[nostamp] = "1"
666addtask savedefconfig after do_configure
667
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500668inherit cml1 pkgconfig
Patrick Williams92b42cb2022-09-03 06:53:57 -0500669
670# Need LD, HOSTLDFLAGS and more for config operations
671KCONFIG_CONFIG_COMMAND:append = " ${EXTRA_OEMAKE}"
672
673EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs do_install do_configure
674
675# kernel-base becomes kernel-${KERNEL_VERSION}
676# kernel-image becomes kernel-image-${KERNEL_VERSION}
677PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules ${KERNEL_PACKAGE_NAME}-dbg"
678FILES:${PN} = ""
679FILES:${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin.modinfo"
680FILES:${KERNEL_PACKAGE_NAME}-image = ""
681FILES:${KERNEL_PACKAGE_NAME}-dev = "/${KERNEL_IMAGEDEST}/System.map* /${KERNEL_IMAGEDEST}/Module.symvers* /${KERNEL_IMAGEDEST}/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
682FILES:${KERNEL_PACKAGE_NAME}-vmlinux = "/${KERNEL_IMAGEDEST}/vmlinux-${KERNEL_VERSION_NAME}"
683FILES:${KERNEL_PACKAGE_NAME}-modules = ""
684FILES:${KERNEL_PACKAGE_NAME}-dbg = "/usr/lib/debug /usr/src/debug"
685RDEPENDS:${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base (= ${EXTENDPKGV})"
686# Allow machines to override this dependency if kernel image files are
687# not wanted in images as standard
688RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image (= ${EXTENDPKGV})"
689PKG:${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}"
690RDEPENDS:${KERNEL_PACKAGE_NAME}-image += "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux (= ${EXTENDPKGV})', '', d)}"
691PKG:${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}"
692RPROVIDES:${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}"
693ALLOW_EMPTY:${KERNEL_PACKAGE_NAME} = "1"
694ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-base = "1"
695ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-image = "1"
696ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-modules = "1"
697DESCRIPTION:${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package"
698
699pkg_postinst:${KERNEL_PACKAGE_NAME}-base () {
700 if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
701 mkdir -p $D/lib/modules/${KERNEL_VERSION}
702 fi
703 if [ -n "$D" ]; then
Andrew Geissler87f5cff2022-09-30 13:13:31 -0500704 depmodwrapper -a -b $D ${KERNEL_VERSION} ${KERNEL_PACKAGE_NAME}
Patrick Williams92b42cb2022-09-03 06:53:57 -0500705 else
706 depmod -a ${KERNEL_VERSION}
707 fi
708}
709
Andrew Geissler517393d2023-01-13 08:55:19 -0600710PACKAGESPLITFUNCS =+ "split_kernel_packages"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500711
712python split_kernel_packages () {
713 do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex=r'^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
714}
715
716# Many scripts want to look in arch/$arch/boot for the bootable
717# image. This poses a problem for vmlinux and vmlinuz based
718# booting. This task arranges to have vmlinux and vmlinuz appear
719# in the normalized directory location.
720do_kernel_link_images() {
721 if [ ! -d "${B}/arch/${ARCH}/boot" ]; then
722 mkdir ${B}/arch/${ARCH}/boot
723 fi
724 cd ${B}/arch/${ARCH}/boot
725 ln -sf ../../../vmlinux
726 if [ -f ../../../vmlinuz ]; then
727 ln -sf ../../../vmlinuz
728 fi
729 if [ -f ../../../vmlinuz.bin ]; then
730 ln -sf ../../../vmlinuz.bin
731 fi
732 if [ -f ../../../vmlinux.64 ]; then
733 ln -sf ../../../vmlinux.64
734 fi
735}
736addtask kernel_link_images after do_compile before do_strip
737
738python do_strip() {
739 import shutil
740
741 strip = d.getVar('STRIP')
742 extra_sections = d.getVar('KERNEL_IMAGE_STRIP_EXTRA_SECTIONS')
743 kernel_image = d.getVar('B') + "/" + d.getVar('KERNEL_OUTPUT_DIR') + "/vmlinux"
744
745 if (extra_sections and kernel_image.find(d.getVar('KERNEL_IMAGEDEST') + '/vmlinux') != -1):
746 kernel_image_stripped = kernel_image + ".stripped"
747 shutil.copy2(kernel_image, kernel_image_stripped)
748 oe.package.runstrip((kernel_image_stripped, 8, strip, extra_sections))
749 bb.debug(1, "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections: " + \
750 extra_sections)
751}
752do_strip[dirs] = "${B}"
753
754addtask strip before do_sizecheck after do_kernel_link_images
755
756# Support checking the kernel size since some kernels need to reside in partitions
757# with a fixed length or there is a limit in transferring the kernel to memory.
758# If more than one image type is enabled, warn on any that don't fit but only fail
759# if none fit.
760do_sizecheck() {
761 if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
762 invalid=`echo ${KERNEL_IMAGE_MAXSIZE} | sed 's/[0-9]//g'`
763 if [ -n "$invalid" ]; then
764 die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integer (The unit is Kbytes)"
765 fi
766 at_least_one_fits=
767 for imageType in ${KERNEL_IMAGETYPES} ; do
768 size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$imageType | awk '{print $1}'`
769 if [ $size -gt ${KERNEL_IMAGE_MAXSIZE} ]; then
770 bbwarn "This kernel $imageType (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device."
771 else
772 at_least_one_fits=y
773 fi
774 done
775 if [ -z "$at_least_one_fits" ]; then
776 die "All kernel images are too big for your device. Please reduce the size of the kernel by making more of it modular."
777 fi
778 fi
779}
780do_sizecheck[dirs] = "${B}"
781
782addtask sizecheck before do_install after do_strip
783
784inherit kernel-artifact-names
785
786kernel_do_deploy() {
787 deployDir="${DEPLOYDIR}"
788 if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then
789 deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}"
790 mkdir "$deployDir"
791 fi
792
793 for imageType in ${KERNEL_IMAGETYPES} ; do
794 baseName=$imageType-${KERNEL_IMAGE_NAME}
795
796 if [ -s ${KERNEL_OUTPUT_DIR}/$imageType.stripped ] ; then
797 install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.stripped $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT}
798 else
799 install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName${KERNEL_IMAGE_BIN_EXT}
800 fi
801 if [ -n "${KERNEL_IMAGE_LINK_NAME}" ] ; then
802 ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT}
803 fi
804 if [ "${KERNEL_IMAGETYPE_SYMLINK}" = "1" ] ; then
805 ln -sf $baseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType
806 fi
807 done
808
809 if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
810 mkdir -p ${D}${root_prefix}/lib
811 if [ -n "${SOURCE_DATE_EPOCH}" ]; then
812 TAR_ARGS="--sort=name --clamp-mtime --mtime=@${SOURCE_DATE_EPOCH}"
813 else
814 TAR_ARGS=""
815 fi
816 TAR_ARGS="$TAR_ARGS --owner=0 --group=0"
817 tar $TAR_ARGS -cv -C ${D}${root_prefix} lib | gzip -9n > $deployDir/modules-${MODULE_TARBALL_NAME}.tgz
818
819 if [ -n "${MODULE_TARBALL_LINK_NAME}" ] ; then
820 ln -sf modules-${MODULE_TARBALL_NAME}.tgz $deployDir/modules-${MODULE_TARBALL_LINK_NAME}.tgz
821 fi
822 fi
823
824 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
825 for imageType in ${KERNEL_IMAGETYPES} ; do
826 if [ "$imageType" = "fitImage" ] ; then
827 continue
828 fi
829 initramfsBaseName=$imageType-${INITRAMFS_NAME}
830 install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfsBaseName${KERNEL_IMAGE_BIN_EXT}
831 if [ -n "${INITRAMFS_LINK_NAME}" ] ; then
832 ln -sf $initramfsBaseName${KERNEL_IMAGE_BIN_EXT} $deployDir/$imageType-${INITRAMFS_LINK_NAME}${KERNEL_IMAGE_BIN_EXT}
833 fi
834 done
835 fi
836}
837
838# We deploy to filenames that include PKGV and PKGR, read the saved data to
839# ensure we get the right values for both
840do_deploy[prefuncs] += "read_subpackage_metadata"
841
842addtask deploy after do_populate_sysroot do_packagedata
843
844EXPORT_FUNCTIONS do_deploy
845
846# Add using Device Tree support
847inherit kernel-devicetree