Initial commit of packaging

This commit is contained in:
Neal Gompa 2025-04-07 21:32:23 -04:00
parent 71323421bc
commit 0db5e933f1
6 changed files with 250 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.tar.gz
*.run

View File

@ -0,0 +1,45 @@
From a2e9b73f8d3f593eed007ebfe51dabc9a0e410c2 Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@almalinux.org>
Date: Mon, 7 Apr 2025 19:36:18 -0400
Subject: [PATCH] kernel-open/nvidia-drm: Enable kernel mode-setting by default
The general expectation for the Linux graphics stack for more than
a decade has been to use kernel mode-setting. It is now a requirement
for things to work properly on Wayland-based graphical environments,
so flip the default to use kernel mode-setting by default.
Signed-off-by: Neal Gompa <ngompa@almalinux.org>
---
kernel-open/nvidia-drm/nvidia-drm-linux.c | 2 +-
kernel-open/nvidia-drm/nvidia-drm-os-interface.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel-open/nvidia-drm/nvidia-drm-linux.c b/kernel-open/nvidia-drm/nvidia-drm-linux.c
index 3cb1815d..209cb469 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-linux.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-linux.c
@@ -31,7 +31,7 @@
MODULE_PARM_DESC(
modeset,
- "Enable atomic kernel modesetting (1 = enable, 0 = disable (default))");
+ "Enable atomic kernel modesetting (1 = enable (default), 0 = disable)");
module_param_named(modeset, nv_drm_modeset_module_param, bool, 0400);
#if defined(NV_DRM_FBDEV_AVAILABLE)
diff --git a/kernel-open/nvidia-drm/nvidia-drm-os-interface.c b/kernel-open/nvidia-drm/nvidia-drm-os-interface.c
index 7617476d..f22afd77 100644
--- a/kernel-open/nvidia-drm/nvidia-drm-os-interface.c
+++ b/kernel-open/nvidia-drm/nvidia-drm-os-interface.c
@@ -41,7 +41,7 @@
#include <drm/drmP.h>
#endif
-bool nv_drm_modeset_module_param = false;
+bool nv_drm_modeset_module_param = true;
bool nv_drm_fbdev_module_param = true;
void *nv_drm_calloc(size_t nmemb, size_t size)
--
2.48.1

View File

@ -0,0 +1,37 @@
From 38b7e1478b58b983724ec817562301edd5c244a2 Mon Sep 17 00:00:00 2001
From: Neal Gompa <ngompa@almalinux.org>
Date: Mon, 7 Apr 2025 19:34:49 -0400
Subject: [PATCH] src/nvidia/Makefile: Drop broken addition of userspace linker
flags
The Makefile currently causes the package build of the kernel modules
to fail with the following error:
ld: unrecognized option '-Wl,-z,relro'
ld: use the --help option for usage information
make[1]: *** [Makefile:214: _out/Linux_x86_64/nv-kernel.o] Error 1
make: *** [Makefile:34: src/nvidia/_out/Linux_x86_64/nv-kernel.o] Error 2
Dropping this line fixes this issue.
Signed-off-by: Neal Gompa <ngompa@almalinux.org>
---
src/nvidia/Makefile | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/nvidia/Makefile b/src/nvidia/Makefile
index 931a74c0..423414af 100644
--- a/src/nvidia/Makefile
+++ b/src/nvidia/Makefile
@@ -208,8 +208,6 @@ all: $(NV_KERNEL_O)
LINKER_SCRIPT = nv-kernel.ld
-NV_KERNEL_O_LDFLAGS += $(LDFLAGS)
-
$(NV_KERNEL_O): $(OBJS) $(EXPORTS_LINK_COMMAND) $(LINKER_SCRIPT)
$(call quiet_cmd,LD) \
$(NV_KERNEL_O_LDFLAGS) \
--
2.48.1

View File

@ -0,0 +1,11 @@
Conflicts: dkms-%{kmodname}
# Conflict with legacy driver
Conflicts: dkms-nvidia kmod-nvidia
# Declare ourselves as a provider of the nvidia kernel module
Conflicts: nvidia-kmod
Provides: nvidia-kmod = 3:%{version}-%{release}
# Require our parts of the stack
Requires: nvidia-open-kmod = %{version}-%{release}
Requires: nvidia-gsprm-gpu-firmware = %{version}
# Install if negativo17 packaged userspace libraries are being installed
Supplements: (kernel%{?1:-%1} and (nvidia-driver-libs%{?_isa} or nvidia-driver-cuda-libs%{?_isa}))

View File

