A new user interface for you! Read more...

File nvidia-bumblebee.spec of Package nvidia-bumblebee

#
# spec file for package nvidia-bumblebee
#
# Copyright (c) 2014 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/
#

Name: nvidia-bumblebee
Summary: Installer for the proprietary graphics driver for GeForce 6xxx and newer GPUs
Version: 352.55
Release: 0
Url: http://www.nvidia.com
Group: System/Libraries
License: GPLv2+
Vendor: The Bumblebee Project
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: dkms
Requires: wget binutils gcc make patch
Requires: gtk3
Conflicts: nvidia-kmp-default
Conflicts: nvidia-kmp-desktop
Conflicts: nvidia-kmp-pae
Conflicts: nvidia-kmp-xen
Conflicts: nvidia-kmp
Provides: nvidia-kernel-module = %{version}-%{release}
%if 0%{?suse_version}
BuildRequires: update-desktop-files
BuildRequires: sysconfig
%endif
Provides: x11-video-nvidiaG02 = %{version}-%{release}
Provides: x11-video-nvidiaG03 = %{version}-%{release}
Provides: x11-video-bumblebee-nvidiaG02 = %{version}-%{release}
Provides: x11-video-bumblebee-nvidiaG03 = %{version}-%{release}
Obsoletes: x11-video-nvidiaG02 < %{version}-%{release}
Obsoletes: x11-video-nvidiaG03 < %{version}-%{release}
Obsoletes: x11-video-bumblebee-nvidiaG02 < %{version}-%{release}
Obsoletes: x11-video-bumblebee-nvidiaG03 < %{version}-%{release}
Conflicts: x11-video-nvidia dkms-nvidia
Source0: README
Source1: nvidia-linux-3.18.patch

%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.

%ifarch x86_64
%package 32bit
License: GPLv2+
Summary: Installer for the proprietary graphics driver for GeForce 6xxx and newer GPUs
Group: System/Libraries
Requires: Mesa-libGL1-32bit
Conflicts: nvidia-utils-32bit


%description 32bit
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.
%endif


%prep
cp %SOURCE0 README.nvidia-bumblebee
cp %SOURCE1 nvidia-linux-3.18.patch
%ifarch x86_64
cp %SOURCE0 README.nvidia-bumblebee-32bit
%endif


%build


%install
mkdir -p %{buildroot}/etc/modprobe.d/
echo "blacklist nouveau" > %{buildroot}/etc/modprobe.d/51-blacklist-nouveau.conf


%pre
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
%ifarch x86_64
LIB=lib64
NV_NAME=NVIDIA-Linux-x86_64-%{version}
if [ -x /usr/bin/wget ] && [ ! -f $NV_NAME.run ] ; then
	#
	#	Get the package
	#
	wget -c http://us.download.nvidia.com/XFree86/Linux-x86_64/%{version}/$NV_NAME.run || exit -1
