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.
This commit is contained in:
Michael Marineau 2013-11-14 19:57:36 -08:00
parent a38632b0ea
commit 012a13bc28

View File

@ -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
}