LogoopenSUSE Build Service > Projects
Sign Up | Log In

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

#
# spec file for package x11-video-bumblebee-nvidia
#
# Copyright (c) 2009 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
# nodebuginfo


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


Name:    x11-video-nvidia
Summary: Installer for the proprietary graphics driver for GeForce 6xxx and newer GPUs
Version: %{package_ver}
Release: 0.1
Url:     https://build.opensuse.org/project/show/home:Bumblebee-Project
Group:   System/Libraries
License: GPL-2.0+
Vendor:  The Bumblebee Project
#Source0: nvidia-settings.desktop
Source1:  xorg.conf
Source2:  xorg.conf-x86_64
Source3:  README
Source100: %{name}-rpmlintrc
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version}
BuildRequires: update-desktop-files
%endif
Requires:  nvidia-kernel-module = %{version}
Requires:  nvidia-compute = %{version}-%{release}
Requires:  %{name}-devel = %{version}-%{release}
Provides:  x11-video-nvidiaG02 = %{version}-%{release}
Provides:  x11-video-bumblebee-nvidiaG02 = %{version}-%{release}
Obsoletes: x11-video-nvidiaG02 < %{version}-%{release}
Obsoletes: x11-video-bumblebee-nvidiaG02 < %{version}-%{release}
ExclusiveArch: %ix86 x86_64


%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


%package devel
License:  GPL-2.0+
Summary:  Installer for the proprietary graphics driver for GeForce 6xxx and newer GPUs
Group:    Development/Libraries/Other
Requires: %{name} = %{version}-%{release}


%description devel
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


%ifarch x86_64
%package 32bit
License:  GPL-2.0+
Summary:  Installer for the proprietary graphics driver for GeForce 6xxx and newer GPUs
Group:    System/Libraries
Requires: %{name} = %{version}-%{release}
Requires: nvidia-compute-32bit = %{version}-%{release}
Requires: %{name}-devel-32bit = %{version}-%{release}


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

http://www.nvidia.com


%package devel-32bit
License:  GPL-2.0+
Summary:  Installer for the proprietary graphics driver for GeForce 6xxx and newer GPUs
Group:    Development/Libraries/Other
Requires: %{name}-32bit = %{version}-%{release}


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

http://www.nvidia.com

%endif


%package -n nvidia-compute
Summary:   Installer for the proprietary NVIDIA driver for computing with GPGPU
Group:     System/Libraries
Requires:  nvidia-kernel-module = %{version}
Provides:  nvidia-computeG02 = %{version}-%{release}
Obsoletes: nvidia-computeG02 < %{version}-%{release}


%description -n nvidia-compute
This package will download and install the proprietary NVIDIA driver
for computing with GPGPUs using CUDA or OpenCL


%package -n nvidia-compute-devel
Summary:  Installer for the proprietary NVIDIA driver for computing with GPGPU
Group:    Development/Libraries/Other
Requires: nvidia-compute = %{version}-%{release}


%description -n nvidia-compute-devel
This package will download and install the proprietary NVIDIA driver
for computing with GPGPUs using CUDA or OpenCL


%ifarch x86_64
%package -n nvidia-compute-32bit
Summary:  Installer for the proprietary NVIDIA driver for computing with GPGPU
Group:    System/Libraries
Requires: nvidia-compute = %{version}-%{release}


%description -n nvidia-compute-32bit
This package will download and install the proprietary NVIDIA driver
for computing with GPGPUs using CUDA or OpenCL


%package -n nvidia-compute-devel-32bit
Summary:  Installer for the proprietary NVIDIA driver for computing with GPGPU
Group:    Development/Libraries/Other
Requires: nvidia-compute-32bit = %{version}-%{release}


%description -n nvidia-compute-devel-32bit
This package will download and install the proprietary NVIDIA driver
for computing with GPGPUs using CUDA or OpenCL

%endif


