From 012a13bc28e9f556fcfca3d25d233db39a4d3c12 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 14 Nov 2013 19:57:36 -0800 Subject: [PATCH] fix(cros-kernel2.eclass): Add kernel modules to initramfs. Since we need to both bundle modules into the initramfs as well as bundle the initramfs into the kernel image we need to update a pre-built image with the user space tools as part of the kernel build process. This seemed the best scheme, the alternatives were: - Unpack bootengine.cpio to a temporary directory, build and install kernel modules into that temporary directory, pass that directory plus a config file listing what device nodes to the kernel build. - Build kernel modules and generate a fresh bootengine.cpio using the update-bootengine tool. This would require calling sudo (and breaking out of the sandbox in the process) in the middle of the ebuild. --- .../coreos-overlay/eclass/cros-kernel2.eclass | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/cros-kernel2.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/cros-kernel2.eclass index d5db734ca0..c5185c1e45 100644 --- a/sdk_container/src/third_party/coreos-overlay/eclass/cros-kernel2.eclass +++ b/sdk_container/src/third_party/coreos-overlay/eclass/cros-kernel2.eclass @@ -91,6 +91,26 @@ install_kernel_sources() { "${D}/${dest_build_dir}/Makefile" || die } +# @FUNCTION: update_bootengine_cpio +# @DESCRIPTION: +# Append files in the given directory to the bootengine cpio. +# Allows us to stick kernel modules into the initramfs built into bzImage. +update_bootengine_cpio() { + local extra_root="$1" + local cpio_path="$(cros-workon_get_build_dir)/bootengine.cpio" + local cpio_args=(--create --append --null + # dracut uses the 'newc' cpio format + --format=newc + # squash file ownership to root for new files. + --owner=root:root + ) + + echo "Updating bootengine.cpio" + (cd "${extra_root}" && \ + find -depth -print0 | cpio "${cpio_args[@]}" -F "${cpio_path}" || \ + die "cpio update failed!") +} + kmake() { local kernel_arch=$(tc-arch-kernel) @@ -127,6 +147,17 @@ cros-kernel2_src_configure() { } cros-kernel2_src_compile() { + # Build both vmlinux and modules (moddep checks symbols in vmlinux) + kmake vmlinux modules + + # Install modules and add them to the initramfs image + local bootengine_root="${T}/bootengine" + kmake INSTALL_MOD_PATH="${bootengine_root}" \ + INSTALL_MOD_STRIP="--strip-unneeded" \ + modules_install + update_bootengine_cpio "${bootengine_root}" + + # Build the final kernel image (bzImage) kmake }