generic-poky/meta/classes/kernel.bbclass

645 lines
24 KiB
Plaintext
Raw Permalink Normal View History

inherit linux-kernel-base kernel-module-split
PROVIDES += "virtual/kernel"
DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native lzop-native"
PACKAGE_WRITE_DEPS += "depmodwrapper-cross virtual/update-alternatives-native"
do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot"
CVE_PRODUCT ?= "linux_kernel"
S = "${STAGING_KERNEL_DIR}"
B = "${WORKDIR}/build"
KBUILD_OUTPUT = "${B}"
OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT"
# we include gcc above, we dont need virtual/libc
INHIBIT_DEFAULT_DEPS = "1"
KERNEL_IMAGETYPE ?= "zImage"
kernel.bbclass: handle embedding of initramfs images * "All 2.6 Linux kernels contain a gzipped "cpio" format archive, which is * extracted into rootfs when the kernel boots up." * (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt) * * In some cases it can be useful to take advantage of this ability and embed your * customized rootfs ("the move to early userspace is necessary because finding * and mounting the real root device is complex"). * * Therefore, some code was added and since 2009 OpenEmbedded metadata * provides a convenient way to include your initramfs by setting * INITRAMFS_IMAGE = "your_initramfs_image.bb" * and specifying the chosen output format in the initramfs image recipe, e.g. * IMAGE_FSTYPES = "cpio.gz cpio.lzma" * * * Patch was imported from the OpenEmbedded git server * (git://git.openembedded.org/openembedded) * * Add satndalone task "builtin_initramfs". * commit 72761e468bb3e905459f2b81ce1bc4d80419481f * (From OE-Core rev: 19bda7f2c2dac6363468a49295c38f2095c67c98) Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'Remove usage of non-standard variables (DEPLOY_TO) and random renaming * of output.' * commit 456ba7ffd159821e86ad7ad4b66ec7d5790bd054 * Richard Purdie <rpurdie@rpsys.net> * * 'Fis typo in do_builtin_initramfs.' * commit 37f2fe4b801df832e93553a08eff24fec736c7d4 * Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'comment initramfs stuff till rootfs locking works properly (initramfs * should be optional as well)' * commit 2818d8b7be1a0d9a59ad3528091d47517d59328b * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'get initramfs stuff working * commit 1642b3e8fc81c666713951fdd4e7ff9a50d1c5a8 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'Fix INITRAMFS logic to stop breaking builds for people not using it' * commit dcf3049eb9eedf0838af59969b3f70a43298d3d7 * Signed-off-by: Richard Purdie <rpurdie@rpsys.net> * * '-change initramfs-logic' * commit 3e3f297457138e96e2b652658675796853eb0293 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'move initramfs stuff to configure so we can do postprocessing * on it with do_configure_append' * commit fc03e2be0b4470748a8b7707cea7293303adc424 * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'copy gz, lzo, lzma initramfs cpio images.' * commit 572abc3fdd1076ca35d8c15d269cc9d862101805 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * 'move the kernel size check to linux-kexecboot.inc.' * commit 45f82a941c77e9d747814fa1e337ba803475d327 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * Finally, two refinements as discussed on openembedded-core * mailing list: * - replace "if image != '' and image is not None:" with "if image" * - add cpio.xz support Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-07-11 22:33:11 +00:00
INITRAMFS_IMAGE ?= ""
INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"
kernel.bbclass: handle embedding of initramfs images * "All 2.6 Linux kernels contain a gzipped "cpio" format archive, which is * extracted into rootfs when the kernel boots up." * (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt) * * In some cases it can be useful to take advantage of this ability and embed your * customized rootfs ("the move to early userspace is necessary because finding * and mounting the real root device is complex"). * * Therefore, some code was added and since 2009 OpenEmbedded metadata * provides a convenient way to include your initramfs by setting * INITRAMFS_IMAGE = "your_initramfs_image.bb" * and specifying the chosen output format in the initramfs image recipe, e.g. * IMAGE_FSTYPES = "cpio.gz cpio.lzma" * * * Patch was imported from the OpenEmbedded git server * (git://git.openembedded.org/openembedded) * * Add satndalone task "builtin_initramfs". * commit 72761e468bb3e905459f2b81ce1bc4d80419481f * (From OE-Core rev: 19bda7f2c2dac6363468a49295c38f2095c67c98) Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'Remove usage of non-standard variables (DEPLOY_TO) and random renaming * of output.' * commit 456ba7ffd159821e86ad7ad4b66ec7d5790bd054 * Richard Purdie <rpurdie@rpsys.net> * * 'Fis typo in do_builtin_initramfs.' * commit 37f2fe4b801df832e93553a08eff24fec736c7d4 * Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'comment initramfs stuff till rootfs locking works properly (initramfs * should be optional as well)' * commit 2818d8b7be1a0d9a59ad3528091d47517d59328b * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'get initramfs stuff working * commit 1642b3e8fc81c666713951fdd4e7ff9a50d1c5a8 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'Fix INITRAMFS logic to stop breaking builds for people not using it' * commit dcf3049eb9eedf0838af59969b3f70a43298d3d7 * Signed-off-by: Richard Purdie <rpurdie@rpsys.net> * * '-change initramfs-logic' * commit 3e3f297457138e96e2b652658675796853eb0293 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'move initramfs stuff to configure so we can do postprocessing * on it with do_configure_append' * commit fc03e2be0b4470748a8b7707cea7293303adc424 * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'copy gz, lzo, lzma initramfs cpio images.' * commit 572abc3fdd1076ca35d8c15d269cc9d862101805 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * 'move the kernel size check to linux-kexecboot.inc.' * commit 45f82a941c77e9d747814fa1e337ba803475d327 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * Finally, two refinements as discussed on openembedded-core * mailing list: * - replace "if image != '' and image is not None:" with "if image" * - add cpio.xz support Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-07-11 22:33:11 +00:00
INITRAMFS_TASK ?= ""
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
INITRAMFS_IMAGE_BUNDLE ?= ""
# KERNEL_VERSION is extracted from source code. It is evaluated as
# None for the first parsing, since the code has not been fetched.
# After the code is fetched, it will be evaluated as real version
# number and cause kernel to be rebuilt. To avoid this, make
# KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on
# LINUX_VERSION which is a constant.
KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or ""}"
KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}"
KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}"
KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
python __anonymous () {
# Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES
type = d.getVar('KERNEL_IMAGETYPE') or ""
alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or ""
types = d.getVar('KERNEL_IMAGETYPES') or ""
if type not in types.split():
types = (type + ' ' + types).strip()
if alttype not in types.split():
types = (alttype + ' ' + types).strip()
d.setVar('KERNEL_IMAGETYPES', types)
# some commonly used kernel images aren't generated by the kernel build system, such as vmlinux.gz
# typeformake lists only valid kernel make targets, and post processing can be done after the kernel
# is built (such as using gzip to compress vmlinux)
typeformake = types.replace('vmlinux.gz', 'vmlinux')
d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake)
for type in types.split():
typelower = type.lower()
imagedest = d.getVar('KERNEL_IMAGEDEST')
d.appendVar('PACKAGES', ' ' + 'kernel-image-' + typelower)
d.setVar('FILES_kernel-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}')
d.appendVar('RDEPENDS_kernel-image', ' ' + 'kernel-image-' + typelower)
d.setVar('PKG_kernel-image-' + typelower, 'kernel-image-' + typelower + '-${KERNEL_VERSION_PKG_NAME}')
kernel.bbclass: handle embedding of initramfs images * "All 2.6 Linux kernels contain a gzipped "cpio" format archive, which is * extracted into rootfs when the kernel boots up." * (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt) * * In some cases it can be useful to take advantage of this ability and embed your * customized rootfs ("the move to early userspace is necessary because finding * and mounting the real root device is complex"). * * Therefore, some code was added and since 2009 OpenEmbedded metadata * provides a convenient way to include your initramfs by setting * INITRAMFS_IMAGE = "your_initramfs_image.bb" * and specifying the chosen output format in the initramfs image recipe, e.g. * IMAGE_FSTYPES = "cpio.gz cpio.lzma" * * * Patch was imported from the OpenEmbedded git server * (git://git.openembedded.org/openembedded) * * Add satndalone task "builtin_initramfs". * commit 72761e468bb3e905459f2b81ce1bc4d80419481f * (From OE-Core rev: 19bda7f2c2dac6363468a49295c38f2095c67c98) Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'Remove usage of non-standard variables (DEPLOY_TO) and random renaming * of output.' * commit 456ba7ffd159821e86ad7ad4b66ec7d5790bd054 * Richard Purdie <rpurdie@rpsys.net> * * 'Fis typo in do_builtin_initramfs.' * commit 37f2fe4b801df832e93553a08eff24fec736c7d4 * Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'comment initramfs stuff till rootfs locking works properly (initramfs * should be optional as well)' * commit 2818d8b7be1a0d9a59ad3528091d47517d59328b * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'get initramfs stuff working * commit 1642b3e8fc81c666713951fdd4e7ff9a50d1c5a8 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'Fix INITRAMFS logic to stop breaking builds for people not using it' * commit dcf3049eb9eedf0838af59969b3f70a43298d3d7 * Signed-off-by: Richard Purdie <rpurdie@rpsys.net> * * '-change initramfs-logic' * commit 3e3f297457138e96e2b652658675796853eb0293 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'move initramfs stuff to configure so we can do postprocessing * on it with do_configure_append' * commit fc03e2be0b4470748a8b7707cea7293303adc424 * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'copy gz, lzo, lzma initramfs cpio images.' * commit 572abc3fdd1076ca35d8c15d269cc9d862101805 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * 'move the kernel size check to linux-kexecboot.inc.' * commit 45f82a941c77e9d747814fa1e337ba803475d327 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * Finally, two refinements as discussed on openembedded-core * mailing list: * - replace "if image != '' and image is not None:" with "if image" * - add cpio.xz support Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-07-11 22:33:11 +00:00
d.setVar('ALLOW_EMPTY_kernel-image-' + typelower, '1')
priority = d.getVar('KERNEL_PRIORITY')
postinst = '#!/bin/sh\n' + 'update-alternatives --install /' + imagedest + '/' + type + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} ' + priority + ' || true' + '\n'
d.setVar('pkg_postinst_kernel-image-' + typelower, postinst)
postrm = '#!/bin/sh\n' + 'update-alternatives --remove' + ' ' + type + ' ' + type + '-${KERNEL_VERSION_NAME} || true' + '\n'
d.setVar('pkg_postrm_kernel-image-' + typelower, postrm)
image = d.getVar('INITRAMFS_IMAGE')
kernel.bbclass: handle embedding of initramfs images * "All 2.6 Linux kernels contain a gzipped "cpio" format archive, which is * extracted into rootfs when the kernel boots up." * (http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt) * * In some cases it can be useful to take advantage of this ability and embed your * customized rootfs ("the move to early userspace is necessary because finding * and mounting the real root device is complex"). * * Therefore, some code was added and since 2009 OpenEmbedded metadata * provides a convenient way to include your initramfs by setting * INITRAMFS_IMAGE = "your_initramfs_image.bb" * and specifying the chosen output format in the initramfs image recipe, e.g. * IMAGE_FSTYPES = "cpio.gz cpio.lzma" * * * Patch was imported from the OpenEmbedded git server * (git://git.openembedded.org/openembedded) * * Add satndalone task "builtin_initramfs". * commit 72761e468bb3e905459f2b81ce1bc4d80419481f * (From OE-Core rev: 19bda7f2c2dac6363468a49295c38f2095c67c98) Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'Remove usage of non-standard variables (DEPLOY_TO) and random renaming * of output.' * commit 456ba7ffd159821e86ad7ad4b66ec7d5790bd054 * Richard Purdie <rpurdie@rpsys.net> * * 'Fis typo in do_builtin_initramfs.' * commit 37f2fe4b801df832e93553a08eff24fec736c7d4 * Signed-off-by:Paul Sokolovsky <pmiscml@gmail.com> * * 'comment initramfs stuff till rootfs locking works properly (initramfs * should be optional as well)' * commit 2818d8b7be1a0d9a59ad3528091d47517d59328b * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'get initramfs stuff working * commit 1642b3e8fc81c666713951fdd4e7ff9a50d1c5a8 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'Fix INITRAMFS logic to stop breaking builds for people not using it' * commit dcf3049eb9eedf0838af59969b3f70a43298d3d7 * Signed-off-by: Richard Purdie <rpurdie@rpsys.net> * * '-change initramfs-logic' * commit 3e3f297457138e96e2b652658675796853eb0293 * Signed-off-by: Thomas Kunze <thommycheck@gmx.de> * * 'move initramfs stuff to configure so we can do postprocessing * on it with do_configure_append' * commit fc03e2be0b4470748a8b7707cea7293303adc424 * Signed-off-by: Koen Kooi <koen@openembedded.org> * * 'copy gz, lzo, lzma initramfs cpio images.' * commit 572abc3fdd1076ca35d8c15d269cc9d862101805 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * 'move the kernel size check to linux-kexecboot.inc.' * commit 45f82a941c77e9d747814fa1e337ba803475d327 * Signed-off-by: Andrea Adami <andrea.adami@gmail.com> * * Finally, two refinements as discussed on openembedded-core * mailing list: * - replace "if image != '' and image is not None:" with "if image" * - add cpio.xz support Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-07-11 22:33:11 +00:00
if image:
d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
# NOTE: setting INITRAMFS_TASK is for backward compatibility
# The preferred method is to set INITRAMFS_IMAGE, because
# this INITRAMFS_TASK has circular dependency problems
# if the initramfs requires kernel modules
image_task = d.getVar('INITRAMFS_TASK')
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
if image_task:
d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}')
}
# Here we pull in all various kernel image types which we support.
#
# In case you're wondering why kernel.bbclass inherits the other image
# types instead of the other way around, the reason for that is to
# maintain compatibility with various currently existing meta-layers.
# By pulling in the various kernel image types here, we retain the
# original behavior of kernel.bbclass, so no meta-layers should get
# broken.
#
# KERNEL_CLASSES by default pulls in kernel-uimage.bbclass, since this
# used to be the default behavior when only uImage was supported. This
# variable can be appended by users who implement support for new kernel
# image types.
KERNEL_CLASSES ?= " kernel-uimage "
inherit ${KERNEL_CLASSES}
# Old style kernels may set ${S} = ${WORKDIR}/git for example
# We need to move these over to STAGING_KERNEL_DIR. We can't just
# create the symlink in advance as the git fetcher can't cope with
# the symlink.
do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
base_do_unpack_append () {
s = d.getVar("S")
kernel.bbclass: fix do_unpack function when S ends with slash * slash at the end causes os.symlink(kernsrc, s) to use s as directory name and fails with: ERROR: Error executing a python function in /OE/build/owpb/webos-ports/meta-smartphone/meta-samsung/recipes-kernel/linux/linux-samsung-tuna_git.bb: The stack trace of python calls that resulted in this exception/failure was: File: 'base_do_unpack', lineno: 26, function: <module> 0022: subprocess.call(d.expand("mv /OE/build/owpb/webos-ports/tmp-glibc/work/maguro-webos-linux-gnueabi/linux-samsung-tuna/3_3.0.72+gitrAUTOINC+f8ed73f94a-r12/git/ /OE/build/owpb/webos-ports/tmp-glibc/sysroots/maguro/usr/src/kernel"), shell=True) 0023: os.symlink(kernsrc, s) 0024: 0025: *** 0026:base_do_unpack(d) 0027: File: 'base_do_unpack', lineno: 23, function: base_do_unpack 0019: bb.utils.mkdirhier(kernsrc) 0020: bb.utils.remove(kernsrc, recurse=True) 0021: import subprocess 0022: subprocess.call(d.expand("mv /OE/build/owpb/webos-ports/tmp-glibc/work/maguro-webos-linux-gnueabi/linux-samsung-tuna/3_3.0.72+gitrAUTOINC+f8ed73f94a-r12/git/ /OE/build/owpb/webos-ports/tmp-glibc/sysroots/maguro/usr/src/kernel"), shell=True) *** 0023: os.symlink(kernsrc, s) 0024: 0025: 0026:base_do_unpack(d) 0027: Exception: OSError: [Errno 2] No such file or directory ERROR: Function failed: base_do_unpack ERROR: Logfile of failure stored in: /OE/build/owpb/webos-ports/tmp-glibc/work/maguro-webos-linux-gnueabi/linux-samsung-tuna/3_3.0.72+gitrAUTOINC+f8ed73f94a-r12/temp/log.do_unpack.17042 ERROR: Task 0 (/OE/build/owpb/webos-ports/meta-smartphone/meta-samsung/recipes-kernel/linux/linux-samsung-tuna_git.bb, do_unpack) failed with exit code '1' (From OE-Core rev: dba30c2395792b553b69ce0b44cc75ff2dbdb317) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-07 14:06:49 +00:00
if s[-1] == '/':
# drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as directory name and fail
s=s[:-1]
kernsrc = d.getVar("STAGING_KERNEL_DIR")
if s != kernsrc:
bb.utils.mkdirhier(kernsrc)
bb.utils.remove(kernsrc, recurse=True)
if d.getVar("EXTERNALSRC"):
# With EXTERNALSRC S will not be wiped so we can symlink to it
os.symlink(s, kernsrc)
else:
import shutil
shutil.move(s, kernsrc)
os.symlink(kernsrc, s)
}
inherit kernel-arch deploy
PACKAGES_DYNAMIC += "^kernel-module-.*"
PACKAGES_DYNAMIC += "^kernel-image-.*"
PACKAGES_DYNAMIC += "^kernel-firmware-.*"
export OS = "${TARGET_OS}"
export CROSS_COMPILE = "${TARGET_PREFIX}"
export KBUILD_BUILD_USER = "oe-user"
export KBUILD_BUILD_HOST = "oe-host"
KERNEL_PRIORITY ?= "${@int(d.getVar('PV').split('-')[0].split('+')[0].split('.')[0]) * 10000 + \
int(d.getVar('PV').split('-')[0].split('+')[0].split('.')[1]) * 100 + \
int(d.getVar('PV').split('-')[0].split('+')[0].split('.')[-1])}"
KERNEL_RELEASE ?= "${KERNEL_VERSION}"
# The directory where built kernel lies in the kernel tree
KERNEL_OUTPUT_DIR ?= "arch/${ARCH}/boot"
KERNEL_IMAGEDEST = "boot"
#
# configuration
#
export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE") or "ttyS0"}"
kernel: Rearrange for 1.8 In 1.8 we want to streamline the kernel build process. Basically we currently have multiple copies of the kernel source floating around and the copying/compression/decompression is painful. Lets assume we have a kernel source per machine since in most cases this is true (and we have a sysroot per machine anyway). Basically, instead of extracting a source into WORKDIR, then copying to a sysroot, we now set S to point straight at STAGING_DIR_KERNEL. Anything using kernel source can then just point at it and use: do_configure[depends] += "virtual/kernel:do_patch" to depend on the kernel source being present. Note this is different behaviour to DEPENDS += "virtual/kernel" which equates to do_configure[depends] += "virtual/kernel:do_populate_sysroot". Once we do this, we no longer need the copy operation in do_populate_sysroot, in fact there is nothing to do there (yay). The remaining part of the challenge is to kill off the horrible do_install. This patch splits it off to a different class, the idea here is to have a separate recipe which depends on the virtual/kernel:do_patch and just installs and packages the source needed to build modules on target into a specific package. Right now this code is proof of concept. It builds kernels and kernel modules. perf blows up in do_package with issues on finding the kernel version which can probably be fixed by adding back the right bit of do_install, and adding a dependency of do_package[depends] += "virtual/kernel:do_install" to perf. The whole thing needs a good write up, the corner cases testing and probably a good dose of cleanup to the remaining code. (From OE-Core rev: 3b3f7e785e27990ba21bc7cd97289c826a9a95d1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-10-21 21:05:30 +00:00
KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}"
KERNEL_LOCALVERSION ?= ""
# kernels are generally machine specific
PACKAGE_ARCH = "${MACHINE_ARCH}"
# U-Boot support
UBOOT_ENTRYPOINT ?= "20008000"
UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
# Some Linux kernel configurations need additional parameters on the command line
KERNEL_EXTRA_ARGS ?= ""
EXTRA_OEMAKE = " HOSTCC="${BUILD_CC}" HOSTCPP="${BUILD_CPP}""
KERNEL_ALT_IMAGETYPE ??= ""
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
copy_initramfs() {
echo "Copying initramfs into ./usr ..."
# In case the directory is not created yet from the first pass compile:
mkdir -p ${B}/usr
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
# Find and use the first initramfs image archive type we find
rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz; do
if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then
cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/.
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
case $img in
*gz)
echo "gzip decompressing image"
gunzip -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
break
;;
*lz4)
echo "lz4 decompressing image"
lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
break
;;
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
*lzo)
echo "lzo decompressing image"
lzop -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
break
;;
*lzma)
echo "lzma decompressing image"
lzma -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
break
;;
*xz)
echo "xz decompressing image"
xz -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
break
;;
esac
fi
done
echo "Finished copy of initramfs into ./usr"
}
INITRAMFS_BASE_NAME ?= "initramfs-${PV}-${PR}-${MACHINE}-${DATETIME}"
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
INITRAMFS_BASE_NAME[vardepsexclude] = "DATETIME"
do_bundle_initramfs () {
if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
echo "Creating a kernel image with a bundled initramfs..."
copy_initramfs
# Backing up kernel image relies on its type(regular file or symbolic link)
tmp_path=""
for type in ${KERNEL_IMAGETYPES} ; do
if [ -h ${KERNEL_OUTPUT_DIR}/$type ] ; then
linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$type`
realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$type`
mv -f $realpath $realpath.bak
tmp_path=$tmp_path" "$type"#"$linkpath"#"$realpath
elif [ -f ${KERNEL_OUTPUT_DIR}/$type ]; then
mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.bak
tmp_path=$tmp_path" "$type"##"
fi
done
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
kernel_do_compile
# Restoring kernel image
for tp in $tmp_path ; do
type=`echo $tp|cut -d "#" -f 1`
linkpath=`echo $tp|cut -d "#" -f 2`
realpath=`echo $tp|cut -d "#" -f 3`
if [ -n "$realpath" ]; then
mv -f $realpath $realpath.initramfs
mv -f $realpath.bak $realpath
ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$type.initramfs
else
mv -f ${KERNEL_OUTPUT_DIR}/$type ${KERNEL_OUTPUT_DIR}/$type.initramfs
mv -f ${KERNEL_OUTPUT_DIR}/$type.bak ${KERNEL_OUTPUT_DIR}/$type
fi
done
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
fi
}
do_bundle_initramfs[dirs] = "${B}"
python do_devshell_prepend () {
os.environ["LDFLAGS"] = ''
}
addtask bundle_initramfs after do_install before do_deploy
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
kernel_do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
kernel.bbclass, image.bbclass: Implement kernel INITRAMFS dependency and bundling This patch aims to fix the following two cases for the INITRAMFS generation. 1) Allow an image recipe to specify a paired INITRAMFS recipe such as core-image-minimal-initramfs. This allows building a base image which always generates the needed initramfs image in one step 2) Allow building a single binary which contains a kernel and the initramfs. A key requirement of the initramfs is to be able to add kernel modules. The current implementation of the INITRAMFS_IMAGE variable has a circular dependency when using kernel modules in the initramfs image.bb file that is caused by kernel.bbclass trying to build the initramfs before the kernel's do_install rule. The solution for this problem is to have the kernel's do_bundle_initramfs_image task depend on the do_rootfs from the INITRAMFS_IMAGE and not some intermediate point. The image.bbclass will also sets up dependencies to make the initramfs creation task run last. The code to bundle the kernel and initramfs together has been added. At a high level, all it is doing is invoking a second compilation of the kernel but changing the value of CONFIG_INITRAMFS_SOURCE to point to the generated initramfs from the image recipe. [YOCTO #4072] (From OE-Core rev: 609d5a9ab9e58bb1c2bcc2145399fbc8b701b85a) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-22 23:04:27 +00:00
# The $use_alternate_initrd is only set from
# do_bundle_initramfs() This variable is specifically for the
# case where we are making a second pass at the kernel
# compilation and we want to force the kernel build to use a
# different initramfs image. The way to do that in the kernel
# is to specify:
# make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio
if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then
# The old style way of copying an prebuilt image and building it
# is turned on via INTIRAMFS_TASK != ""
copy_initramfs
use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio
fi
for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
done
# vmlinux.gz is not built by kernel
if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
mkdir -p "${KERNEL_OUTPUT_DIR}"
gzip -9c < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz"
fi
}
do_compile_kernelmodules() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then
oe_runmake -C ${B} ${PARALLEL_MAKE} modules CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
# Module.symvers gets updated during the
# building of the kernel modules. We need to
# update this in the shared workdir since some
# external kernel modules has a dependency on
# other kernel modules and will look at this
# file to do symbol lookups
cp ${B}/Module.symvers ${STAGING_KERNEL_BUILDDIR}/
else
bbnote "no modules to compile"
fi
}
addtask compile_kernelmodules after do_compile before do_strip
kernel_do_install() {
#
# First install the modules
#
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install
rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
# If the kernel/ directory is empty remove it to prevent QA issues
rmdir --ignore-fail-on-non-empty "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel"
else
bbnote "no modules to install"
fi
#
# Install various kernel output (zImage, map file, config, module support files)
#
install -d ${D}/${KERNEL_IMAGEDEST}
install -d ${D}/boot
for type in ${KERNEL_IMAGETYPES} ; do
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${D}/${KERNEL_IMAGEDEST}/${type}-${KERNEL_VERSION}
done
install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
[ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION}
install -d ${D}${sysconfdir}/modules-load.d
install -d ${D}${sysconfdir}/modprobe.d
kernel: move source and build output to work-shared commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location. This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds. To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to: work-shared/MACHINE/kernel-source work-shared/MACHINE/kernel-build-artifacts Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts". External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout. recipes that depend on the kernel source must have a depedency on the do_shared_workdir task: do_configure[depends] += "virtual/kernel:do_shared_workdir" With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build. (From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
}
do_install[prefuncs] += "package_get_auto_pr"
# Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile
do_kernel_version_sanity_check() {
if [ "x${KERNEL_VERSION_SANITY_SKIP}" = "x1" ]; then
exit 0
fi
# The Makefile determines the kernel version shown at runtime
# Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile
VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//)
PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//)
EXTRAVERSION=$(grep "^EXTRAVERSION =" ${S}/Makefile | sed s/.*=\ *//)
# Build a string for regex and a plain version string
reg="^${VERSION}\.${PATCHLEVEL}"
vers="${VERSION}.${PATCHLEVEL}"
if [ -n "${SUBLEVEL}" ]; then
# Ignoring a SUBLEVEL of zero is fine
if [ "${SUBLEVEL}" = "0" ]; then
reg="${reg}(\.${SUBLEVEL})?"
else
reg="${reg}\.${SUBLEVEL}"
vers="${vers}.${SUBLEVEL}"
fi
fi
vers="${vers}${EXTRAVERSION}"
reg="${reg}${EXTRAVERSION}"
if [ -z `echo ${PV} | grep -E "${reg}"` ]; then
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."
fi
exit 0
}
addtask shared_workdir after do_compile before do_compile_kernelmodules
addtask shared_workdir_setscene
do_shared_workdir_setscene () {
exit 1
}
kernel: move source and build output to work-shared commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location. This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds. To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to: work-shared/MACHINE/kernel-source work-shared/MACHINE/kernel-build-artifacts Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts". External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout. recipes that depend on the kernel source must have a depedency on the do_shared_workdir task: do_configure[depends] += "virtual/kernel:do_shared_workdir" With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build. (From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
emit_depmod_pkgdata() {
# Stash data for depmod
install -d ${PKGDESTWORK}/kernel-depmod/
echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/kernel-depmod/kernel-abiversion
cp ${B}/System.map ${PKGDESTWORK}/kernel-depmod/System.map-${KERNEL_VERSION}
}
PACKAGEFUNCS += "emit_depmod_pkgdata"
kernel: move source and build output to work-shared commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location. This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds. To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to: work-shared/MACHINE/kernel-source work-shared/MACHINE/kernel-build-artifacts Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts". External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout. recipes that depend on the kernel source must have a depedency on the do_shared_workdir task: do_configure[depends] += "virtual/kernel:do_shared_workdir" With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build. (From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
do_shared_workdir () {
cd ${B}
kerneldir=${STAGING_KERNEL_BUILDDIR}
kernel/bbclass: rework kernel and module classes to allow for building out-of-tree modules The existing infrastructure uses an external build tree which references the kernel source in the work dir. If run with rm work, building external modules will fail. This patch places a configured source tree in sysroots. Striking a balance between minimal size and minimal maintenance is difficult. A fully configured tree is about 500MB after a clean. This version leans on the side of caution and removes only the obviously unecessary parts of the source tree to conserve space, resulting in about 170MB. The arch directories would be some additional pruning we could do. Given examples from the devel package from distributions, I suspect this size could be reduced to 75MB or so, but at the cost of a much more complex recipe which is likely to require a great deal more maintenance to keep current with kernel releases. Care is also taken to clean the hostprogs in scripts, and the modules are responsible for building them as needed. Although it is unclear to me if this is really necessary, especially considering that modules put these bits back as soon as they compile. If we are not generating an sstate package, I suspect we can ignore these. Please try this with your modules and let me know how it does. I tried to take non linux-yocto kernel recipes into account, but I have only tested with linux-yocto and the hello-mod recipe so far. (From OE-Core rev: a9d41062e24a6b99661b3a5256f369b557433607) Signed-off-by: Darren Hart <dvhart@linux.intel.com> Acked-by: Koen Kooi <koen@dominion.thruhere.net> Acked-by: Gary Thomas <gary@mlbassoc.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-03-09 01:09:10 +00:00
install -d $kerneldir
#
# Store the kernel version in sysroots for module-base.bbclass
#
echo "${KERNEL_VERSION}" > $kerneldir/kernel-abiversion
kernel: move source and build output to work-shared commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location. This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds. To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to: work-shared/MACHINE/kernel-source work-shared/MACHINE/kernel-build-artifacts Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts". External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout. recipes that depend on the kernel source must have a depedency on the do_shared_workdir task: do_configure[depends] += "virtual/kernel:do_shared_workdir" With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build. (From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
# Copy files required for module builds
cp System.map $kerneldir/System.map-${KERNEL_VERSION}
cp Module.symvers $kerneldir/
cp .config $kerneldir/
mkdir -p $kerneldir/include/config
cp include/config/kernel.release $kerneldir/include/config/kernel.release
if [ -e certs/signing_key.pem ]; then
# The signing_key.* files are stored in the certs/ dir in
# newer Linux kernels
mkdir -p $kerneldir/certs
cp certs/signing_key.* $kerneldir/certs/
elif [ -e signing_key.priv ]; then
cp signing_key.* $kerneldir/
fi
kernel: move source and build output to work-shared commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location. This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds. To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to: work-shared/MACHINE/kernel-source work-shared/MACHINE/kernel-build-artifacts Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts". External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout. recipes that depend on the kernel source must have a depedency on the do_shared_workdir task: do_configure[depends] += "virtual/kernel:do_shared_workdir" With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build. (From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
# We can also copy over all the generated files and avoid special cases
# like version.h, but we've opted to keep this small until file creep starts
# to happen
if [ -e include/linux/version.h ]; then
mkdir -p $kerneldir/include/linux
cp include/linux/version.h $kerneldir/include/linux/version.h
fi
# As of Linux kernel version 3.0.1, the clean target removes
# arch/powerpc/lib/crtsavres.o which is present in
# KBUILD_LDFLAGS_MODULE, making it required to build external modules.
if [ ${ARCH} = "powerpc" ]; then
mkdir -p $kerneldir/arch/powerpc/lib/
cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi
if [ -d include/generated ]; then
mkdir -p $kerneldir/include/generated/
cp -fR include/generated/* $kerneldir/include/generated/
fi
Revert "kernel/kernel-arch: Explicitly mapping between i386/x86_64 and x86 for kernel ARCH" This reverts commit 8d310b24927d0f348fb431895f0583733db2aad0. That commit completely breaks KBUILD_DEFCONFIG because it relies on $ARCH to match between the target OE arch and the kernel subdirectory containing the defconfigs. In the kernel all defconfigs for everything x86-based (including x86_64) is stored in dir arch/x86/configs/ kernel-yocto.bbclass correctly searches for all the defconfigs inside ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} Commit 8d310b249 makes it search in wrong places and _only_ if you define TARGET_ARCH = "athlon" will it search x86 which is nonsensical. The commit further adds an if clause to hack the mungled kernel arches back to their original values (ugh) in do_shared_workdir which is run after do compile, but of course the build breaks before that in do_kernel_metadata because of the KBUILD_DEFCONFIG mentioned above (so that hack is useless). Please fix that corner case bug in another way which does not completely screw up the kernel arch mapping & defconfig logic. If 64bit configs are generated in the kernel for 32bit machines because the host is asked, then it it a bug in the kernel, it is of no use to hack around it in OE. (From OE-Core rev: bc02a478a5d4a5de7b3943ed809d5c22711f5b1f) Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-02 09:01:56 +00:00
if [ -d arch/${ARCH}/include/generated ]; then
mkdir -p $kerneldir/arch/${ARCH}/include/generated/
cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/
fi
}
# We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware
kernel: move source and build output to work-shared commit 3b3f7e785e279 [kernel: Rearrange for 1.8] began the process of moving the kernel source and build artefacts out of sstate control and into a shared location. This changed triggered some workflow issues, as well as bugs related to the kernel source containing build output, and hence being dirty and breaking kernel rebuilds. To solve these issues, and to make it clear that the kernel is not under sstate control, we move the source and build outputs to: work-shared/MACHINE/kernel-source work-shared/MACHINE/kernel-build-artifacts Where kernel-build-artifacts is the kernel build output and kernel-source is kept "pristine". The build-artifacts contain everything that is required to build external modules against the kernel source, and includes the defconfig, the kernel-abiversion, System.map files and output from "make scripts". External module builds should either pass O= on the command line, or set KBUILD_OUTPUT to point to the build-artifacts. module-base.bbclass takes care of setting KBUILD_OUTPUT, so most existing external module recipes are transparently adapted to the new source/build layout. recipes that depend on the kernel source must have a depedency on the do_shared_workdir task: do_configure[depends] += "virtual/kernel:do_shared_workdir" With this dependency added, the STAGING_KERNEL_DIR will be populated and available to the rest of the build. (From OE-Core rev: 6a1ff0e7eacef595738f2fed086986fd622ec32a) Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-01-15 11:54:15 +00:00
sysroot_stage_all () {
:
}
KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig || yes '' | oe_runmake -C ${S} O=${B} oldconfig"
python check_oldest_kernel() {
oldest_kernel = d.getVar('OLDEST_KERNEL')
kernel_version = d.getVar('KERNEL_VERSION')
tclibc = d.getVar('TCLIBC')
if tclibc == 'glibc':
kernel_version = kernel_version.split('-', 1)[0]
if oldest_kernel and kernel_version:
if bb.utils.vercmp_string(kernel_version, oldest_kernel) < 0:
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))
}
check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION"
do_configure[prefuncs] += "check_oldest_kernel"
kernel_do_configure() {
# fixes extra + in /lib/modules/2.6.37+
# $ scripts/setlocalversion . => +
# $ make kernelversion => 2.6.37
# $ make kernelrelease => 2.6.37+
touch ${B}/.scmversion ${S}/.scmversion
if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then
mv "${S}/.config" "${B}/.config"
fi
# Copy defconfig to .config if .config does not exist. This allows
# recipes to manage the .config themselves in do_configure_prepend().
if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
cp "${WORKDIR}/defconfig" "${B}/.config"
fi
${KERNEL_CONFIG_COMMAND}
}
do_savedefconfig() {
bbplain "Saving defconfig to:\n${B}/defconfig"
oe_runmake -C ${B} savedefconfig
}
do_savedefconfig[nostamp] = "1"
addtask savedefconfig after do_configure
inherit cml1
EXPORT_FUNCTIONS do_compile do_install do_configure
# kernel-base becomes kernel-${KERNEL_VERSION}
# kernel-image becomes kernel-image-${KERNEL_VERSION}
PACKAGES = "kernel kernel-base kernel-vmlinux kernel-image kernel-dev kernel-modules"
FILES_${PN} = ""
FILES_kernel-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin"
FILES_kernel-image = ""
FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
FILES_kernel-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}"
FILES_kernel-modules = ""
RDEPENDS_kernel = "kernel-base"
# Allow machines to override this dependency if kernel image files are
# not wanted in images as standard
RDEPENDS_kernel-base ?= "kernel-image"
PKG_kernel-image = "kernel-image-${@legitimize_package_name('${KERNEL_VERSION}')}"
RDEPENDS_kernel-image += "${@base_conditional('KERNEL_IMAGETYPE', 'vmlinux', 'kernel-vmlinux', '', d)}"
PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
RPROVIDES_kernel-base += "kernel-${KERNEL_VERSION}"
ALLOW_EMPTY_kernel = "1"
ALLOW_EMPTY_kernel-base = "1"
ALLOW_EMPTY_kernel-image = "1"
ALLOW_EMPTY_kernel-modules = "1"
DESCRIPTION_kernel-modules = "Kernel modules meta package"
pkg_postinst_kernel-base () {
if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
mkdir -p $D/lib/modules/${KERNEL_VERSION}
fi
if [ -n "$D" ]; then
depmodwrapper -a -b $D ${KERNEL_VERSION}
else
depmod -a ${KERNEL_VERSION}
fi
}
PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
python split_kernel_packages () {
do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
}
# Many scripts want to look in arch/$arch/boot for the bootable
# image. This poses a problem for vmlinux and vmlinuz based
# booting. This task arranges to have vmlinux and vmlinuz appear
# in the normalized directory location.
do_kernel_link_images() {
if [ ! -d "${B}/arch/${ARCH}/boot" ]; then
mkdir ${B}/arch/${ARCH}/boot
fi
cd ${B}/arch/${ARCH}/boot
ln -sf ../../../vmlinux
if [ -f ../../../vmlinuz ]; then
ln -sf ../../../vmlinuz
fi
if [ -f ../../../vmlinuz.bin ]; then
ln -sf ../../../vmlinuz.bin
fi
}
addtask kernel_link_images after do_compile before do_strip
do_strip() {
if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then
if ! (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux"); then
bbwarn "image type(s) will not be stripped (not supported): ${KERNEL_IMAGETYPES}"
return
fi
cd ${B}
headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_DIR}/vmlinux | \
grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \
sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \
gawk '{print $1}'`
for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do {
if ! (echo "$headers" | grep -q "^$str$"); then
bbwarn "Section not found: $str";
fi
"$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_DIR}/vmlinux
}; done
bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \
"${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}"
fi;
}
do_strip[dirs] = "${B}"
addtask strip before do_sizecheck after do_kernel_link_images
# Support checking the kernel size since some kernels need to reside in partitions
# with a fixed length or there is a limit in transferring the kernel to memory
do_sizecheck() {
if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then
invalid=`echo ${KERNEL_IMAGE_MAXSIZE} | sed 's/[0-9]//g'`
if [ -n "$invalid" ]; then
die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integerx (The unit is Kbytes)"
fi
for type in ${KERNEL_IMAGETYPES} ; do
size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$type | awk '{print $1}'`
if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
warn "This kernel $type (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device. Please reduce the size of the kernel by making more of it modular."
fi
done
fi
}
do_sizecheck[dirs] = "${B}"
addtask sizecheck before do_install after do_strip
KERNEL_IMAGE_BASE_NAME ?= "${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
# Don't include the DATETIME variable in the sstate package signatures
KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
KERNEL_IMAGE_SYMLINK_NAME ?= "${MACHINE}"
MODULE_IMAGE_BASE_NAME ?= "modules-${PKGE}-${PKGV}-${PKGR}-${MACHINE}-${DATETIME}"
MODULE_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
MODULE_TARBALL_BASE_NAME ?= "${MODULE_IMAGE_BASE_NAME}.tgz"
# Don't include the DATETIME variable in the sstate package signatures
MODULE_TARBALL_SYMLINK_NAME ?= "modules-${MACHINE}.tgz"
MODULE_TARBALL_DEPLOY ?= "1"
kernel_do_deploy() {
for type in ${KERNEL_IMAGETYPES} ; do
base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type} ${DEPLOYDIR}/${base_name}.bin
done
if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
mkdir -p ${D}/lib
tar -cvzf ${DEPLOYDIR}/${MODULE_TARBALL_BASE_NAME} -C ${D} lib
ln -sf ${MODULE_TARBALL_BASE_NAME} ${DEPLOYDIR}/${MODULE_TARBALL_SYMLINK_NAME}
fi
for type in ${KERNEL_IMAGETYPES} ; do
base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
ln -sf ${base_name}.bin ${DEPLOYDIR}/${symlink_name}.bin
ln -sf ${base_name}.bin ${DEPLOYDIR}/${type}
done
cd ${B}
# Update deploy directory
for type in ${KERNEL_IMAGETYPES} ; do
if [ -e "${KERNEL_OUTPUT_DIR}/${type}.initramfs" ]; then
echo "Copying deploy ${type} kernel-initramfs image and setting up links..."
initramfs_base_name=${type}-${INITRAMFS_BASE_NAME}
initramfs_symlink_name=${type}-initramfs-${MACHINE}
install -m 0644 ${KERNEL_OUTPUT_DIR}/${type}.initramfs ${DEPLOYDIR}/${initramfs_base_name}.bin
ln -sf ${initramfs_base_name}.bin ${DEPLOYDIR}/${initramfs_symlink_name}.bin
fi
done
}
do_deploy[cleandirs] = "${DEPLOYDIR}"
do_deploy[dirs] = "${DEPLOYDIR} ${B}"
do_deploy[prefuncs] += "package_get_auto_pr"
addtask deploy after do_populate_sysroot do_packagedata
EXPORT_FUNCTIONS do_deploy