%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 %SOURCE3 README.x11-video-nvidia
cp %SOURCE3 README.x11-video-nvidia-devel
cp %SOURCE3 README.nvidia-compute
cp %SOURCE3 README.nvidia-compute-devel
%ifarch x86_64
cp %SOURCE3 README.x11-video-nvidia-32bit
cp %SOURCE3 README.x11-video-nvidia-devel-32bit
cp %SOURCE3 README.nvidia-compute-32bit
cp %SOURCE3 README.nvidia-compute-devel-32bit
%endif


%build


%install
#
#	Setup
#
install -d %{buildroot}/etc/X11
%ifarch x86_64
install -m 644 %{SOURCE2} %{buildroot}/etc/X11/xorg.conf.nvidia-example
%else
install -m 644 %{SOURCE1} %{buildroot}/etc/X11/xorg.conf.nvidia-example
%endif


%pre
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
%ifarch x86_64
LIB=lib64
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
LIB=lib
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
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
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
#
if [ -d $NV_NAME ] ; then
	#
	#	Install
	#
	pushd $NV_NAME >/dev/null 2>&1
	install -d /usr/bin
	install -d /usr/$LIB/nvidia
	install -d /usr/$LIB/nvidia/tls
	install -d /usr/$LIB/nvidia/vdpau
	install -d /usr/$LIB/nvidia/xorg/modules/updates/drivers
	install -d /usr/$LIB/nvidia/xorg/modules/updates/extensions
	install nvidia-settings /usr/bin
	install nvidia-bug-report.sh /usr/bin
	install nvidia-xconfig /usr/bin
	install tls/libnvidia-tls.so.%{version} /usr/$LIB/nvidia/tls
	install libnvidia-cfg.so.%{version} /usr/$LIB/nvidia
	install libnvidia-compiler.so.%{version} /usr/$LIB/nvidia
	install libnvidia-glcore.so.%{version} /usr/$LIB/nvidia
	install libnvidia-tls.so.%{version} /usr/$LIB/nvidia
	install libnvcuvid.so.%{version} /usr/$LIB/nvidia
	install libvdpau_nvidia.so.%{version} /usr/$LIB/nvidia/vdpau
#	install libvdpau_trace.so.{version} /usr/$LIB/nvidia/vdpau
	install libGL.so.%{version} /usr/$LIB/nvidia
	install libXvMCNVIDIA.so.%{version} /usr/$LIB/nvidia
#	install libnvidia-wfb.so.{version} /usr/$LIB/nvidia/xorg/modules/updates
	install nvidia_drv.so /usr/$LIB/nvidia/xorg/modules/updates/drivers
	install libglx.so.%{version} /usr/$LIB/nvidia/xorg/modules/updates/extensions
	#
	#	Links
	#
#	ln -sf libnvidia-wfb.so.{version} /usr/$LIB/nvidia/xorg/modules/updates/libnvidia-wfb.so.1
	# still a lot of applications make a dlopen to the .so file
	ln -sf libnvcuvid.so.%{version} /usr/$LIB/nvidia/libnvcuvid.so.1
	ln -sf libnvidia-cfg.so.%{version} /usr/$LIB/nvidia/libnvidia-cfg.so.1
	ln -sf libvdpau_nvidia.so.%{version} /usr/$LIB/nvidia/vdpau/libvdpau_nvidia.so.1
#	ln -sf libvdpau_trace.so.{version} /usr/$LIB/nvidia/vdpau/libvdpau_trace.so.1
	ln -sf libGL.so.%{version} /usr/$LIB/nvidia/libGL.so.1
	ln -sf libXvMCNVIDIA.so.%{version} /usr/$LIB/nvidia/libXvMCNVIDIA_dynamic.so.1
	#
	#	Documentation
	#
	install -d /usr/share/doc/packages/%name
	cp -a html /usr/share/doc/packages/%name
	install -m 644 LICENSE /usr/share/doc/packages/%name
	install -d %{_mandir}/man1
	install -m 644 *.1.gz %{_mandir}/man1
	#
	#	Setup
	#
	install -d /usr/share/pixmaps
	install -m 644 nvidia-settings.png /usr/share/pixmaps
	popd >/dev/null 2>&1
