LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File dkms-nvidia.spec of Package dkms-nvidia (Project home:Bumblebee-Project:nVidia:304.134)

#
# spec file for package dkms-nvidia
#
# Copyright (c) 2008 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 bumblebee.obs@gmail.com
#
# norootforbuild
#
%define modname  nvidia


#define mirror1  http://download.nvidia.com/XFree86
#define mirror1  http://uk.download.nvidia.com/XFree86
%define mirror1  http://us.download.nvidia.com/XFree86


Name:    dkms-%{modname}
Summary: Installer for the graphics driver kernel module for GeForce 6xxx and newer GPUs
Version: %{package_ver}
Release: 0.1
Url:     https://build.opensuse.org/project/show/home:Bumblebee-Project
Group:   System/Kernel
License: GPL-2.0+
Vendor:  The Bumblebee Project
Source0: README
Source1: kernel-4.6.patch
Source1000: %{name}-rpmlintrc
%if 0%{?suse_version}
Conflicts: nvidia-kmp-default
Conflicts: nvidia-kmp-desktop
Conflicts: nvidia-kmp-pae
Conflicts: nvidia-kmp-xen
Conflicts: nvidia-kmp
Conflicts: nvidia-gfxG02-kmp-default
Conflicts: nvidia-gfxG02-kmp-desktop
Conflicts: nvidia-gfxG02-kmp-pae
Conflicts: nvidia-gfxG02-kmp-xen
Conflicts: nvidia-gfxG02-kmp
%endif
Provides:  nvidia-kernel-module = %{version}-%{release}
Requires:  wget binutils gcc make patch
%if 0%{?mdkversion}
Requires:  dkms-minimal
%else
Requires:  dkms
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build


%description
This package will download and install the proprietary NVIDIA
Accelerated Linux Graphics Driver that brings accelerated 2D functionality
and high-performance OpenGL support to Linux x86 with the
use of NVIDIA graphics processing units (GPUs).

These drivers provide optimized hardware acceleration for OpenGL and X
applications and support nearly all recent NVIDIA GPU products
(see README.txt, Appendix A for a complete list of supported GPUs).
TwinView, TV-Out and flat panel displays are also supported.

http://www.nvidia.com


%prep
%if %{undefined package_name}
%{error:%%package_name missing in the Project Config}
exit -1
%endif
%if %{undefined package_ver}
%{error:%%package_ver missing in the Project Config}
exit -1
%endif
%if %{undefined md5_x86}
%{error:%%md5_x86 missing in the Project Config}
exit -1
%endif
%if %{undefined md5_x86_64}
%{error:%%md5_x86_64 missing in the Project Config}
exit -1
%endif
#
cp %SOURCE0 .
cp %SOURCE1 .


%build


%install
install -d 755 %{buildroot}/etc/modprobe.d
echo "blacklist nouveau" > %{buildroot}/etc/modprobe.d/50-blacklist-nouveau.conf


%pre
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
%ifarch x86_64
NV_NAME=%{package_name}_64-%{version}
if [ -f $NV_NAME.run ] ; then
    #
    # Check the package
    #
    md5sum --status -c <<EOF  || rm -f $NV_NAME.run
%{md5_x86_64}
EOF
fi
#
if [ -x /usr/bin/wget ] && [ ! -f $NV_NAME.run ] ; then
    #
    # Get the package
    #
    wget %{mirror1}/Linux-x86_64/%{version}/$NV_NAME.run || exit -1
    #
    # Check the package
    #
    md5sum --status -c <<EOF  || exit -1
%{md5_x86_64}
EOF
fi
%else
NV_NAME=%{package_name}-%{version}
if [ -f $NV_NAME.run ] ; then
    #
    # Check the nVidia package
    #
    md5sum --status -c <<EOF  || rm -f $NV_NAME.run
%{md5_x86}
EOF
fi
#
if [ -x /usr/bin/wget ] && [ ! -f $NV_NAME.run ] ; then
    #
    # Get the package
    #
    wget %{mirror1}/Linux-x86/%{version}/$NV_NAME.run || exit -1
    #
    # Check the package
    #
    md5sum --status -c <<EOF  || exit -1
%{md5_x86}
EOF
fi
%endif
#
if [ -f $NV_NAME.run ] ; then
	#
	#	Check the nVidia package
	#
	sh $NV_NAME.run --check || exit -2
