From 35fd55a41a0c68351a050c4ae9e8f419ecb7fb54 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Tue, 19 Nov 2013 13:36:23 -0800 Subject: [PATCH] fix(cros-kernel2.eclass): Fix cpio update steps. The kernel is much more particular about how it handles the cpio format than GNU's cpio tool. Two things: - Don't use the -depth option to find, cpio documentation recommends using it (the directory comes after the contents so set the permissions on the dir last in case it is overly restrictive) but the kernel thinks the other direction and doesn't put things into a directory that does not (yet) exist. - Don't add anything under /lib which is a symlink in the original file. Adding /lib as a directory later replaces the earlier /lib symlink. Again the user space tool thinks in the other direction and will happily dereference the symlink while extracting, preserving it. CPIO CPIO CPIO! --- .../coreos-overlay/eclass/cros-kernel2.eclass | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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 5931c6ecef..b7f7f60419 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 @@ -94,6 +94,21 @@ install_kernel_sources() { "${D}/${dest_build_dir}/Makefile" || die } +# @FUNCTION: get_bootengine_lib +# @DESCRIPTION: +# Check if /lib is a symlink in the current cpio. If so we need to use +# the target path (usually lib64) instead when adding new things. +# When extracting with GNU cpio the first entry (the symlink) wins but +# in the kernel the second entry (as a directory) definition wins. +# As if using cpio isn't bad enough already. +# If lib doesn't exist or isn't a symlink then nothing is returned. +get_bootengine_lib() { + local cpio_path="$(cros-workon_get_build_dir)/bootengine.cpio" + cpio -itv --quiet < "${cpio_path}" | \ + awk '$1 ~ /^l/ && $9 == "lib" { print $11 }' + assert +} + # @FUNCTION: update_bootengine_cpio # @DESCRIPTION: # Append files in the given directory to the bootengine cpio. @@ -110,8 +125,8 @@ update_bootengine_cpio() { echo "Updating bootengine.cpio" (cd "${extra_root}" && \ - find -depth -print0 | cpio "${cpio_args[@]}" -F "${cpio_path}" || \ - die "cpio update failed!") + find . -print0 | cpio "${cpio_args[@]}" -F "${cpio_path}") || \ + die "cpio update failed!" } kmake() { @@ -166,6 +181,11 @@ cros-kernel2_src_compile() { kmake INSTALL_MOD_PATH="${bootengine_root}" \ INSTALL_MOD_STRIP="--strip-unneeded" \ modules_install + + local bootengine_lib=$(get_bootengine_lib) + if [[ -n "${bootengine_lib}" ]]; then + mv "${bootengine_root}/lib" "${bootengine_root}/${bootengine_lib}" + fi update_bootengine_cpio "${bootengine_root}" # Build the final kernel image