fi
#
popd >/dev/null 2>&1
#
#	Funcs
#
setup_nvidia_xorg_conf()
{
	#
	#	Is the current xorg.conf for nVidia ?
	#
	if [[ ! -n "$(cat /etc/X11/xorg.conf | sed 's/^\([ \t]*Driver[ \t]*\"nvidia\"\)/FoundMagic/' | grep 'FoundMagic')" ]] ; then
		#
		#	No nVidia driver selected in current xorg.conf, start a new one
		#
		rm -f /etc/X11/xorg.conf
		cp /etc/X11/xorg.conf.nvidia-example /etc/X11/xorg.conf
	else
		#
		#	nVidia xorg.conf found, change the module paths
		#
		if [[ ! -n "$(grep '\"Files\"' /etc/X11/xorg.conf)" ]] ; then
			#
			#	Add new section
			#
			cat >> /etc/X11/xorg.conf << EOF

Section "Files"
EndSection
EOF
		fi
		#
		#	Remove all module paths
		#
		sed -i "/^[ \t]*ModulePath.*/d" /etc/X11/xorg.conf
		#
		#	Add new paths
		#
		sed -i "s?\"Files\"?\"Files\"\n    ModulePath    \"$MODULE_PATH1\"\n    ModulePath    \"$MODULE_PATH2\"\n    ModulePath    \"$MODULE_PATH3\"?" /etc/X11/xorg.conf
	fi
}
#
#	Main
#
ARCH=$(uname -m)

if [ "$ARCH" == "x86_64" ] ; then
	MODULE_PATH1="/usr/lib64/nvidia/xorg/modules/updates"
	MODULE_PATH2="/usr/lib64/xorg/modules/updates"
	MODULE_PATH3="/usr/lib64/xorg/modules"
else
	MODULE_PATH1="/usr/lib/nvidia/xorg/modules/updates"
	MODULE_PATH2="/usr/lib/xorg/modules/updates"
	MODULE_PATH3="/usr/lib/xorg/modules"
fi

#
#	Install / Upgrade
#

#
#	Get the number of video cards
#
if [ -x /sbin/lspci ] ; then
	VIDEO_CARDS=$(/sbin/lspci -n | grep "^.* 030[02]:" | wc -l)
	NVIDIA_CARDS=$(/sbin/lspci -n -d 10de: | grep "^.* 030[02]:" | wc -l)
else
	VIDEO_CARDS=1
	NVIDIA_CARDS=0
fi
#
if [ $NVIDIA_CARDS -eq $VIDEO_CARDS ] ; then
	#
	#	All nvidia cards, install xorg.conf, library paths and Wrapper
	#
	if [ -f /etc/X11/xorg.conf ] ; then
		cp -f /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia_post
		#
		#	Check xorg.conf
		#
		setup_nvidia_xorg_conf
	else
		#
		#	If configuration for proprietary driver already exists, bring it back 
		#
		if [ -f /etc/X11/xorg.conf.nvidia_postun ] ; then
			mv /etc/X11/xorg.conf.nvidia_postun /etc/X11/xorg.conf
			#
			#	Check xorg.conf
			#
			setup_nvidia_xorg_conf
		else
			#
			#	Clean  machine, use the example
			#
			cp -f /etc/X11/xorg.conf.nvidia-example /etc/X11/xorg.conf
		fi
	fi
	#
	#	Add the libs to the dynamic lib search path
	#
