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 <jpiotrowski@microsoft.com>
This commit is contained in:
Jeremi Piotrowski 2024-03-08 15:54:18 +00:00
parent 601adeb434
commit a134b02a48

View File

@ -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() {