fi
%else
LIB=lib
NV_NAME=NVIDIA-Linux-x86-%{version}
if [ -x /usr/bin/wget ] && [ ! -f $NV_NAME.run ] ; then
	#
	#	Get the package
	#
	wget -c http://us.download.nvidia.com/XFree86/Linux-x86/%{version}/$NV_NAME.run || exit -1
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
LIB=lib64
NV_NAME=NVIDIA-Linux-x86_64-%{version}
%else
LIB=lib
NV_NAME=NVIDIA-Linux-x86-%{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
#
if [ -d $NV_NAME ] ; then
	#
	#	Install dkms sources
	#
	rm -rf /usr/src/nvidia-%{version}
	mkdir -p /usr/src/nvidia-%{version}
	cp -R $NV_NAME/kernel/* /usr/src/nvidia-%{version}/
	cp -R $NV_NAME/LICENSE /usr/src/nvidia-%{version}/
	cp -R $NV_NAME/README.txt /usr/src/nvidia-%{version}/
    # Copy patches to dkms
    mkdir -p /usr/src/nvidia-%{version}/patches
    cp /usr/share/doc/packages/nvidia-bumblebee/*.patch /usr/src/nvidia-%{version}/patches
    #
	pushd /usr/src/nvidia-%{version} >/dev/null 2>&1
		echo "nvidia.ko external" > Module.supported
        # Patch makefile for x86_64 systems
        # %ifarch x86_64
		# sed '34 c\ARCH = x86_64' Makefile > mk1
        # mv mk1 Makefile       
		# %endif
		ln -sf Makefile Makefile.kbuild
	popd >/dev/null 2>&1
	#
	#	Setup dkms.conf
	#
	cat > /usr/src/nvidia-%{version}/dkms.conf << EOF
PACKAGE_NAME=nvidia
PACKAGE_VERSION=%{version}
BUILT_MODULE_NAME[0]=nvidia
DEST_MODULE_LOCATION[0]="/updates/"
MAKE[0]="make module KERNEL_UNAME=\${kernelver}"
CLEAN="make clean"
AUTOINSTALL="yes"
PATCH[0]="nvidia-linux-3.18.patch"
PATCH_MATCH[0]="^3\.18(\..*)?"
BUILT_MODULE_NAME[1]="nvidia-uvm"
BUILT_MODULE_LOCATION[1]="uvm/"
DEST_MODULE_LOCATION[1]="/updates/"
MAKE[0]+="; make -C uvm module KERNEL_UNAME=\${kernelver} KBUILD_EXTMOD=\${dkms_tree}/nvidia/%{version}/build/uvm"
CLEAN+="; make -C uvm clean"
EOF
	#
	#	Install library
	#
	pushd $NV_NAME >/dev/null 2>&1
	
	# X driver
	install -D -m755 nvidia_drv.so /usr/$LIB/xorg/modules/drivers/nvidia_drv.so
	# GLX extension module for X
	install -D -m755 "libglx.so.%{version}" /usr/$LIB/nvidia/xorg/modules/extensions/libglx.so.%{version}
	# OpenGL library
	install -D -m755 "libGL.so.%{version}" /usr/$LIB/nvidia/libGL.so.%{version}
	# OpenGL core library
	install -D -m755 "libnvidia-glcore.so.%{version}" /usr/$LIB/libnvidia-glcore.so.%{version}
	# VDPAU
	install -D -m755 "libvdpau_nvidia.so.%{version}" /usr/$LIB/vdpau/libvdpau_nvidia.so.%{version}
	ln -sf libvdpau_nvidia.so.%{version} /usr/$LIB/vdpau/libvdpau_nvidia.so.1
	# nvidia-tls library
	install -D -m755 "tls/libnvidia-tls.so.%{version}" /usr/$LIB/libnvidia-tls.so.%{version}
	install -D -m755 "libnvidia-cfg.so.%{version}" /usr/$LIB/libnvidia-cfg.so.%{version}
	ln -sf libnvidia-cfg.so.%{version} /usr/$LIB/libnvidia-cfg.so.1
	install -D -m755 "libnvidia-ml.so.%{version}" /usr/$LIB/libnvidia-ml.so.%{version}
    ln -sf libnvidia-ml.so.%{version} /usr/$LIB/libnvidia-ml.so
	# CUDA
	install -D -m755 "libcuda.so.%{version}" /usr/$LIB/libcuda.so.%{version}
    ln -sf libcuda.so.%{version} /usr/$LIB/libcuda.so
	install -D -m755 "libnvcuvid.so.%{version}" /usr/$LIB/libnvcuvid.so.%{version}
	ln -sf libnvcuvid.so.%{version} /usr/$LIB/libnvcuvid.so.1
	#nvidia-xconfig
	install -D -m755 nvidia-xconfig /usr/bin/nvidia-xconfig
	install -D -m644 nvidia-xconfig.1.gz /usr/share/man/man1/nvidia-xconfig.1.gz
	# nvidia-settings
	install -D -m755 nvidia-settings /usr/bin/nvidia-settings
	install -D -m644 nvidia-settings.1.gz /usr/share/man/man1/nvidia-settings.1.gz
	install -D -m644 nvidia-settings.desktop /usr/share/applications/nvidia-settings.desktop
	install -D -m644 nvidia-settings.png /usr/share/pixmaps/nvidia-settings.png
	sed -e 's:__UTILS_PATH__:/usr/bin:' -e 's:__PIXMAP_PATH__:/usr/share/pixmaps:' -i "/usr/share/applications/nvidia-settings.desktop"
    install -D -m755 "libnvidia-gtk3.so.%{version}" /usr/$LIB/nvidia/libnvidia-gtk3.so.%{version}
    install -D -m644 "nvidia-application-profiles-%{version}-key-documentation" /usr/share/nvidia/nvidia-application-profiles-%{version}-key-documentation
	# nvidia-bug-report
	install -D -m755 nvidia-bug-report.sh /usr/bin/nvidia-bug-report.sh
	# nvidia-smi
	install -D -m755 nvidia-smi /usr/bin/nvidia-smi
	install -D -m644 nvidia-smi.1.gz /usr/share/man/man1/nvidia-smi.1.gz
	# OpenCL
	install -D -m644 nvidia.icd "/etc/OpenCL/vendors/nvidia.icd"
	install -D -m755 "libnvidia-compiler.so.%{version}" "/usr/$LIB/libnvidia-compiler.so.%{version}"
	install -D -m755 "libnvidia-opencl.so.%{version}" "/usr/$LIB/libnvidia-opencl.so.%{version}"
    ln -sf libnvidia-opencl.so.%{version} /usr/$LIB/libnvidia-opencl.so
	install -D -m755 "libOpenCL.so.1.0.0" "/usr/$LIB/nvidia/libOpenCL.so.1.0.0"
	# Links to OpenCL
	ln -sf "/usr/${LIB}/nvidia/libOpenCL.so.1.0.0" "/usr/${LIB}/nvidia/libOpenCL.so"
 	# Documentation
	install -D -m644 LICENSE /usr/share/licenses/nvidia/LICENSE
	ln -s nvidia /usr/share/licenses/nvidia-utils
	install -D -m644 README.txt /usr/share/doc/nvidia/README
	install -D -m644 NVIDIA_Changelog /usr/share/doc/nvidia/NVIDIA_Changelog
	ln -sf nvidia /usr/share/doc/nvidia-utils
	# Link to libwfb.so
	ln -sf /usr/$LIB/xorg/modules/libwfb.so /usr/$LIB/nvidia/xorg/modules/libwfb.so
	# Link to libglx.so otherwise X dont find them
	ln -sf /usr/$LIB/nvidia/xorg/modules/extensions/libglx.so.%{version} /usr/$LIB/nvidia/xorg/modules/extensions/libglx.so
	# Link to libGL
	ln -sf /usr/$LIB/nvidia/libGL.so.%{version} /usr/$LIB/nvidia/libGL.so.1
	
	popd >/dev/null 2>&1
fi
#
set -x
if [ -x /usr/sbin/dkms ] ; then
	/usr/sbin/dkms add -m nvidia -v %{version} --rpm_safe_upgrade
	/usr/sbin/dkms build -m nvidia -v %{version}
	/usr/sbin/dkms install -m nvidia -v %{version}
fi
#
popd >/dev/null 2>&1

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


%postun
%ifarch x86_64
LIB=lib64
NV_NAME=NVIDIA-Linux-x86_64-%{version}
%else
LIB=lib
NV_NAME=NVIDIA-Linux-x86-%{version}
%endif
## Remove all files
rm -f /usr/$LIB/xorg/modules/drivers/nvidia_drv.so
rm -f /usr/$LIB/nvidia/xorg/modules/extensions/libglx.so.%{version}
rm -f /usr/$LIB/nvidia/xorg/modules/extensions/libglx.so"
rm -f /usr/$LIB/nvidia/libGL.so.%{version}
rm -f /usr/$LIB/nvidia/libGL.so.1
rm -f /usr/$LIB/libnvidia-glcore.so.%{version}
rm -f /usr/$LIB/vdpau/libvdpau_nvidia.so.%{version}
rm -f /usr/$LIB/vdpau/libvdpau_nvidia.so.1
rm -f /usr/$LIB/libnvidia-tls.so.%{version}
rm -f /usr/$LIB/libnvidia-cfg.so.%{version}
rm -f /usr/$LIB/libnvidia-cfg.so.1
rm -f /usr/$LIB/libnvidia-ml.so.%{version}
rm -f /usr/$LIB/libcuda.so.%{version}
rm -f /usr/$LIB/libnvcuvid.so.%{version}
rm -f /usr/$LIB/libnvcuvid.so.1
rm -f /usr/bin/nvidia-xconfig
rm -f /usr/share/man/man1/nvidia-xconfig.1.gz
rm -f /usr/bin/nvidia-settings
rm -f /usr/$LIB/nvidia/libnvidia-gtk3.so.%{version}
rm -f /usr/share/nvidia/nvidia-application-profiles-%{version}-key-documentation"
rm -f /usr/share/man/man1/nvidia-settings.1.gz
rm -f /usr/share/applications/nvidia-settings.desktop
rm -f /usr/share/pixmaps/nvidia-settings.png
rm -f /usr/bin/nvidia-bug-report.sh
rm -f /usr/bin/nvidia-smi
rm -f /usr/share/man/man1/nvidia-smi.1.gz
rm -f /etc/OpenCL/vendors/nvidia.icd
rm -f /usr/$LIB/libnvidia-compiler.so.%{version}
rm -f /usr/$LIB/libnvidia-opencl.so.%{version}
rm -f /usr/$LIB/nvidia/libOpenCL.so.1.0.0
rm -f /usr/$LIB/nvidia/libOpenCL.so
rm -f /usr/share/licenses/nvidia/LICENSE
rm -f /usr/share/licenses/nvidia-utils
rm -f /usr/share/doc/nvidia/README
rm -f /usr/share/doc/nvidia/NVIDIA_Changelog
rm -f /usr/share/doc/nvidia-utils
rm -f /usr/$LIB/nvidia/xorg/modules/libwfb.so
#
#	Remove the sources
#
rm -rf /usr/src/nvidia-%{version}
rm -rf /usr/src/$NV_NAME
rm -f /usr/src/$NV_NAME.run


%ifarch x86_64
%pre 32bit
LIB=lib64
NV_NAME=NVIDIA-Linux-x86_64-%{version}
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
NV_NAME=NVIDIA-Linux-x86_64-%{version}
if [ -x /usr/bin/wget ] && [ ! -f /usr/src/$NV_NAME.run ] ; then
	#
	#	Get the package
	#
	wget -c http://us.download.nvidia.com/XFree86/Linux-x86_64/%{version}/$NV_NAME.run || exit -1
fi
#
if [ -f $NV_NAME.run ] ; then
	#
	#	Check the nVidia package
	#
	sh $NV_NAME.run --check || exit -2
fi
#
if [ ! -d $NV_NAME ] && [ -f /usr/src/$NV_NAME.run ] ; then
	#
	#	Unpack
	#
	sh /usr/src/$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 32bit
LIB=lib64
NV_NAME=NVIDIA-Linux-x86_64-%{version}
pushd /usr/src >/dev/null 2>&1
#
NV_NAME=NVIDIA-Linux-x86_64-%{version}
#
#	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
#
if [ -d $NV_NAME ] ; then
	#
	#	Install
	#
	pushd $NV_NAME >/dev/null 2>&1
		
	# OpenGL library
	install -D -m755 32/libGL.so.%{version} /usr/lib/nvidia/libGL.so.%{version}
	# OpenGL Links
	ln -sf /usr/lib/nvidia/libGL.so.%{version} /usr/lib/nvidia/libGL.so
	ln -sf /usr/lib/nvidia/libGL.so.%{version} /usr/lib/nvidia/libGL.so.1
	# OpenGL core library
	install -D -m755 32/libnvidia-glcore.so.%{version} /usr/lib/libnvidia-glcore.so.%{version}
	# VDPAU
	install -D -m755 32/libvdpau_nvidia.so.%{version} /usr/lib/vdpau/libvdpau_nvidia.so.%{version}
	# ln -sf libvdpau_nvidia.so.%{version} /usr/lib/vdpau/libvdpau_nvidia.so.1
	# CUDA
	install -D -m755 32/libcuda.so.%{version} /usr/lib/libcuda.so.%{version}
	install -D -m755 32/libnvcuvid.so.%{version} /usr/lib/libnvcuvid.so.%{version}
	# nvidia-tls library
	install -D -m755 32/tls/libnvidia-tls.so.%{version} /usr/lib/libnvidia-tls.so.%{version}
	# OpenCL
	install -D -m755 32/libnvidia-compiler.so.%{version} /usr/lib/libnvidia-compiler.so.%{version}
	install -D -m755 32/libnvidia-opencl.so.%{version} /usr/lib/libnvidia-opencl.so.%{version}
	install -D -m755 32/libnvidia-ml.so.%{version} /usr/lib/libnvidia-ml.so.%{version}
	
	install -D -m755 32/libOpenCL.so.1.0.0 /usr/lib/nvidia/libOpenCL.so.1.0.0
	# Links
	ln -sf /usr/lib/nvidia/libOpenCL.so.1.0.0 /usr/lib/nvidia/libOpenCL.so
		
	popd  >/dev/null 2>&1
fi
#
popd  >/dev/null 2>&1
#
/sbin/ldconfig


%postun 32bit
NV_NAME=NVIDIA-Linux-x86_64-%{version}
#
rm -f /usr/lib/nvidia/libGL.so.%{version}
rm -f /usr/lib/nvidia/libGL.so
rm -f /usr/lib/nvidia/libGL.so.1
rm -f /usr/lib/libnvidia-glcore.so.%{version}
rm -f /usr/lib/vdpau/libvdpau_nvidia.so.%{version}
rm -f /usr/lib/vdpau/libvdpau_nvidia.so.1
rm -f /usr/lib/libcuda.so.%{version}
rm -f /usr/lib/libnvcuvid.so.%{version}
rm -f /usr/lib/libnvidia-tls.so.%{version}
rm -f /usr/lib/libnvidia-compiler.so.%{version}
rm -f /usr/lib/libnvidia-opencl.so.%{version}
rm -f /usr/lib/nvidia/libOpenCL.so.1.0.0
rm -f /usr/lib/nvidia/libOpenCL.so
rm -f /usr/lib/libnvidia-ml.so.%{version}
#
/sbin/ldconfig
%endif


%files
%defattr(-,root,root)
%doc README.nvidia-bumblebee
%doc nvidia-linux-3.18.patch
/etc/modprobe.d/51-blacklist-nouveau.conf

%ifarch x86_64
%files 32bit
%defattr(-,root,root)
%doc README.nvidia-bumblebee-32bit
%endif

%changelog