%if 0%{?suse_version}
%if 0%{?suse_version} <= 1140
	#
	#	There is no nice way to add the new lib paths.
	#	We need to edit the ld.so.conf file to ensure they are first in the path.
	#
	sed -i "/^.*\/lib\/nvidia.*/d" /etc/ld.so.conf
	if [[ "$ARCH" == "x86_64" ]] ; then
		sed -i "/^.*\/lib64\/nvidia.*/d" /etc/ld.so.conf
	fi
	#
	> /etc/ld.so.conf.new
	if [[ "$ARCH" == "x86_64" ]] ; then
		echo "/usr/lib64/nvidia" >> /etc/ld.so.conf.new
		echo "/usr/lib64/nvidia/vdpau" >> /etc/ld.so.conf.new
	fi
	echo "/usr/lib/nvidia" >> /etc/ld.so.conf.new
	echo "/usr/lib/nvidia/vdpau" >> /etc/ld.so.conf.new
	cat /etc/ld.so.conf >> /etc/ld.so.conf.new
	mv -f /etc/ld.so.conf.new /etc/ld.so.conf
	#
	#	Activate new search path
	#
	/sbin/ldconfig
%else
	#
	#	Use the ld.so.conf.d ( make sure it is first in the list )
	#
	> /etc/ld.so.conf.d/00-nvidia.conf
	if [[ "$ARCH" == "x86_64" ]] ; then
		echo "/usr/lib64/nvidia" >> /etc/ld.so.conf.d/00-nvidia.conf
		echo "/usr/lib64/nvidia/vdpau" >> /etc/ld.so.conf.d/00-nvidia.conf
	fi
	echo "/usr/lib/nvidia" >> /etc/ld.so.conf.d/00-nvidia.conf
	echo "/usr/lib/nvidia/vdpau" >> /etc/ld.so.conf.d/00-nvidia.conf
%endif
%else
	#
	#	Use the ld.so.conf.d ( make sure it is first in the list )
	#
	> /etc/ld.so.conf.d/00-nvidia.conf
	if [[ "$ARCH" == "x86_64" ]] ; then
		echo "/usr/lib64/nvidia" >> /etc/ld.so.conf.d/00-nvidia.conf
		echo "/usr/lib64/nvidia/vdpau" >> /etc/ld.so.conf.d/00-nvidia.conf
	fi
	echo "/usr/lib/nvidia" >> /etc/ld.so.conf.d/00-nvidia.conf
	echo "/usr/lib/nvidia/vdpau" >> /etc/ld.so.conf.d/00-nvidia.conf
%endif
fi


%postun
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
NV_NAME=%{package_name}-%{version}
%endif
rm -f /usr/bin/nvidia-settings
rm -f /usr/bin/nvidia-bug-report.sh
rm -f /usr/bin/nvidia-xconfig
rm -f /usr/$LIB/nvidia/tls/libnvidia-tls.so.*
rm -f /usr/$LIB/nvidia/libnvidia-cfg.so.*
rm -f /usr/$LIB/nvidia/libnvidia-compiler.so.*
rm -f /usr/$LIB/nvidia/libnvidia-glcore.so.*
rm -f /usr/$LIB/nvidia/libnvidia-tls.so.*
rm -f /usr/$LIB/nvidia/libnvcuvid.so.*
rm -f /usr/$LIB/nvidia/vdpau/libvdpau_nvidia.so.*
#rm -f /usr/$LIB/nvidia/vdpau/libvdpau_trace.so.*
rm -f /usr/$LIB/nvidia/libGL.so.*
rm -f /usr/$LIB/nvidia/libXvMCNVIDIA.so.*
rm -f /usr/$LIB/nvidia/libXvMCNVIDIA_dynamic.so.*
#rm -f /usr/$LIB/nvidia/xorg/modules/updates/libnvidia-wfb.so.*
rm -f /usr/$LIB/nvidia/xorg/modules/updates/drivers/nvidia_drv.so
rm -f /usr/$LIB/nvidia/xorg/modules/updates/extensions/libglx.so.*
rm -f /usr/share/doc/packages/%name/LICENSE
rm -rf /usr/share/doc/packages/%name/html
rm -f %{_mandir}/man1/nvidia-installer.*
rm -f %{_mandir}/man1/nvidia-settings.*
rm -f %{_mandir}/man1/nvidia-smi.*
rm -f %{_mandir}/man1/nvidia-xconfig.*
#
if [ -d  /usr/$LIB/nvidia ] ; then
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/tls
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/vdpau
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules/updates/drivers
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules/updates/extensions
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules/updates
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia
fi
#
ARCH=$(uname -m)
#
#	Cleanup dynamic library search path
#
%if 0%{?suse_version}
%if 0%{?suse_version} <= 1140
sed -i "/^.*\/lib\/nvidia.*/d" /etc/ld.so.conf
if [[ "$ARCH" == "x86_64" ]] ; then
	sed -i "/^.*\/lib64\/nvidia.*/d" /etc/ld.so.conf
