x11-drivers/nvidia-drivers: build driver against /lib/modules

There are two ways to build the nvidia-driver - either against a full kernel
source tree in /usr/src/linux, or against a slim kernel-devel equivalent in
/lib/modules/*/build. The /lib/modules/*/build is provided by
sys-kernel/coreos-module, see `install_build_source`. The interesting thing is
that in absence of --kernel-source-path, nvidia-installer will autodetect which
to use and already builds against /lib/modules/*/build on Flatcar right now. By
passing --kernel-name, we make that choice explicit and this allows us to skip
the emerge steps of the build.

Since this runs in the developer container, there is also no point in trying to
execute systemctl or depmod, so pass the flags to disable usage of those.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
This commit is contained in:
Jeremi Piotrowski 2022-04-25 09:50:56 +02:00
parent b9f2da8566
commit 85f7b86c00

View File

@ -2,17 +2,16 @@
. /usr/share/coreos/release . /usr/share/coreos/release
NVIDIA_DRIVER_BASENAME="$1" NVIDIA_DRIVER_BASENAME="$1"
KERNEL_NAME="$(ls /lib/modules)"
emerge-gitclone
emerge -gKv coreos-sources > /dev/null
cp "/usr/lib64/modules/$(ls /usr/lib64/modules)/build/.config" /usr/src/linux/
make -C /usr/src/linux modules_prepare
cd "/nvidia/${NVIDIA_DRIVER_BASENAME}" cd "/nvidia/${NVIDIA_DRIVER_BASENAME}"
./nvidia-installer -s -n \ ./nvidia-installer -s -n \
--no-check-for-alternate-installs \ --no-check-for-alternate-installs \
--no-kernel-module-source \ --no-kernel-module-source \
--kernel-name="${KERNEL_NAME}" \
--no-opengl-files \ --no-opengl-files \
--no-distro-scripts \ --no-distro-scripts \
--no-systemd \
--skip-depmod \
--kernel-install-path="${PWD}" \ --kernel-install-path="${PWD}" \
--log-file-name="${PWD}/nvidia-installer.log" || true --log-file-name="${PWD}/nvidia-installer.log" || true