From 19bda7f2c2dac6363468a49295c38f2095c67c98 Mon Sep 17 00:00:00 2001 From: Andrea Adami Date: Tue, 12 Jul 2011 00:33:11 +0200 Subject: 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 * Signed-off-by:Paul Sokolovsky * * 'Remove usage of non-standard variables (DEPLOY_TO) and random renaming * of output.' * commit 456ba7ffd159821e86ad7ad4b66ec7d5790bd054 * Richard Purdie * * 'Fis typo in do_builtin_initramfs.' * commit 37f2fe4b801df832e93553a08eff24fec736c7d4 * Signed-off-by:Paul Sokolovsky * * 'comment initramfs stuff till rootfs locking works properly (initramfs * should be optional as well)' * commit 2818d8b7be1a0d9a59ad3528091d47517d59328b * Signed-off-by: Koen Kooi * * 'get initramfs stuff working * commit 1642b3e8fc81c666713951fdd4e7ff9a50d1c5a8 * Signed-off-by: Thomas Kunze * * 'Fix INITRAMFS logic to stop breaking builds for people not using it' * commit dcf3049eb9eedf0838af59969b3f70a43298d3d7 * Signed-off-by: Richard Purdie * * '-change initramfs-logic' * commit 3e3f297457138e96e2b652658675796853eb0293 * Signed-off-by: Thomas Kunze * * 'move initramfs stuff to configure so we can do postprocessing * on it with do_configure_append' * commit fc03e2be0b4470748a8b7707cea7293303adc424 * Signed-off-by: Koen Kooi * * 'copy gz, lzo, lzma initramfs cpio images.' * commit 572abc3fdd1076ca35d8c15d269cc9d862101805 * Signed-off-by: Andrea Adami * * 'move the kernel size check to linux-kexecboot.inc.' * commit 45f82a941c77e9d747814fa1e337ba803475d327 * Signed-off-by: Andrea Adami * * 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 Signed-off-by: Richard Purdie --- meta/classes/kernel.bbclass | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'meta/classes') diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass index 943252ab9..1a71df64b 100644 --- a/meta/classes/kernel.bbclass +++ b/meta/classes/kernel.bbclass @@ -7,6 +7,8 @@ DEPENDS += "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}depmod virtual/$ INHIBIT_DEFAULT_DEPS = "1" KERNEL_IMAGETYPE ?= "zImage" +INITRAMFS_IMAGE ?= "" +INITRAMFS_TASK ?= "" python __anonymous () { kerneltype = bb.data.getVar('KERNEL_IMAGETYPE', d, 1) or '' @@ -14,6 +16,10 @@ python __anonymous () { depends = bb.data.getVar("DEPENDS", d, 1) depends = "%s u-boot-mkimage-native" % depends bb.data.setVar("DEPENDS", depends, d) + + image = bb.data.getVar('INITRAMFS_IMAGE', d, True) + if image: + bb.data.setVar('INITRAMFS_TASK', '${INITRAMFS_IMAGE}:do_rootfs', d) } inherit kernel-arch deploy @@ -179,8 +185,18 @@ kernel_do_configure() { cp "${WORKDIR}/defconfig" "${S}/.config" fi yes '' | oe_runmake oldconfig + + 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" + cp "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.$i + fi + done + fi } +kernel_do_configure[depends] += "${INITRAMFS_TASK}" + do_menuconfig() { export DISPLAY='${DISPLAY}' export DBUS_SESSION_BUS_ADDRESS='${DBUS_SESSION_BUS_ADDRESS}' -- cgit v1.2.3