fi
%else
rm -f /etc/ld.so.conf.d/00-nvidia.conf
%endif
%else
rm -f /etc/ld.so.conf.d/00-nvidia.conf
%endif
#
#	Restore xorg.conf
#
if [ -f /etc/X11/xorg.conf ] ; then
	mv -f /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia_postun
fi
if [ -r /etc/X11/xorg.conf.nvidia_post ] ; then
	mv -f /etc/X11/xorg.conf.nvidia_post /etc/X11/xorg.conf
fi
#
#	Activate new search path
#
/sbin/ldconfig


%pre devel
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
%ifarch x86_64
LIB=lib64
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
LIB=lib
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 devel
pushd /usr/src >/dev/null 2>&1
#
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
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
#
if [ -d $NV_NAME ] ; then
	#
	#	Install
	#
	pushd $NV_NAME >/dev/null 2>&1
	install -d /usr/$LIB/nvidia
	install -d /usr/$LIB/nvidia/vdpau
	install -d /usr/$LIB/nvidia/xorg/modules/updates/extensions
	install libXvMCNVIDIA.a /usr/$LIB/nvidia
	chmod 644 /usr/$LIB/nvidia/libXvMCNVIDIA.a
	#
	#	Links
	#
	ln -sf libglx.so.%{version} /usr/$LIB/nvidia/xorg/modules/updates/extensions/libglx.so
	#ln -sf libnvidia-wfb.so.{version} /usr/$LIB/nvidia/xorg/modules/updates/libnvidia-wfb.so
	# still a lot of applications make a dlopen to the .so file
	ln -sf libnvcuvid.so.%{version} /usr/$LIB/nvidia/libnvcuvid.so
	ln -sf libnvidia-cfg.so.%{version} /usr/$LIB/nvidia/libnvidia-cfg.so
	ln -sf libvdpau_nvidia.so.%{version} /usr/$LIB/nvidia/vdpau/libvdpau_nvidia.so
	#ln -sf libvdpau_trace.so.{version} /usr/$LIB/nvidia/vdpau/libvdpau_trace.so
	ln -sf libGL.so.%{version} /usr/$LIB/nvidia/libGL.so
	ln -sf libXvMCNVIDIA.so.%{version} /usr/$LIB/nvidia/libXvMCNVIDIA_dynamic.so
	popd >/dev/null 2>&1
fi
#
popd >/dev/null 2>&1
#
/sbin/ldconfig


%postun devel
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
NV_NAME=%{package_name}-%{version}
%endif
rm -f /usr/$LIB/nvidia/libXvMCNVIDIA.a
rm -f /usr/$LIB/nvidia/xorg/modules/updates/extensions/libglx.so
#rm -f /usr/$LIB/nvidia/xorg/modules/updates/libnvidia-wfb.so
rm -f /usr/$LIB/nvidia/libnvcuvid.so
rm -f /usr/$LIB/nvidia/libnvidia-cfg.so
rm -f /usr/$LIB/nvidia/vdpau/libvdpau_nvidia.so
#rm -f /usr/$LIB/nvidia/vdpau/libvdpau_trace.so
rm -f /usr/$LIB/nvidia/libGL.so
rm -f /usr/$LIB/nvidia/libXvMCNVIDIA_dynamic.so
#
if [ -d  /usr/$LIB/nvidia ] ; then
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/vdpau
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules/updates/extensions
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules/updates
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg/modules
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia/xorg
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia
fi
#
/sbin/ldconfig


