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!
This commit is contained in:
Michael Marineau 2013-11-19 13:36:23 -08:00
parent f9a0b52c92
commit 35fd55a41a

View File

@ -94,6 +94,21 @@ install_kernel_sources() {
"${D}/${dest_build_dir}/Makefile" || die "${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 # @FUNCTION: update_bootengine_cpio
# @DESCRIPTION: # @DESCRIPTION:
# Append files in the given directory to the bootengine cpio. # Append files in the given directory to the bootengine cpio.
@ -110,8 +125,8 @@ update_bootengine_cpio() {
echo "Updating bootengine.cpio" echo "Updating bootengine.cpio"
(cd "${extra_root}" && \ (cd "${extra_root}" && \
find -depth -print0 | cpio "${cpio_args[@]}" -F "${cpio_path}" || \ find . -print0 | cpio "${cpio_args[@]}" -F "${cpio_path}") || \
die "cpio update failed!") die "cpio update failed!"
} }
kmake() { kmake() {
@ -166,6 +181,11 @@ cros-kernel2_src_compile() {
kmake INSTALL_MOD_PATH="${bootengine_root}" \ kmake INSTALL_MOD_PATH="${bootengine_root}" \
INSTALL_MOD_STRIP="--strip-unneeded" \ INSTALL_MOD_STRIP="--strip-unneeded" \
modules_install 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}" update_bootengine_cpio "${bootengine_root}"
# Build the final kernel image # Build the final kernel image