@ -0,0 +1,44 @@
# Backport missing architecture macros
%{!?x86_64: %global x86_64 x86_64 amd64 em64t}
%{!?arm64: %global arm64 aarch64}
Name: nvidia-gsprm-gpu-firmware
Version: 570.133.07
Release: 0%{?dist}.1
Summary: NVIDIA GSP-RM GPU firmware
License: LicenseRef-NVIDIA
URL: https://nvidia.com
Source0: https://download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run
ExclusiveArch: %{x86_64} %{arm64} noarch
BuildArch: noarch
%description
This package provides the NVIDIA GSP-RM GPU firmware
for the NVIDIA GPU driver for Turing and newer GPUs.
%prep
%setup -qcT
sh %{SOURCE0} --extract-only
%build
# Nothing to do
%install
# Install gpu-open firmware and license files
mkdir -p %{buildroot}%{_prefix}/lib/firmware/nvidia/%{version}
cp -a NVIDIA-Linux-x86_64-%{version}/firmware/* %{buildroot}%{_prefix}/lib/firmware/nvidia/%{version}
%files
%license NVIDIA-Linux-x86_64-%{version}/LICENSE
%dir %{_prefix}/lib/firmware/nvidia
%{_prefix}/lib/firmware/nvidia/%{version}/
%changelog
* Mon Apr 07 2025 Neal Gompa <ngompa@almalinux.org> - 570.133.07-0.1
- Initial package

111
nvidia-open-kmod.spec Normal file
View File

@ -0,0 +1,111 @@
# Backport missing architecture macros
%{!?x86_64: %global x86_64 x86_64 amd64 em64t}
%{!?arm64: %global arm64 aarch64}
# Because Red Hat broke this macro by not including kernel-rpm-macros in the base buildroot
%{!?kernel_module_package_buildreqs:%global kernel_module_package_buildreqs kernel-devel kernel-abi-stablelists redhat-rpm-config kernel-rpm-macros elfutils-libelf-devel kmod}
%global kmodname nvidia-open
# Signing kernel modules requires certs, which should be defined in the build environment
%bcond_with modsign
%{!?modsign_privkey:%global modsign_privkey %{nil}}
%{!?modsign_pubkey:%global modsign_pubkey %{nil}}
%if %{with modsign}
# XXX: For the moment, signing kmods and debuginfo are incompatible
%global debug_package %{nil}
%endif
Name: %{kmodname}-kmod
Version: 570.133.07
Release: 0%{?dist}.1
Summary: Kernel module (kmod) for NVIDIA GPU hardware
License: GPL-2.0-only and MIT
URL: https://github.com/NVIDIA/open-gpu-kernel-modules
Source0: %{url}/archive/%{version}/open-gpu-kernel-modules-%{version}.tar.gz
Patch0: 0001-src-nvidia-Makefile-Drop-broken-addition-of-userspac.patch
Patch1: 0001-kernel-open-nvidia-drm-Enable-kernel-mode-setting-by.patch
# For kmodtool
Source10: kmod-%{kmodname}.spec.preamble
# patch dependencies
BuildRequires: git-core
# kernel module package macros were split out sometime after EL7...
BuildRequires: kernel-rpm-macros
# kmod dependencies
BuildRequires: %kernel_module_package_buildreqs
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: make
# Depend on negativo17 userspace libraries
Requires: nvidia-driver-libs%{?_isa} = 3:%{version}
# Only supported architectures for the driver
ExclusiveArch: %{x86_64} %{arm64}
%{?kernel_module_package:%kernel_module_package -n %{kmodname} -p %{S:10}}
%description
This package contains the kernel modules for providing
hardware support for the NVIDIA Turing (GTX 16/RTX 20)
and newer models of GPU hardware.
%prep
%autosetup -n open-gpu-kernel-modules-%{version} -S git_am
%if %{with modsign} && "%{modsign_pubkey}" != "%{nil}"
# For documenting the signing key
cp %{modsign_pubkey} kmod-signing-ca.cer
%endif
for flavor in %{flavors_to_build}; do
cp -a ../open-gpu-kernel-modules-%{version} ../%{name}-%{version}-kmodbuild
mv ../%{name}-%{version}-kmodbuild .
done
%build
# This module is useless
export NV_EXCLUDE_KERNEL_MODULES=nvidia-peermem
for flavor in %{flavors_to_build}; do
pushd %{name}-%{version}-kmodbuild
export SYSSRC=%{kernel_source $flavor}
%make_build modules
%if %{with modsign} && "%{modsign_privkey}" != "%{nil}" && "%{modsign_pubkey}" != "%{nil}"
for kmod in $PWD/*.ko; do
%{kernel_source $flavor}/scripts/sign-file -p sha256 %{modsign_privkey} %{modsign_pubkey} $kmod
done
%endif
popd
done
%install
export INSTALL_MOD_PATH=%{buildroot}
# This module is useless
export NV_EXCLUDE_KERNEL_MODULES=nvidia-peermem
for flavor in %{flavors_to_build}; do
pushd %{name}-%{version}-kmodbuild
export SYSSRC=%{kernel_source $flavor}
%{__make} V=1 modules_install
done
%files
%license COPYING
%doc README.md
%if %{with modsign} && "%{modsign_pubkey}" != "%{nil}"
%doc kmod-signing-ca.cer
%endif
%changelog
* Mon Apr 07 2025 Neal Gompa <ngompa@almalinux.org> - 570.133.07-0.1
- Initial package