%ifarch x86_64
%pre 32bit
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
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
#
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
pushd /usr/src >/dev/null 2>&1
#
NV_NAME=%{package_name}_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
	install -d /usr/lib/nvidia
	install -d /usr/lib/nvidia/tls
	install -d /usr/lib/nvidia/vdpau
	install 32/tls/libnvidia-tls.so.* /usr/lib/nvidia/tls
	install 32/libnvidia-compiler.so.* /usr/lib/nvidia
	install 32/libnvidia-glcore.so.* /usr/lib/nvidia
	install 32/libnvidia-tls.so.* /usr/lib/nvidia
	install 32/libvdpau_nvidia.so.* /usr/lib/nvidia/vdpau
	#install 32/libvdpau_trace.so.* /usr/lib/nvidia/vdpau
	install 32/libGL.so.* /usr/lib/nvidia
	popd  >/dev/null 2>&1
	#
	#	Links
	#
	ln -sf libvdpau_nvidia.so.%{version} /usr/lib/nvidia/vdpau/libvdpau_nvidia.so.1
	ln -sf libGL.so.%{version} /usr/lib/nvidia/libGL.so.1
fi
#
popd  >/dev/null 2>&1
#
/sbin/ldconfig


%postun 32bit
NV_NAME=%{package_name}_64-%{version}
#
rm -f /usr/lib/nvidia/tls/libnvidia-tls.so.*
rm -f /usr/lib/nvidia/libnvidia-compiler.so.*
rm -f /usr/lib/nvidia/libnvidia-glcore.so.*
rm -f /usr/lib/nvidia/libnvidia-tls.so.*
rm -f /usr/lib/nvidia/vdpau/libvdpau_nvidia.so.*
rm -f /usr/lib/nvidia/vdpau/libvdpau_trace.so.*
rm -f /usr/lib/nvidia/libGL.so.*
#
if [ -d  /usr/lib/nvidia/tls ] ; then
	rmdir --ignore-fail-on-non-empty /usr/lib/nvidia/tls
fi
if [ -d  /usr/lib/nvidia/vdpau ] ; then
	rmdir --ignore-fail-on-non-empty /usr/lib/nvidia/vdpau
fi
if [ -d  /usr/lib/nvidia ] ; then
	rmdir --ignore-fail-on-non-empty /usr/lib/nvidia
fi
#
/sbin/ldconfig


%posttrans devel-32bit
install -d /usr/lib/nvidia
install -d /usr/lib/nvidia/vdpau
ln -sf libvdpau_nvidia.so.%{version} /usr/lib/nvidia/vdpau/libvdpau_nvidia.so
ln -sf libGL.so.%{version} /usr/lib/nvidia/libGL.so


%postun devel-32bit
NV_NAME=%{package_name}_64-%{version}
#
rm -f /usr/lib/nvidia/vdpau/libvdpau_nvidia.so
rm -f /usr/lib/nvidia/libGL.so
#
if [ -d  /usr/lib/nvidia/tls ] ; then
	rmdir --ignore-fail-on-non-empty /usr/lib/nvidia/tls
fi
if [ -d  /usr/lib/nvidia/vdpau ] ; then
	rmdir --ignore-fail-on-non-empty /usr/lib/nvidia/vdpau
fi
if [ -d  /usr/lib/nvidia ] ; then
	rmdir --ignore-fail-on-non-empty /usr/lib/nvidia
fi
#
/sbin/ldconfig

%endif


