generic-poky/meta/classes/kernel.bbclass

531 lines
18 KiB
Plaintext
Raw Normal View History

inherit linux-kernel-base module_strip
PROVIDES += "virtual/kernel"
DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}depmod virtual/${TARGET_PREFIX}gcc${KERNEL_CCSUFFIX} update-modules"
# 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_TASK ?= ""
python __anonymous () {
kerneltype = d.getVar('KERNEL_IMAGETYPE', 1) or ''
if kerneltype == 'uImage':
depends = d.getVar("DEPENDS", 1)
depends = "%s u-boot-mkimage-native" % depends
d.setVar("DEPENDS", depends)
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
image = d.getVar('INITRAMFS_IMAGE', True)
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.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs')
}
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}"
KERNEL_PRIORITY = "${@d.getVar('PV',1).split('-')[0].split('.')[-1]}"
KERNEL_RELEASE ?= "${KERNEL_VERSION}"
KERNEL_CCSUFFIX ?= ""
KERNEL_LDSUFFIX ?= ""
# Set TARGET_??_KERNEL_ARCH in the machine .conf to set architecture
# specific options necessary for building the kernel and modules.
#FIXME: should be this: TARGET_CC_KERNEL_ARCH ?= "${TARGET_CC_ARCH}"
TARGET_CC_KERNEL_ARCH ?= ""
HOST_CC_KERNEL_ARCH ?= "${TARGET_CC_KERNEL_ARCH}"
TARGET_LD_KERNEL_ARCH ?= ""
HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc${KERNEL_CCSUFFIX} ${HOST_CC_KERNEL_ARCH}${TOOLCHAIN_OPTIONS}"
KERNEL_LD = "${HOST_PREFIX}ld${KERNEL_LDSUFFIX} ${HOST_LD_KERNEL_ARCH}${TOOLCHAIN_OPTIONS}"
# Where built kernel lies in the kernel tree
KERNEL_OUTPUT ?= "arch/${ARCH}/boot/${KERNEL_IMAGETYPE}"
KERNEL_IMAGEDEST = "boot"
#
# configuration
#
export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE",1) or "ttyS0"}"
KERNEL_VERSION = "${@get_kernelversion('${B}')}"
KERNEL_LOCALVERSION ?= ""
# kernels are generally machine specific
PACKAGE_ARCH = "${MACHINE_ARCH}"
# U-Boot support
UBOOT_ENTRYPOINT ?= "20008000"
UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
# For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE.
# We don't want to override kernel Makefile variables from the environment
EXTRA_OEMAKE = ""
KERNEL_ALT_IMAGETYPE ??= ""
KERNEL_IMAGETYPE_FOR_MAKE = "${@(lambda s: s[:-3] if s[-3:] == ".gz" else s)(d.getVar('KERNEL_IMAGETYPE', 1))}"
kernel_do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
oe_runmake include/linux/version.h CC="${KERNEL_CC}" LD="${KERNEL_LD}"
oe_runmake ${KERNEL_IMAGETYPE_FOR_MAKE} ${KERNEL_ALT_IMAGETYPE} CC="${KERNEL_CC}" LD="${KERNEL_LD}"
if test "${KERNEL_IMAGETYPE_FOR_MAKE}.gz" = "${KERNEL_IMAGETYPE}"; then
gzip -9c < "${KERNEL_IMAGETYPE_FOR_MAKE}" > "${KERNEL_OUTPUT}"
fi
}
do_compile_kernelmodules() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
oe_runmake modules CC="${KERNEL_CC}" LD="${KERNEL_LD}"
else
bbnote "no modules to compile"
fi
}
addtask compile_kernelmodules after do_compile before do_install
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 INSTALL_MOD_PATH="${D}" modules_install
rm -f "${D}/lib/modules/${KERNEL_VERSION}/modules.order"
rm -f "${D}/lib/modules/${KERNEL_VERSION}/modules.builtin"
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
install -m 0644 ${KERNEL_OUTPUT} ${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}
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}/etc/modutils
install -d ${D}/etc/modprobe.d
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
#
# Support for external module building - create a minimal copy of the
# kernel source tree.
#
kerneldir=${D}/kernel
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
#
# Store kernel image name to allow use during image generation
#
echo "${KERNEL_IMAGE_BASE_NAME}" >$kerneldir/kernel-image-name
#
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
# Copy the entire source tree. In case an external build directory is
# used, copy the build directory over first, then copy over the source
# dir. This ensures the original Makefiles are used and not the
# redirecting Makefiles in the build directory.
#
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
# work and sysroots can be on different partitions, so we can't rely on
# hardlinking, unfortunately.
#
cp -fR * $kerneldir
cp .config $kerneldir
if [ "${S}" != "${B}" ]; then
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
cp -fR ${S}/* $kerneldir
fi
install -m 0644 ${KERNEL_OUTPUT} $kerneldir/${KERNEL_IMAGETYPE}
install -m 0644 System.map $kerneldir/System.map-${KERNEL_VERSION}
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
#
# Clean and remove files not needed for building modules.
# Some distributions go through a lot more trouble to strip out
# unecessary headers, for now, we just prune the obvious bits.
#
# We don't want to leave host-arch binaries in /sysroots, so
# we clean the scripts dir while leaving the generated config
# and include files.
#
oe_runmake -C $kerneldir CC="${KERNEL_CC}" LD="${KERNEL_LD}" clean
make -C $kerneldir _mrproper_scripts
find $kerneldir -path $kerneldir/scripts -prune -o -name "*.[csS]" -exec rm '{}' \;
find $kerneldir/Documentation -name "*.txt" -exec rm '{}' \;
# 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
cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi
# Remove the following binaries which cause strip errors
# during do_package for cross-compiled platforms
bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \
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
arch/powerpc/boot/mktree"
for entry in $bin_files; do
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
rm -f $kerneldir/$entry
done
}
PACKAGE_PREPROCESS_FUNCS += "kernel_package_preprocess"
kernel_package_preprocess () {
rm -rf ${PKGD}/kernel
}
sysroot_stage_all_append() {
sysroot_stage_dir ${D}/kernel ${SYSROOT_DESTDIR}/kernel
}
kernel_do_configure() {
# 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
yes '' | oe_runmake oldconfig
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 [ ! -z "${INITRAMFS_IMAGE}" ]; then
for img in cpio.gz cpio.lzo cpio.lzma cpio.xz; do
if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" ]; then
cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$img" initramfs.$img
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
fi
done
fi
}
do_configure[depends] += "${INITRAMFS_TASK}"
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
do_savedefconfig() {
oe_runmake savedefconfig
}
do_savedefconfig[nostamp] = "1"
addtask savedefconfig after do_configure
pkg_postinst_kernel () {
cd /${KERNEL_IMAGEDEST}; update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
}
pkg_postrm_kernel () {
cd /${KERNEL_IMAGEDEST}; update-alternatives --remove ${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE}-${KERNEL_VERSION} || true
}
inherit cml1
EXPORT_FUNCTIONS do_compile do_install do_configure
# kernel-base becomes kernel-${KERNEL_VERSION}
# kernel-image becomes kernel-image-${KERNEL_VERISON}
PACKAGES = "kernel kernel-base kernel-image kernel-dev kernel-vmlinux kernel-misc"
FILES = ""
FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}*"
FILES_kernel-dev = "/boot/System.map* /boot/Module.symvers* /boot/config*"
FILES_kernel-vmlinux = "/boot/vmlinux*"
# misc is a package to contain files we need in staging
FILES_kernel-misc = "/kernel/include/config /kernel/scripts /kernel/drivers/crypto /kernel/drivers/media"
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}')}"
PKG_kernel-base = "kernel-${@legitimize_package_name('${KERNEL_VERSION}')}"
ALLOW_EMPTY_kernel = "1"
ALLOW_EMPTY_kernel-base = "1"
ALLOW_EMPTY_kernel-image = "1"
pkg_postinst_kernel-image () {
if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
mkdir -p $D/lib/modules/${KERNEL_VERSION}
fi
if [ -n "$D" ]; then
${HOST_PREFIX}depmod -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
else
depmod -a
fi
}
pkg_postinst_modules () {
if [ -n "$D" ]; then
${HOST_PREFIX}depmod -A -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
else
depmod -a
update-modules || true
fi
}
pkg_postrm_modules () {
update-modules || true
}
autoload_postinst_fragment() {
if [ x"$D" = "x" ]; then
modprobe %s || true
fi
}
# autoload defaults (alphabetically sorted)
module_autoload_hidp = "hidp"
module_autoload_ipv6 = "ipv6"
module_autoload_ipsec = "ipsec"
module_autoload_ircomm-tty = "ircomm-tty"
module_autoload_rfcomm = "rfcomm"
module_autoload_sa1100-rtc = "sa1100-rtc"
# sa1100-rtc was renamed in 2.6.23 onwards
module_autoload_rtc-sa1100 = "rtc-sa1100"
# alias defaults (alphabetically sorted)
module_conf_af_packet = "alias net-pf-17 af_packet"
module_conf_bluez = "alias net-pf-31 bluez"
module_conf_bnep = "alias bt-proto-4 bnep"
module_conf_hci_uart = "alias tty-ldisc-15 hci_uart"
module_conf_l2cap = "alias bt-proto-0 l2cap"
module_conf_sco = "alias bt-proto-2 sco"
module_conf_rfcomm = "alias bt-proto-3 rfcomm"
python populate_packages_prepend () {
def extract_modinfo(file):
import tempfile, re
tempfile.tempdir = d.getVar("WORKDIR", 1)
tf = tempfile.mkstemp()
tmpfile = tf[1]
cmd = "PATH=\"%s\" %sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("PATH", 1), d.getVar("HOST_PREFIX", 1) or "", file, tmpfile)
os.system(cmd)
f = open(tmpfile)
l = f.read().split("\000")
f.close()
os.close(tf[0])
os.unlink(tmpfile)
exp = re.compile("([^=]+)=(.*)")
vals = {}
for i in l:
m = exp.match(i)
if not m:
continue
vals[m.group(1)] = m.group(2)
return vals
def parse_depmod():
import re
dvar = d.getVar('PKGD', 1)
if not dvar:
bb.error("PKGD not defined")
return
kernelver = d.getVar('KERNEL_VERSION', 1)
kernelver_stripped = kernelver
m = re.match('^(.*-hh.*)[\.\+].*$', kernelver)
if m:
kernelver_stripped = m.group(1)
path = d.getVar("PATH", 1)
host_prefix = d.getVar("HOST_PREFIX", 1) or ""
cmd = "PATH=\"%s\" %sdepmod -n -a -r -b %s -F %s/boot/System.map-%s %s" % (path, host_prefix, dvar, dvar, kernelver, kernelver_stripped)
f = os.popen(cmd, 'r')
deps = {}
pattern0 = "^(.*\.k?o):..*$"
pattern1 = "^(.*\.k?o):\s*(.*\.k?o)\s*$"
pattern2 = "^(.*\.k?o):\s*(.*\.k?o)\s*\\\$"
pattern3 = "^\t(.*\.k?o)\s*\\\$"
pattern4 = "^\t(.*\.k?o)\s*$"
line = f.readline()
while line:
if not re.match(pattern0, line):
line = f.readline()
continue
m1 = re.match(pattern1, line)
if m1:
deps[m1.group(1)] = m1.group(2).split()
else:
m2 = re.match(pattern2, line)
if m2:
deps[m2.group(1)] = m2.group(2).split()
line = f.readline()
m3 = re.match(pattern3, line)
while m3:
deps[m2.group(1)].extend(m3.group(1).split())
line = f.readline()
m3 = re.match(pattern3, line)
m4 = re.match(pattern4, line)
deps[m2.group(1)].extend(m4.group(1).split())
line = f.readline()
f.close()
return deps
def get_dependencies(file, pattern, format):
# file no longer includes PKGD
file = file.replace(d.getVar('PKGD', 1) or '', '', 1)
# instead is prefixed with /lib/modules/${KERNEL_VERSION}
file = file.replace("/lib/modules/%s/" % d.getVar('KERNEL_VERSION', 1) or '', '', 1)
if module_deps.has_key(file):
import re
dependencies = []
for i in module_deps[file]:
m = re.match(pattern, os.path.basename(i))
if not m:
continue
on = legitimize_package_name(m.group(1))
dependency_pkg = format % on
dependencies.append(dependency_pkg)
return dependencies
return []
def frob_metadata(file, pkg, pattern, format, basename):
import re
vals = extract_modinfo(file)
dvar = d.getVar('PKGD', 1)
# If autoloading is requested, output /etc/modutils/<name> and append
# appropriate modprobe commands to the postinst
autoload = d.getVar('module_autoload_%s' % basename, 1)
if autoload:
name = '%s/etc/modutils/%s' % (dvar, basename)
f = open(name, 'w')
for m in autoload.split():
f.write('%s\n' % m)
f.close()
postinst = d.getVar('pkg_postinst_%s' % pkg, 1)
if not postinst:
bb.fatal("pkg_postinst_%s not defined" % pkg)
postinst += d.getVar('autoload_postinst_fragment', 1) % autoload
d.setVar('pkg_postinst_%s' % pkg, postinst)
# Write out any modconf fragment
modconf = d.getVar('module_conf_%s' % basename, 1)
if modconf:
name = '%s/etc/modprobe.d/%s.conf' % (dvar, basename)
f = open(name, 'w')
f.write("%s\n" % modconf)
f.close()
files = d.getVar('FILES_%s' % pkg, 1)
files = "%s /etc/modutils/%s /etc/modutils/%s.conf /etc/modprobe.d/%s.conf" % (files, basename, basename, basename)
d.setVar('FILES_%s' % pkg, files)
if vals.has_key("description"):
old_desc = d.getVar('DESCRIPTION_' + pkg, 1) or ""
d.setVar('DESCRIPTION_' + pkg, old_desc + "; " + vals["description"])
rdepends_str = d.getVar('RDEPENDS_' + pkg, 1)
if rdepends_str:
rdepends = rdepends_str.split()
else:
rdepends = []
rdepends.extend(get_dependencies(file, pattern, format))
bb.data.setVar('RDEPENDS_' + pkg, ' '.join(rdepends), d)
module_deps = parse_depmod()
module_regex = '^(.*)\.k?o$'
module_pattern = 'kernel-module-%s'
postinst = d.getVar('pkg_postinst_modules', 1)
postrm = d.getVar('pkg_postrm_modules', 1)
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.bin$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.fw$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
do_split_packages(d, root='/lib/firmware', file_regex='^(.*)\.cis$', output_pattern='kernel-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
do_split_packages(d, root='/lib/modules', file_regex=module_regex, output_pattern=module_pattern, description='%s kernel module', postinst=postinst, postrm=postrm, recursive=True, hook=frob_metadata, extra_depends='update-modules kernel-%s' % d.getVar("KERNEL_VERSION", 1))
import re
metapkg = "kernel-modules"
d.setVar('ALLOW_EMPTY_' + metapkg, "1")
d.setVar('FILES_' + metapkg, "")
blacklist = [ 'kernel-dev', 'kernel-image', 'kernel-base', 'kernel-vmlinux', 'perf', 'perf-dbg', 'kernel-misc' ]
for l in module_deps.values():
for i in l:
pkg = module_pattern % legitimize_package_name(re.match(module_regex, os.path.basename(i)).group(1))
blacklist.append(pkg)
metapkg_rdepends = []
packages = d.getVar('PACKAGES', 1).split()
for pkg in packages[1:]:
if not pkg in blacklist and not pkg in metapkg_rdepends:
metapkg_rdepends.append(pkg)
bb.data.setVar('RDEPENDS_' + metapkg, ' '.join(metapkg_rdepends), d)
d.setVar('DESCRIPTION_' + metapkg, 'Kernel modules meta package')
packages.append(metapkg)
bb.data.setVar('PACKAGES', ' '.join(packages), d)
}
# 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
size=`ls -l ${KERNEL_OUTPUT} | awk '{ print $5}'`
if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then
rm ${KERNEL_OUTPUT}
die "This kernel (size=$size > ${KERNEL_IMAGE_MAXSIZE}) is too big for your device. Please reduce the size of the kernel by making more of it modular."
fi
fi
}
addtask sizecheck before do_install after do_compile
KERNEL_IMAGE_BASE_NAME ?= "${KERNEL_IMAGETYPE}-${PV}-${PR}-${MACHINE}-${DATETIME}"
# Don't include the DATETIME variable in the sstate package signatures
KERNEL_IMAGE_BASE_NAME[vardepsexclude] = "DATETIME"
KERNEL_IMAGE_SYMLINK_NAME ?= "${KERNEL_IMAGETYPE}-${MACHINE}"
kernel_do_deploy() {
install -m 0644 ${KERNEL_OUTPUT} ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
tar -cvzf ${DEPLOYDIR}/modules-${KERNEL_VERSION}-${PR}-${MACHINE}.tgz -C ${D} lib
fi
if test "x${KERNEL_IMAGETYPE}" = "xuImage" ; then
if test -e arch/${ARCH}/boot/uImage ; then
cp arch/${ARCH}/boot/uImage ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
elif test -e arch/${ARCH}/boot/compressed/vmlinux ; then
${OBJCOPY} -O binary -R .note -R .comment -S arch/${ARCH}/boot/compressed/vmlinux linux.bin
uboot-mkimage -A ${ARCH} -O linux -T kernel -C none -a ${UBOOT_ENTRYPOINT} -e ${UBOOT_ENTRYPOINT} -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
rm -f linux.bin
else
${OBJCOPY} -O binary -R .note -R .comment -S vmlinux linux.bin
rm -f linux.bin.gz
gzip -9 linux.bin
uboot-mkimage -A ${ARCH} -O linux -T kernel -C gzip -a ${UBOOT_ENTRYPOINT} -e ${UBOOT_ENTRYPOINT} -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin.gz ${DEPLOYDIR}/${KERNEL_IMAGE_BASE_NAME}.bin
rm -f linux.bin.gz
fi
fi
cd ${DEPLOYDIR}
rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.bin
ln -sf ${KERNEL_IMAGE_BASE_NAME}.bin ${KERNEL_IMAGE_SYMLINK_NAME}.bin
cp ${COREBASE}/meta/files/deploydir_readme.txt ${DEPLOYDIR}/README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
}
do_deploy[dirs] = "${DEPLOYDIR} ${B}"
addtask deploy before do_build after do_install
EXPORT_FUNCTIONS do_deploy
# perf must be enabled in individual kernel recipes
PACKAGES =+ "perf-dbg perf"
FILES_perf = "${bindir}/* \
${libexecdir}"
FILES_perf-dbg = "${FILES_${PN}-dbg}"