File nvidia-gfx.spec of Package nvidia-gfx
#
# spec file for package nvidia-gfx
#
# 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/
#
# norootforbuild
# nodebuginfo
# 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-gfx
BuildRequires: kernel-source kernel-syms module-init-tools
ExclusiveArch: %ix86 x86_64
License: SUSE-NonFree
Group: System/Kernel
Summary: NVIDIA graphics driver kernel module for GeForce4 GPUs
URL: https://www.nvidia.com/object/unix.html
Version: 96.43.23
Release: 0
Source0: http://download.nvidia.com/XFree86/Linux-x86/%{version}/NVIDIA-Linux-x86-%{version}-pkg1.run
Source1: http://download.nvidia.com/XFree86/Linux-x86_64/%{version}/NVIDIA-Linux-x86_64-%{version}-pkg2.run
Source3: preamble
Source4: pci_ids-%{version}
Source6: fetch.sh
Source7: README
Source8: pci_ids-%{version}.legacy
Source9: kmp-filelist
Source10: kmp-filelist-old
Source11: kmp-post.sh
Source12: kmp-post-old.sh
Source13: my-find-supplements
Source14: kmp-preun.sh
Source15: kmp-preun-old.sh
NoSource: 0
NoSource: 1
NoSource: 6
NoSource: 7
Patch1: nv-fix-xen.diff
Patch4: NVIDIA_kernel-1.0-9625-NOSMBUS.diff.txt
Patch5: load-failure.diff
Patch7: NVIDIA_kernel-2.6.25.diff
Patch8: sles10.diff
Patch9: nvidia-no_locked_io.patch
Patch10: NVIDIA_kernel-3.0-kdb.diff
Patch11: conftest.sh-generated_asm.diff
Patch12: nvidia-blacklist-register-mapping-195.diff
Patch13: nvidia-blacklist-vga-pmu-registers-195.diff
Patch14: nvidia-Makefile-3.4.diff
Patch15: nvidia-source-3.4.diff
Patch16: NVIDIA_kernel-define_linux.diff
Patch17: NVIDIA_kernel-define_linux-x86.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# patch the kmp template
%if %suse_version > 1100
%define kmp_template -t
%define kmp_filelist kmp-filelist
%define kmp_post kmp-post.sh
%define kmp_preun kmp-preun.sh
%else
%define kmp_template -s
%define kmp_filelist kmp-filelist-old
%define kmp_post kmp-post-old.sh
%define kmp_preun kmp-preun-old.sh
%endif
%if %suse_version > 1010
%define kmp_template_name /usr/lib/rpm/kernel-module-subpackage
%else
%define kmp_template_name /usr/lib/rpm/rpm-suse-kernel-module-subpackage
%endif
%(sed -e '/^%%post\>/ r %_sourcedir/%kmp_post' -e '/^%%preun\>/ r %_sourcedir/%kmp_preun' %kmp_template_name >%_builddir/nvidia-kmp-template)
%kernel_module_package %kmp_template %_builddir/nvidia-kmp-template -p %_sourcedir/preamble -f %_sourcedir/%kmp_filelist -x kdump um xen xenpae ec2 debug
# moved from %kmp_post snippet to this place (boo#1145316)
%(sed -i '/^%%preun/i \
exit $RES' %_builddir/nvidia-kmp-template)
# supplements no longer depend on the driver
%if %suse_version > 1010
%define pci_id_file %_sourcedir/pci_ids-%version.legacy
%else
%define pci_id_file %_sourcedir/pci_ids-%version
%endif
# 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 GeForce4 GPUs.
%package KMP
License: SUSE-NonFree
Summary: NVIDIA graphics driver kernel module for GeForce4 GPUs
Group: System/Kernel
%description KMP
This package provides the closed-source NVIDIA graphics driver kernel
module for GeForce4 GPUs.
%prep
%define kver %(for dir in /usr/src/linux-obj/*/*/; do make -s -C "$dir" kernelversion; break; done |perl -ne '/(\\d+)\\.(\\d+)\\.(\\d+)?/&&printf "%%d%%02d%%02d\\n",$1,$2,$3')
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}-*/usr/src/nv/* source/%{version} || :
pushd source/%{version}
# mark support as external
echo "nvidia.ko external" > Module.supported
ln -s Makefile.kbuild Makefile
patch -p3 -s < %{P:4}
#patch -p0 -s < %{P:5}
# undocumented/secret devices (Bugs #201268, #205642)
cat >> %_sourcedir/pci_ids-%{version} << EOF
0x0221 GeForce 6200
0x0247 GeForce Go 6100
EOF
chmod 755 %_sourcedir/my-find-supplements*
#patch1
#patch -p1 -s < %{P:1}
%patch7
%if %suse_version < 1020
%patch8
%endif
#%patch9 -p1
%patch10
%patch11
#%patch12 -p3
#%patch13 -p3
%patch14 -p3
%patch15 -p1
%ifarch x86_64
%patch16 -p0
%else
%patch17 -p0
%endif
rm *.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 -sC %{kernel_source $flavor} kernelrelease)/source
if ! test -d "$src"; then
src=/usr/src/linux
fi
%if 0%{?suse_version} <= 1020
export SYSSRC=$src
%endif
rm -rf obj/$flavor
cp -r source obj/$flavor
make -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 -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=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=updates
for flavor in %flavors_to_build; do
export SYSSRC=/lib/modules/$(make -sC %{kernel_source $flavor} kernelrelease)/source
if ! test -d "$SYSSRC"; then
SYSSRC=/usr/src/linux
fi
make -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}
cp source/%{version}/* %{buildroot}/usr/src/kernel-modules/nvidia-%{version}-${flavor}
done
mkdir -p $RPM_BUILD_ROOT/etc/modprobe.d
for flavor in %flavors_to_build; do
echo "blacklist nouveau" > $RPM_BUILD_ROOT/etc/modprobe.d/nvidia-$flavor.conf
done
%changelog