%pre -n nvidia-compute
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
%ifarch x86_64
LIB=lib64
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
LIB=lib
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 -n nvidia-compute
pushd /usr/src >/dev/null 2>&1
#
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
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
#
if [ -d $NV_NAME ] ; then
	#
	#	Install
	#
	pushd $NV_NAME >/dev/null 2>&1
	install -d /etc/OpenCL/vendors
	install -m 644 nvidia.icd /etc/OpenCL/vendors
	install -d /usr/bin
	install -d /usr/$LIB/nvidia
	install nvidia-smi /usr/bin
	install libcuda.so.* /usr/$LIB/nvidia
	install libOpenCL.so.* /usr/$LIB/nvidia
	install libnvidia-ml.so.* /usr/$LIB/nvidia
	OPENCL_LIB=`ls libOpenCL.so.*`
	popd >/dev/null 2>&1
	#
	#	Links
	#
	ln -sf libcuda.so.%{version} /usr/$LIB/nvidia/libcuda.so.1
	ln -sf $OPENCL_LIB /usr/$LIB/nvidia/libOpenCL.so.1
	ln -sf libnvidia-ml.so.%{version} /usr/$LIB/nvidia/libnvidia-ml.so.1
fi
#
popd >/dev/null 2>&1
#
/sbin/ldconfig


%postun -n nvidia-compute
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
NV_NAME=%{package_name}-%{version}
%endif
rm -f /etc/OpenCL/vendors/nvidia.icd
rm -f /usr/bin/nvidia-smi
rm -f /usr/$LIB/nvidia/libcuda.so.*
rm -f /usr/$LIB/nvidia/libOpenCL.so.*
rm -f /usr/$LIB/nvidia/libnvidia-ml.so.*
#
if [ -d  /etc/OpenCL ] ; then
	rmdir --ignore-fail-on-non-empty /etc/OpenCL/vendors
	rmdir --ignore-fail-on-non-empty /etc/OpenCL
fi
if [ -d  /usr/$LIB/nvidia ] ; then
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia
fi
#
/sbin/ldconfig


%pre -n nvidia-compute-devel
pushd /usr/src >/dev/null 2>&1
#
#	Get the nVidia package and unpack
#
%ifarch x86_64
LIB=lib64
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
LIB=lib
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 -n nvidia-compute-devel
pushd /usr/src >/dev/null 2>&1
#
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
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
#
if [ -d $NV_NAME ] ; then
	#
	#	Install
	#
	pushd $NV_NAME >/dev/null 2>&1
	install -d /usr/$LIB/nvidia
	OPENCL_LIB=`ls libOpenCL.so.*`  
	popd >/dev/null 2>&1
	#
	#	Links
	#
	ln -sf libcuda.so.%{version} /usr/$LIB/nvidia/libcuda.so
	ln -sf $OPENCL_LIB /usr/$LIB/nvidia/libOpenCL.so
	ln -sf libnvidia-ml.so.%{version} /usr/$LIB/nvidia/libnvidia-ml.so
fi
#
popd >/dev/null 2>&1
#
/sbin/ldconfig


%postun -n nvidia-compute-devel
%ifarch x86_64
LIB=lib64
NV_NAME=%{package_name}_64-%{version}
%else
LIB=lib
NV_NAME=%{package_name}-%{version}
%endif
rm -f /usr/$LIB/nvidia/libcuda.so
rm -f /usr/$LIB/nvidia/libOpenCL.so
rm -f /usr/$LIB/nvidia/libnvidia-ml.so
#
if [ -d  /usr/$LIB/nvidia ] ; then
	rmdir --ignore-fail-on-non-empty /usr/$LIB/nvidia
fi
#
/sbin/ldconfig


%files
%defattr(-,root,root)
%doc README.x11-video-nvidia
%config /etc/X11/xorg.conf.nvidia-example


%files devel
%defattr(-,root,root)
%doc README.x11-video-nvidia-devel


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


%files devel-32bit
%defattr(-,root,root)
%doc README.x11-video-nvidia-devel-32bit
%endif


%files -n nvidia-compute
%defattr(-,root,root)
%doc README.nvidia-compute


%files -n nvidia-compute-devel
%defattr(-,root,root)
%doc README.nvidia-compute-devel


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


%files -n nvidia-compute-devel-32bit
%defattr(-,root,root)
%doc README.nvidia-compute-devel-32bit
%endif


%changelog