LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File cuda-9.0.spec of Package cuda-9.0 (Project home:Bumblebee-Project:nVidia:390.42)

#
# spec file for package cuda-9.0
#
# 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 bumblebee.obs@gmail.com
#

%define mirror1 https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers

%define	cuda_package_name	    cuda
%define	cuda_package_version	9.0.176

%define md5_cuda_x86_64		7a00187b2ce5c5e350e68882f42dd507  %{cuda_package_name}_%{version}_linux.run



Name:    %{cuda_package_name}-%{cuda_package_version}
Summary: Installer for the nVidia CUDA Toolkit 9.0
Version: %{cuda_package_version}_384.81
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
Requires:  nvidia-kernel-module >= 384.81
Requires:  nvidia-uvm-kernel-module >= 384.81
Requires:  gcc-c++
Requires:  glu-devel
Requires:  freeglut-devel
Requires:  libXi-devel
Requires:  libXmu-devel
Provides:  cuda = %{version}
Conflicts: cuda < %{cuda_package_version}
Conflicts: cuda > %{cuda_package_version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: x86_64


%description
This package will download and install the proprietary NVIDIA CUDA Toolkit.

The NVIDIA® CUDA® Toolkit provides a comprehensive development environment
for C and C++ developers building GPU-accelerated applications.
The CUDA Toolkit includes a compiler for NVIDIA GPUs, math libraries,
and tools for debugging and optimizing the performance of your applications.
You’ll also find programming guides, user manuals, API reference,
and other documentation to help you get started quickly accelerating
your application with GPUs.

https://developer.nvidia.com/cuda-toolkit


%prep
%if %{undefined cuda_package_name}
%{error:%%cuda_package_name missing}
exit -1
%endif
%if %{undefined cuda_package_version}
%{error:%%cuda_package_version missing}
exit -1
%endif
%if %{undefined md5_cuda_x86_64}
%{error:%%md5_cuda_x86_64 missing}
exit -1
%endif
#
cp %SOURCE0 .


%build


%install
install -d %{buildroot}%{_bindir}
install -d %{buildroot}/etc/ld.so.conf.d
install -d %{buildroot}/opt/%{cuda_package_name}-%{cuda_package_version}
touch %{buildroot}/etc/ld.so.conf.d/00-nvidia-cuda.conf
touch %{buildroot}%{_bindir}/bin2c
chmod 755 %{buildroot}%{_bindir}/bin2c
touch %{buildroot}%{_bindir}/computeprof
chmod 755 %{buildroot}%{_bindir}/computeprof
touch %{buildroot}%{_bindir}/crt
chmod 755 %{buildroot}%{_bindir}/crt
touch %{buildroot}%{_bindir}/cudafe
chmod 755 %{buildroot}%{_bindir}/cudafe
touch %{buildroot}%{_bindir}/cudafe++
chmod 755 %{buildroot}%{_bindir}/cudafe++
touch %{buildroot}%{_bindir}/cuda-gdb
chmod 755 %{buildroot}%{_bindir}/cuda-gdb
touch %{buildroot}%{_bindir}/cuda-gdbserver
chmod 755 %{buildroot}%{_bindir}/cuda-gdbserver
touch %{buildroot}%{_bindir}/cuda-gdb
chmod 755 %{buildroot}%{_bindir}/cuda-gdb
touch %{buildroot}%{_bindir}/cuda-memcheck
chmod 755 %{buildroot}%{_bindir}/cuda-memcheck
touch %{buildroot}%{_bindir}/cuobjdump
chmod 755 %{buildroot}%{_bindir}/cuobjdump
touch %{buildroot}%{_bindir}/fatbinary
chmod 755 %{buildroot}%{_bindir}/fatbinary
touch %{buildroot}%{_bindir}/gpu-library-advisor
chmod 755 %{buildroot}%{_bindir}/gpu-library-advisor
touch %{buildroot}%{_bindir}/nsight
chmod 755 %{buildroot}%{_bindir}/nsight
touch %{buildroot}%{_bindir}/nsight_ee_plugins_manage.sh
chmod 755 %{buildroot}%{_bindir}/nsight_ee_plugins_manage.sh
touch %{buildroot}%{_bindir}/nvcc
chmod 755 %{buildroot}%{_bindir}/nvcc
touch %{buildroot}%{_bindir}/nvcc.profile
chmod 755 %{buildroot}%{_bindir}/nvcc.profile
touch %{buildroot}%{_bindir}/nvdisasm
chmod 755 %{buildroot}%{_bindir}/nvdisasm
touch %{buildroot}%{_bindir}/nvlink
chmod 755 %{buildroot}%{_bindir}/nvlink
touch %{buildroot}%{_bindir}/nvprof
chmod 755 %{buildroot}%{_bindir}/nvprof
touch %{buildroot}%{_bindir}/nvprune
chmod 755 %{buildroot}%{_bindir}/nvprune
touch %{buildroot}%{_bindir}/nvvp
chmod 755 %{buildroot}%{_bindir}/nvvp
touch %{buildroot}%{_bindir}/ptxas
chmod 755 %{buildroot}%{_bindir}/ptxas


%pre
pushd /usr/src >/dev/null 2>&1
#
#	Get the toolkit package
#
NV_NAME=%{cuda_package_name}_%{version}_linux
if [ -f $NV_NAME.run ] ; then
    #
    # Check the package
    #
    md5sum --status -c <<EOF  || rm -f $NV_NAME.run
%{md5_cuda_x86_64}
EOF
fi
#
if [ -x /usr/bin/wget ] && [ ! -f $NV_NAME.run ] ; then
    #
    # Get the package
    #
    wget %{mirror1}/$NV_NAME-run || { rm -f $NV_NAME-run ; exit -1 ; }
    mv -f $NV_NAME-run $NV_NAME.run
    #
    # Check the package
    #
    md5sum --status -c <<EOF  || { rm -f $NV_NAME.run ; exit -1 ; }
%{md5_cuda_x86_64}
EOF
fi
#
if [ ! -d $NV_NAME ] && [ -f $NV_NAME.run ] ; then
	#
	#	Unpack
	#
	sh $NV_NAME.run -extract=/usr/src/$NV_NAME -silent --nox11 >/dev/null 2>&1 || { rm -f $NV_NAME.run ; exit -3 ; }
fi
#    
NV_USAGE_FILE=/usr/src/$NV_NAME.usage
#
NV_USED=0
touch $NV_USAGE_FILE
source $NV_USAGE_FILE
NV_USED=$((NV_USED + 1))
echo "NV_USED=$NV_USED" > $NV_USAGE_FILE
#
popd >/dev/null 2>&1


%post
pushd /usr/src >/dev/null 2>&1
#
NV_NAME=%{cuda_package_name}_%{version}_linux
#
if [ -d $NV_NAME ] ; then
	pushd $NV_NAME >/dev/null 2>&1
	sh %{cuda_package_name}-linux.%{cuda_package_version}-*.run -prefix=/opt/%{cuda_package_name}-%{cuda_package_version} -noprompt -nosymlink --nox11 >/dev/null 2>&1
	sh %{cuda_package_name}-samples.%{cuda_package_version}-*.run -prefix=/opt/%{cuda_package_name}-%{cuda_package_version}/samples -cudaprefix=/opt/%{cuda_package_name}-%{cuda_package_version} -noprompt --nox11 >/dev/null 2>&1
	popd >/dev/null 2>&1
fi
#
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/bin2c %{_bindir}/bin2c
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/computeprof %{_bindir}/computeprof
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/crt %{_bindir}/crt
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cudafe %{_bindir}/cudafe
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cudafe++ %{_bindir}/cudafe++
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cuda-gdb %{_bindir}/cuda-gdb
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cuda-gdbserver %{_bindir}/cuda-gdbserver
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cuda-gdb %{_bindir}/cuda-gdb
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cuda-memcheck %{_bindir}/cuda-memcheck
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/cuobjdump %{_bindir}/cuobjdump
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/fatbinary %{_bindir}/fatbinary
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/filehash %{_bindir}/gpu-library-advisor
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nsight %{_bindir}/nsight
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nsight %{_bindir}/nsight_ee_plugins_manage.sh
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvcc %{_bindir}/nvcc
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvcc.profile %{_bindir}/nvcc.profile
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvdisasm %{_bindir}/nvdisasm
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvlink %{_bindir}/nvlink
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvprof %{_bindir}/nvprof
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvprune %{_bindir}/nvprune
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/nvvp %{_bindir}/nvvp
ln -sf /opt/%{cuda_package_name}-%{cuda_package_version}/bin/ptxas %{_bindir}/ptxas
#
> /etc/ld.so.conf.d/00-nvidia-cuda.conf
echo "/opt/%{cuda_package_name}-%{cuda_package_version}/lib64" >> /etc/ld.so.conf.d/00-nvidia-cuda.conf
#
/sbin/ldconfig
#
popd >/dev/null 2>&1


%preun


%postun
NV_NAME=%{cuda_package_name}_%{version}_linux
#
if [ "$1" == "0" ] ; then
#
[ -d /opt/%{cuda_package_name}-%{cuda_package_version} ] && rm -rf /opt/%{cuda_package_name}-%{cuda_package_version}
#
fi
#
/sbin/ldconfig
#    
NV_USAGE_FILE=/usr/src/$NV_NAME.usage
#
NV_USED=1
touch $NV_USAGE_FILE
source $NV_USAGE_FILE
NV_USED=$((NV_USED - 1))
echo "NV_USED=$NV_USED" > $NV_USAGE_FILE
if [ $NV_USED == 0 ] ; then
    #
    #	Remove the sources
    #
    [ -d /usr/src/$NV_NAME ] && rm -rf /usr/src/$NV_NAME
    [ -f /usr/src/$NV_NAME.run ] && rm -f /usr/src/$NV_NAME.run
    [ -f /usr/src/$NV_NAME.usage ] && rm -f /usr/src/$NV_NAME.usage
fi


%clean
rm -rf %{buildroot}


%files
%defattr(-, root, root)
%doc README
%ghost /etc/ld.so.conf.d/00-nvidia-cuda.conf
%ghost /opt/%{cuda_package_name}-%{cuda_package_version}
%ghost %{_bindir}/bin2c
%ghost %{_bindir}/computeprof
%ghost %{_bindir}/crt
%ghost %{_bindir}/cudafe
%ghost %{_bindir}/cudafe++
%ghost %{_bindir}/cuda-gdb
%ghost %{_bindir}/cuda-gdbserver
%ghost %{_bindir}/cuda-gdb
%ghost %{_bindir}/cuda-memcheck
%ghost %{_bindir}/cuobjdump
%ghost %{_bindir}/fatbinary
%ghost %{_bindir}/gpu-library-advisor
%ghost %{_bindir}/nsight
%ghost %{_bindir}/nsight_ee_plugins_manage.sh
%ghost %{_bindir}/nvcc
%ghost %{_bindir}/nvcc.profile
%ghost %{_bindir}/nvdisasm
%ghost %{_bindir}/nvlink
%ghost %{_bindir}/nvprof
%ghost %{_bindir}/nvprune
%ghost %{_bindir}/nvvp
%ghost %{_bindir}/ptxas


%changelog