fi
#
if [ ! -d $NV_NAME ] && [ -f $NV_NAME.run ] ; then
	#
	#	Unpack
	#
	sh $NV_NAME.run -x || exit -3
fi
#
#	To be used by the new setup
#
if [ -f $NV_NAME.run ] ; then
	mv -f $NV_NAME.run $NV_NAME.run.new 
fi
if [ -d $NV_NAME ] ; then
	mv -f $NV_NAME $NV_NAME.new
fi
#
popd >/dev/null 2>&1


%posttrans
pushd /usr/src >/dev/null 2>&1
#
%ifarch x86_64
NV_NAME=%{package_name}_64-%{version}
%else
NV_NAME=%{package_name}-%{version}
%endif
#
#	Get the new setup
#
if [ -f $NV_NAME.run.new ] ; then
	mv -f $NV_NAME.run.new $NV_NAME.run 
fi
if [ -d $NV_NAME.new ] ; then
	mv -f $NV_NAME.new $NV_NAME
fi
#
MAJOR_VER=$( echo %{version} | cut -d '.' -f 1 )
MINOR_VER=$( echo %{version} | cut -d '.' -f 2 )
PATCH_VER=$( echo %{version} | cut -d '.' -f 3 )
#
if [ -d $NV_NAME ] ; then
	#
	#	Install dkms sources
	#
	rm -rf /usr/src/%{modname}-%{version}-%{release}
	mkdir -p /usr/src/%{modname}-%{version}-%{release}
	cp -R $NV_NAME/kernel/* /usr/src/%{modname}-%{version}-%{release}/
	cp -R $NV_NAME/LICENSE /usr/src/%{modname}-%{version}-%{release}/
	cp -R $NV_NAME/README.txt /usr/src/%{modname}-%{version}-%{release}/
	pushd /usr/src/%{modname}-%{version}-%{release} >/dev/null 2>&1
	echo "nvidia.ko external" > Module.supported
	ln -sf Makefile.kbuild Makefile
	#
    #	Kernel 4.6 patch
    #
    patch -p0 < /usr/share/doc/packages/dkms-nvidia/kernel-4.6.patch
    #
	popd >/dev/null 2>&1
	#
	#	Setup dkms.conf
	#
	cat > /usr/src/%{modname}-%{version}-%{release}/dkms.conf << EOF
PACKAGE_NAME=%{modname}
PACKAGE_VERSION=%{version}-%{release}
MAKE[0]="make -C \${kernel_source_dir} SUBDIRS=\${dkms_tree}/\${PACKAGE_NAME}/\${PACKAGE_VERSION}/build modules"
CLEAN="make -f /usr/src/%{modname}-%{version}-%{release}/Makefile.kbuild -C \${kernel_source_dir} SUBDIRS=\${dkms_tree}/\${PACKAGE_NAME}/\${PACKAGE_VERSION}/build clean"
DEST_MODULE_LOCATION[0]="/updates/"
BUILT_MODULE_NAME[0]=%{modname}
AUTOINSTALL="yes"
REMAKE_INITRD="yes"
NO_WEAK_MODULES="yes"
EOF
fi
#
set -x
if [ -x /usr/sbin/dkms ] ; then
	/usr/sbin/dkms add -m %{modname} -v %{version}-%{release} --rpm_safe_upgrade
	/usr/sbin/dkms build -m %{modname} -v %{version}-%{release}
	/usr/sbin/dkms install -m %{modname} -v %{version}-%{release}
fi
#
popd >/dev/null 2>&1


%preun
#
#	Remove the module, rmmod can fail
#
if [ -x /sbin/rmmod ] ; then
	/sbin/rmmod %{modname} >/dev/null 2>&1
fi
#
#	Remove the module from dkms
#
set -x
if [ -x /usr/sbin/dkms ] ; then
	/usr/sbin/dkms remove -m %{modname} -v %{version}-%{release} --all --rpm_safe_upgrade || :
fi


%postun
%ifarch x86_64
NV_NAME=%{package_name}_64-%{version}
%else
NV_NAME=%{package_name}-%{version}
%endif
#
#	Remove the sources
#
rm -rf /usr/src/%{modname}-%{version}-%{release}
rm -rf /usr/src/$NV_NAME
rm -f /usr/src/$NV_NAME.run


%clean
rm -rf %{buildroot}


%files
%defattr(-, root, root)
%doc README kernel-4.6.patch
%dir /etc/modprobe.d
%config /etc/modprobe.d/50-blacklist-nouveau.conf


%changelog