From a134b02a48d600731fd02e58156f16e662ae1b0e Mon Sep 17 00:00:00 2001 From: Jeremi Piotrowski Date: Fri, 8 Mar 2024 15:54:18 +0000 Subject: [PATCH] coreos-kernel.eclass: Adapt install_build_source for compatibility build/source, which is accidentally an empty directory, needs to be a symlink so that Gentoo kmod ebuilds can build when setting KERNEL_DIR=/lib/modules/.../build. They detect the proper layout with the symlink. The other issue is building the Nvidia driver with SYSSRC=/lib/modules/.../build. This works on Ubuntu but fails on Flatcar. Ubuntus build directory contains symlinks to includes from the source tree so recreate the same layout. Signed-off-by: Jeremi Piotrowski --- .../coreos-overlay/eclass/coreos-kernel.eclass | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass index 6eb7362dd8..21fa398eb3 100644 --- a/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass +++ b/sdk_container/src/third_party/coreos-overlay/eclass/coreos-kernel.eclass @@ -243,6 +243,22 @@ install_build_source() { --owner=root:root \ --dereference \ "${D}/usr/lib/modules/${KV_FULL}" || die + # ./build/source is a symbolic link so cpio ends up creating an empty dir. + # Restore the symlink. + pushd "${D}/usr/lib/modules/${KV_FULL}" + rmdir build/source || die + ln -sr source build || die + # Symlink includes into the build directory to resemble Ubuntu's /lib/modules + # layout. This lets the Nvidia driver build when passing SYSSRC=/lib/modules/../build + # instead of requiring SYSOUT/SYSSRC. + { + find source/include -mindepth 1 -maxdepth 1 -type d + find source/arch/${kernel_arch}/include -mindepth 1 -maxdepth 1 -type d + } | while read src; do + dst="${src/source/build}" + ln -sr "${src}" "${dst}" || die + done || die + popd } coreos-kernel_pkg_pretend() {