File nvidia-gfxG02.spec of Package x11-video-nvidiaG02
#
# spec file for package nvidia-gfxG02
#
# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# kABI symbols are no longer generated with openSUSE >= 13.1, since they
# became useless with zypper's 'multiversion' feature enabled for the kernel
# as default (multiple kernels can be installed at the same time; with
# different kABI symbols of course!). So it has been decided to match on the
# uname output of the kernel only. We cannot use that one for NVIDIA, since we
# only build against GA kernel. So let's get rid of this requirement.
#
%global __requires_exclude kernel-uname-r*
Name: nvidia-gfxG02
Version: 304.137
Release: 0
License: SUSE-NonFree
Summary: NVIDIA graphics driver kernel module for GeForce 6xxx and newer GPUs
URL: https://www.nvidia.com/object/unix.html
Group: System/Kernel
Source0: http://download.nvidia.com/XFree86/Linux-x86/%{version}/NVIDIA-Linux-x86-%{version}.run
Source1: http://download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}.run
Source3: preamble
Source6: fetch.sh
Source7: README
Source8: kmp-filelist
Source10: kmp-post.sh
Source12: my-find-supplements
Source13: kmp-preun.sh
Source15: pci_ids-%{version}.legacy
Source16: nvidia-gfxG02.rpmlintrc
Patch1: NVIDIA_kernel-define_linux.diff
Patch2: 0001-disable-mtrr-4.3.patch
Patch3: 0002-pud-offset-4.12.patch
Patch4: 0003-nvidia-drm-pci-init-4.14.patch
Patch5: 0004-timer-4.15.patch
Patch6: 0005-usercopy-4.16.patch
Patch7: 0006-do_gettimeofday-5.0.patch
Patch8: 0007-subdirs-5.3.patch
Patch9: 0008-on-each-cpu-5.3.patch
Patch10: 0009-remove-drmp-5.5.patch
Patch11: 0010-proc-ops-5.6.patch
Patch12: 0011-kernel-5.7.0-setmemoryarray.patch
Patch13: 0012-kernel5.8.patch
Patch14: 0013-kernel5.9.patch
Patch15: 0014-import-drm_legacy_pci_init-exit-from-src-linux-5.9.1.patch
Patch16: 0015-add-static-and-nv_-prefix-to-copied-drm-legacy-bits.patch
Patch17: 0016-fix-mistake.patch
Patch18: 0016-vmalloc5.9.patch
Patch19: 0017-patch-14-kernel-5.11.patch
Patch20: 0018-kernel5.14.patch
Patch21: 0019-kernel-5.16.patch
Patch22: 0020-kernel-5.17.patch
Patch23: 0021-kernel-5.18-opensusedit.patch
Patch24: 0022-kernel-6.0-opensusedit.patch
Patch25: 0023-kernel-6.2.patch
Patch26: 0024-kernel-6.3.patch
Patch27: 0025-kernel-6.5.patch
Patch28: 0026-gcc14-fix.patch
NoSource: 0
NoSource: 1
NoSource: 6
NoSource: 7
BuildRequires: kernel-source
BuildRequires: kernel-syms
%if 0%{?sle_version} >= 120400 && !0%{?is_opensuse}
BuildRequires: kernel-syms-azure
%endif
BuildRequires: module-init-tools
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %ix86 x86_64
# patch the kmp template
%define kmp_template -t
%define kmp_filelist kmp-filelist
%define kmp_post kmp-post.sh
%define kmp_preun kmp-preun.sh
%define kmp_template_name /usr/lib/rpm/kernel-module-subpackage
%(sed -e '/^%%post\>/ r %_sourcedir/%kmp_post' -e '/^%%preun\>/ r %_sourcedir/%kmp_preun' -e '/^Provides: multiversion(kernel)/d' %kmp_template_name >%_builddir/nvidia-kmp-template)
# moved from %kmp_post snippet to this place (boo#1145316)
%(sed -i '/^%%posttrans/i \
exit $RES' %_builddir/nvidia-kmp-template)
# Leap 42.3/sle12-sp3 needs this to recompile module after having
# uninstalled drm-kmp package (%triggerpostun)
%if 0%{?suse_version} < 1320 && 0%{?sle_version} >= 120300
%(cp %_builddir/nvidia-kmp-template %_builddir/nvidia-kmp-template.old)
%(echo "%triggerpostun -n %%{-n*}-kmp-%1 -- drm-kmp-default" >> %_builddir/nvidia-kmp-template)
%(cat %_sourcedir/%kmp_preun >> %_builddir/nvidia-kmp-template)
%(cat %_sourcedir/%kmp_post >> %_builddir/nvidia-kmp-template)
%(echo 'nvr=%%{-n*}-kmp-%1-%_this_kmp_version-%%{-r*}' >> %_builddir/nvidia-kmp-template)
%(echo 'wm2=/usr/lib/module-init-tools/weak-modules2' >> %_builddir/nvidia-kmp-template)
%(echo 'if [ -x $wm2 ]; then' >> %_builddir/nvidia-kmp-template)
%(echo ' %%{-b:KMP_NEEDS_MKINITRD=1} INITRD_IN_POSTTRANS=1 /bin/bash -${-/e/} $wm2 --add-kmp $nvr' >> %_builddir/nvidia-kmp-template)
%(echo 'fi' >> %_builddir/nvidia-kmp-template)
# moved from %kmp_post snippet to this place (boo#1145316)
%(echo 'exit $RES' >> %_builddir/nvidia-kmp-template)
# Let all initrds get generated by regenerate-initrd-posttrans
# if drm-kmp-default gets uninstalled
%(echo "%%{?regenerate_initrd_posttrans}" >> %_builddir/nvidia-kmp-template)
%endif
%define kver %(for dir in /usr/src/linux-obj/*/*/; do make %{?jobs:-j%jobs} -s -C "$dir" kernelversion; break; done |perl -ne '/(\\d+)\\.(\\d+)\\.(\\d+)?/&&printf "%%d%%02d%%03d\\n",$1,$2,$3')
%define x_flavors kdump um debug xen xenpae
%kernel_module_package %kmp_template %_builddir/nvidia-kmp-template -p %_sourcedir/preamble -f %_sourcedir/%kmp_filelist -x %x_flavors
# supplements no longer depend on the driver
%define pci_id_file %_sourcedir/pci_ids-%version.legacy
# rpm 4.9+ using the internal dependency generators
%define __ksyms_supplements %_sourcedir/my-find-supplements %pci_id_file %name
# older rpm
%define __find_supplements %_sourcedir/my-find-supplements %pci_id_file %name
%description
This package provides the closed-source NVIDIA graphics driver kernel
module for GeForce 6xxx and newer GPUs.
%package KMP
License: SUSE-NonFree
Summary: NVIDIA graphics driver kernel module for GeForce 6xxx and newer GPUs
Group: System/Kernel
%description KMP
This package provides the closed-source NVIDIA graphics driver kernel
module for GeForce 6xxx and newer GPUs.
%prep
echo "kver = %kver"
%setup -T -c %{name}-%{version}
%ifarch %ix86
sh %{SOURCE0} -x
%endif
%ifarch x86_64
sh %{SOURCE1} -x
%endif
#rm -rf NVIDIA-Linux-x86*-%{version}-*/usr/src/nv/precompiled
mkdir -p source/%{version}
cp NVIDIA-Linux-x86*-%{version}/kernel/* source/%{version} || :
pushd source/%{version}
# mark support as external
echo "nvidia.ko external" > Module.supported
ln -s Makefile.kbuild Makefile
### Bug 123456
#sed -i /0x1234/d %_sourcedir/pci_ids-%{version}
#sed -i /0x1234/d %_sourcedir/pci_ids-%{version}.new
### Bugs 768020, 751730
cat >> %_sourcedir/pci_ids-%{version} << EOF
0x0FFB 0x0FFB
0x0FFC 0x0FFC
EOF
cat >> %_sourcedir/pci_ids-%{version}.new << EOF
0x0FFB 0x0FFB
0x0FFC 0x0FFC
EOF
chmod 755 %_sourcedir/my-find-supplements*
%patch -P 1
%patch -P 2 -p1
%patch -P 3 -p1
%patch -P 4 -p1
%patch -P 5 -p1
%patch -P 6 -p1
%patch -P 7 -p1
%patch -P 8 -p1
%patch -P 9 -p1
%patch -P 10 -p1
%patch -P 11 -p1
%patch -P 12 -p1
%patch -P 13 -p1
%patch -P 14 -p1
%patch -P 15 -p1
%patch -P 16 -p1
%patch -P 17 -p1
%patch -P 18 -p1
%patch -P 19 -p1
%patch -P 20 -p1
%patch -P 21 -p1
%patch -P 22 -p1
%patch -P 23 -p1
%patch -P 24 -p1
%patch -P 25 -p1
%patch -P 26 -p1
%patch -P 27 -p1
%if 0%{?suse_version} >= 1600
%patch -P 28 -p2
%endif
rm -f *.orig
popd
mkdir obj
sed -i -e 's,-o "$ARCH" = "x86_64",-o "$ARCH" = "x86_64" -o "$ARCH" = "x86",' source/*/conftest.sh
%build
export EXTRA_CFLAGS='-DVERSION=\"%{version}\"'
for flavor in %flavors_to_build; do
src=/lib/modules/$(make %{?jobs:-j%jobs} -siC %{kernel_source $flavor} kernelrelease)/source
if ! test -d "$src"; then
src=/usr/src/linux
fi
rm -rf obj/$flavor
%if 0%{?suse_version} >= 1600
touch $PWD/source/%{version}/.nv-kernel.o.cmd
%endif
cp -r source obj/$flavor
make %{?jobs:-j%jobs} -C /usr/src/linux-obj/%_target_cpu/$flavor modules M=$PWD/obj/$flavor/%{version} SYSSRC="$src" SYSOUT=/usr/src/linux-obj/%_target_cpu/$flavor
pushd $PWD/obj/$flavor/%{version}
make %{?jobs:-j%jobs} -f Makefile.kbuild nv-linux.o SYSSRC="$src" SYSOUT=/usr/src/linux-obj/%_target_cpu/$flavor
popd
done
%install
### do not sign the ghost .ko file, it is generated on target system anyway
export BRP_PESIGN_FILES=""
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=updates
for flavor in %flavors_to_build; do
export SYSSRC=/lib/modules/$(make %{?jobs:-j%jobs} -siC %{kernel_source $flavor} kernelrelease)/source
if ! test -d "$SYSSRC"; then
SYSSRC=/usr/src/linux
fi
make %{?jobs:-j%jobs} -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install M=$PWD/obj/$flavor/%{version}
#install -m 644 $PWD/obj/$flavor/%{version}/{nv-linux.o,nv-kernel.o} \
# %{buildroot}/lib/modules/*-$flavor/updates
mkdir -p %{buildroot}/usr/src/kernel-modules/nvidia-%{version}-${flavor}
%if 0%{?suse_version} >= 1600
touch %{buildroot}/usr/src/kernel-modules/nvidia-%{version}-${flavor}/.nv-kernel.o.cmd
%endif
cp source/%{version}/* %{buildroot}/usr/src/kernel-modules/nvidia-%{version}-${flavor}
done
mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d
for flavor in %flavors_to_build; do
echo "blacklist nouveau" > %{buildroot}%{_sysconfdir}/modprobe.d/nvidia-$flavor.conf
done
%changelog