system/nvidia-driver: added rc.nvidia-persistenced.

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Lenard Spencer 2020-04-10 00:28:23 +07:00 committed by Willy Sudiarto Raharjo
parent cd90c74dab
commit d10cd53348
No known key found for this signature in database
GPG Key ID: 887B8374D7333381
9 changed files with 211 additions and 98 deletions

View File

@ -12,16 +12,18 @@ If you plan to test this buildscript on current (15.0 EXPERIMENTAL), to
avoid stomping on the installed libglvnd, do:
CURRENT="yes" ./nvidia-driver.SlackBuild
This script now installs the nvidia-persitenced daemon. For details, see
README.nvidia-persitenced.
Several useful utilities are included: nvidia-xsettings, nvidia-smi, and
nvidia-settings. Please refer to the Nvidia documentation and man pages
for details and usage.
For CUDA/OpenCL to work after reboot, and for utilites such as nvidia-smi,
you might need to include the following line in your /etc/rc.d/rc.local:
-------------8<---------------
# Create missing nvidia device nodes after reboot
/usr/bin/nvidia-modprobe -c 0 -u
------------->8---------------
# Create missing nvidia device nodes after reboot
/usr/bin/nvidia-modprobe -c 0 -u
Notes:
1. You still need to blacklist the opensource nouveau driver. This is
@ -30,7 +32,8 @@ Notes:
2. If nvidia-driver is already installed, there may be extraneous
"unable to find installed file..." messages on the console and log.
This is benign and due to the nvidia installer not being very smart.
3. If you want to revert back to the open source drivers, run
'nvidia-switch --remove' to restore the original libGL.la and then
'removepkg nvidia-driver' "should" work in most cases. If not, simply
reinstall the orginal Mesa and xorg-server packages.
3. On 14.2 ONLY, if you want to revert back to the open source drivers,
run 'nvidia-switch --remove' to restore the original libGL.la and
then 'removepkg nvidia-driver' "should" work in most cases. If not,
simply reinstall the orginal Mesa package. (THIS STEP IS NO LONGER
NECESSARY ON CURRENT.)

View File

@ -0,0 +1,27 @@
The driver now includes rc.nvidia-persistenced as an option. While it can
be run as root, it is more secure to run it as an unpriveleged user, so we
run it as user nvidia. Create the nvidia user and group with the following:
# groupadd -g 365 nvidia
# useradd -u 365 -g 365 -c "Nvidia" -d /dev/null -s /bin/false nvidia
To activate the daemon, add the following to /etc/rc.d/local:
# Start the nvidia-persistenced daemon:
if [ -x /etc/rc.d/rc.nvidia-persistenced ]; then
/etc/rc.d/rc.nvidia-persistenced start
fi
and then 'chmod +x /etc/rc.d/rc.nvidia-persistenced' to make it executable.
Add the following to /etc/rc.d/rc.local_shutdown:
# Stop the nvidia-persistenced daemon:
if [ -x /etc/rc.d/rc.nvidia-persistenced ]; then
/etc/rc.d/rc.nvidia-persistenced stop
fi
NOTE: This may not work on all systems. If you encounter problems
with it, just 'chmod -x /etc/rc.d/rc.persistenced' and it will no
longer load. YMMV.

View File

@ -49,3 +49,5 @@
7.1 15-Dec-2019 version update LLB, fix libs
7.2 12-Feb-2020 version update LLB
7.3 24-Mar-2020 version update LLB, fixes nvidia-switch; doinst; update patch (thanks Daniel B.)
7.4 03-Apr-2020 script cleanups, added rc.nvidia-persitenced
new maintainer Lenard Spencer <lenardrspencer@gmail.com>

View File

@ -2,5 +2,3 @@ if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications
fi
./usr/sbin/nvidia-switch --install

View File

@ -2,7 +2,9 @@
# Slackware build script for nvidia-driver
# Copyright 2012-2019 Edward W. Koenig, Vancouver, WA, USA
# Copyright 2012-2019 Edward W. Koenig, Vancouver, WA, US
# Copyright 2020 Lenard Spencer, Orlando, FL, USA
#
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@ -26,7 +28,7 @@
PRGNAM=nvidia-driver
VERSION=${VERSION:-440.64}
BUILD=${BUILD:-1}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
CURRENT=${CURRENT:-no}
@ -57,6 +59,14 @@ else
exit 1
fi
# There are a couple of unresolved issues with nvidia-installer, so we
# abort if an Nvidia driver is still installed:
if [ -x /usr/bin/nvidia-installer ]; then
echo -e "\n A previous Nvidia installation has been detected!"
echo -e " Please remove the installed driver and rerun this script.\n"
exit 1
fi
SRCNAM=NVIDIA-Linux-$TARGET-${VERSION}
# make a clean package directory tree
@ -120,16 +130,12 @@ cd -
mv -f $PKG/usr/bin/nvidia-installer $TMP/$SRCNAM
mv -f $PKG/usr/man/man1/nvidia-installer.1.gz $TMP/$SRCNAM
if [ "$ARCH" = "x86_64" -a "${COMPAT32}" = "yes" ]; then
if [ "${COMPAT32}" = "yes" ]; then
COMP32="--install-compat32-libs --compat32-prefix=$PKG/usr"
MULTI="_multi"
MULTI="_multilib"
else
if [ ! "$ARCH" = "x86_64" ]; then
COMP32=""
else
COMP32="--no-install-compat32-libs"
MULTI=""
fi
COMP32="--no-install-compat32-libs"
MULTI=""
fi
# Install the binary libs using nvidia-installer compiled above
@ -150,55 +156,50 @@ cd $TMP/$SRCNAM
--log-file-name=$PKG/var/log/nvidia-installer.log \
--egl-external-platform-config-path=$PKG/usr/share/egl/egl_external_platform.d \
--no-nvidia-modprobe \
--install-libglvnd \
$COMP32
# Clean-up: we really do not need this:
rm -rf $PKG/var/log/nvidia
# If running current (15.0) remove duplicate libglvnd files and symlinks
# Move ICDs to $PKG and cleanup (no switch option in installer?)
mv /etc/OpenCL/vendors/nvidia.icd $PKG/etc/OpenCL/vendors/nvidia.icd
mv /etc/vulkan/icd.d/nvidia_icd.json $PKG/etc/vulkan/icd.d/nvidia_icd.json
mv /etc/vulkan/implicit_layer.d/nvidia_layers.json $PKG/etc/vulkan/implicit_layer.d/nvidia_layers.json
rm -rf /etc/vulkan
# In current, mesa now puts an entry into this directory, so we
# leave it alone if it is not empty
if [ -z "$(ls -A /etc/OpenCL/vendors)" ]; then
rm -rf /etc/OpenCL
fi
if [ "$CURRENT" = "yes" ]; then
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libEGL.so{,.1,.1.1.0}
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libGL.so{,.1,.1.7.0}
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libGLESv1_CM.so{,.1,.1.2.0}
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libGLESv2.so{,.2,.2.1.0}
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libGLX.so{,.0}
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libGLdispatch.so.0
rm -f $PKG/usr/lib$LIBDIRSUFFIX/libOpenGL.so{,.0}
if [ "$ARCH" = "x86_64" -a "${COMPAT32}" = "yes" ]; then
rm -f $PKG/usr/lib/libEGL.so{,.1,.1.1.0}
rm -f $PKG/usr/lib/libGL.so{,.1,.1.7.0}
rm -f $PKG/usr/lib/libGLESv1_CM.so{,.1,.1.2.0}
rm -f $PKG/usr/lib/libGLESv2.so{,.2,.2.1.0}
rm -f $PKG/usr/lib/libGLX.so{,.0}
rm -f $PKG/usr/lib/libGLdispatch.so.0
rm -f $PKG/usr/lib/libOpenGL.so{,.0}
fi
# Don't ship .la files:
# Don't ship .la files. Also, libOpenCL.so is now included
# in current (in ocl-icd), so we don't need this one.
rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la
if [ "$ARCH" = "x86_64" -a "${COMPAT32}" = "yes" ]; then
rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libOpenCL.so.1.0.0
if [ "${COMPAT32}" = "yes" ]; then
rm -f $PKG/usr/lib/*.la
rm -f $PKG/usr/lib/libOpenCL.so.1.0.0
fi
else
# Correct wrong paths in /usr/lib{,64}/libGL.la
sed -i "s|$PKG||" $PKG/usr/lib${LIBDIRSUFFIX}/libGL.la
if [ "${COMPAT32}" = "yes" ]; then
# This one points to /usr/ instead of /usr/lib/, so we need to fix it anyway
sed -i "s|$PKG/usr|/usr/lib|" $PKG/usr/lib/libGL.la
fi
# save libGL.la for 14.2
cd $PKG/usr/lib$LIBDIRSUFFIX
mv libGL.la libGL.la-nvidia
cd -
if [ "$ARCH" = "x86_64" -a "${COMPAT32}" = "yes" ]; then
if [ "${COMPAT32}" = "yes" ]; then
cd $PKG/usr/lib
mv libGL.la libGL.la-nvidia
cd -
fi
# Bash script to cleanly install (in doinst.sh) and uninstall the nvidia files
# so we don't stomp on the overlapping xorg files.
# Bash script to cleanly install (in doinst.sh) and uninstall the nvidia
# files so we don't stomp on the overlapping xorg files.
# Note: switching can be problematic ;-)
install -m 0755 $CWD/nvidia-switch $PKG/usr/sbin/
sed -i s/PKGVERSION/$VERSION/g $PKG/usr/sbin/nvidia-switch
sed -i s/LIBDIRSUFFIX/$LIBDIRSUFFIX/g $PKG/usr/sbin/nvidia-switch
if [ "$GLVND" = "yes" ]; then
sed -i s/GLVNDFLAG/yes/g $PKG/usr/sbin/nvidia-switch
else
sed -i s/GLVNDFLAG/no/g $PKG/usr/sbin/nvidia-switch
fi
if [ ${COMPAT32} = "yes" ]; then
sed -i s/LIB32FLAG/yes/g $PKG/usr/sbin/nvidia-switch
else
@ -206,14 +207,6 @@ else
fi
fi
# add tls
if [ "$ARCH" = "x86_64" -a "${COMPAT32}" = "yes" ]; then
install -m 755 32/libnvidia-tls.so.$VERSION $PKG/usr/lib/tls/libnvidia-tls.so.$VERSION
cd $PKG/usr/lib
ln -sf tls/libnvidia-tls.so.$VERSION libnvidia-tls.so.$VERSION
cd -
fi
# Compile utilites from source, replacing the precompiled versions
#
# Compiling nvidia-settings
@ -273,8 +266,8 @@ cd -
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" make
install -m 755 _out/Linux_$TARGET/nvidia-modprobe $PKG/usr/bin/
# must be installed suid root for nvidia-persistenced to work properly
install -m 4755 _out/Linux_$TARGET/nvidia-modprobe $PKG/usr/bin/
install -m 644 _out/Linux_$TARGET/nvidia-modprobe.1.gz $PKG/usr/man/man1/
cd -
@ -288,24 +281,16 @@ cd -
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" make
#FIXME: need rc.nvidia-persistenced script; see doc
install -m 755 _out/Linux_$TARGET/nvidia-persistenced $PKG/usr/bin/
install -m 644 _out/Linux_$TARGET/nvidia-persistenced.1.gz $PKG/usr/man/man1/
cd -
# These update or correct wrong paths
# These update the paths in nvidia-settings.desktop
sed -i "s|__UTILS_PATH__|/usr/bin|" $PKG/usr/share/applications/nvidia-settings.desktop
sed -i "s|__PIXMAP_PATH__|/usr/share/pixmaps|" $PKG/usr/share/applications/nvidia-settings.desktop
sed -i "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Application;Settings;|" $PKG/usr/share/applications/nvidia-settings.desktop
# Move ICDs to $PKG and cleanup (no switch option in installer?)
mv /etc/OpenCL/vendors/nvidia.icd $PKG/etc/OpenCL/vendors/nvidia.icd
mv /etc/vulkan/icd.d/nvidia_icd.json $PKG/etc/vulkan/icd.d/nvidia_icd.json
mv /etc/vulkan/implicit_layer.d/nvidia_layers.json $PKG/etc/vulkan/implicit_layer.d/nvidia_layers.json
rm -rf /etc/OpenCL
rm -rf /etc/vulkan
# Remove xorg conf file since we take care of that in nvidia-driver
# Remove xorg conf file since we handle that in nvidia-kernel
rm -rf $PKG/etc/X11/xorg.conf.d
cd $TMP/$SRCNAM
@ -319,8 +304,26 @@ cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README.Slackware
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
sed "s/PKGVERSION/$VERSION/g" $CWD/slack-desc > $PKG/install/slack-desc
if [ "$COMPAT32" = "yes" ]; then
sed -i "s|@MULTILIB@| This package includes the 32-bit libraries.|" $PKG/install/slack-desc
else
sed -i "s|@MULTILIB@||" $PKG/install/slack-desc
fi
# Add rc.nvidia-persistenced:
mkdir -p $PKG/var/run/nvidia-persistenced
chown nvidia:nvidia $PKG/var/run/nvidia-persistenced
mkdir -p $PKG/etc/rc.d
cat $CWD/rc.nvidia-persistenced > $PKG/etc/rc.d/rc.nvidia-persistenced
sed -i "s|__USER__|nvidia|" $PKG/etc/rc.d/rc.nvidia-persistenced
cat $CWD/doinst.sh > $PKG/install/doinst.sh
# 14.2 needs nvidia-switch, -current does not
if [ "$CURRENT" = "no" ]; then
echo -e "./usr/sbin/nvidia-switch --install\n" >> $PKG/install/doinst.sh
fi
# Flag install as multlib as needed and build package.
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION$MULTI-$TARGET-$BUILD$TAG.${PKGTYPE:-tgz}

View File

@ -16,5 +16,5 @@ MD5SUM_x86_64="ba746d5b5f50369139bbed47da04aa74 \
94b081b77eba7cfd2aa82ffda54cca90 \
80a50eb9892588d57cca02b1822cddbd"
REQUIRES="nvidia-kernel"
MAINTAINER="Edward W. Koenig"
EMAIL="kingbeowulf@gmail.com"
MAINTAINER="Lenard Spencer"
EMAIL="lenardrspencer@gmail.com"

View File

@ -1,6 +1,7 @@
#!/bin/sh
# Copyright 2012-2019 Edward W. Koenig, Vancouver, WA, USA
# Updates copyright 2020 Lenard Spencer, Orlando, FL, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@ -20,26 +21,26 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# nvidia-switch utility 4.6
# nvidia-switch utility 4.7.1
#
# A tool to install and cleanly remove the nvidia driver without stomping on the xorg files.
# Note: this tool "should" allow switching on the fly, but why? Pick a driver! You will still
# need to edit a bunch of other config files.
# A tool to install and cleanly remove the nvidia driver without stomping
# on the mesa files. Note: this tool "should" allow switching on the fly,
# but why? Pick a driver! You will stilll need to edit a bunch of other
# config files.
# TO-DO: needs more cleanup, simplify linking using system tools, add 15.0 fixes
ROOT="${ROOT:-/}"
# When ROOT=<PATH> is specified when using {install,upgrade,remove}pkg,
# PATH is usually specified without a trailing "/", so we need to add it
if [ "$ROOT" = "" ]; then
ROOT="${ROOT:-"/"}"
else
ROOT="${ROOT}/"
fi
CWD=$(pwd)
COMPAT32="LIB32FLAG" # This will be replaced in the build script (yes | no)
LIBSUFFIX="LIBDIRSUFFIX" # This will be replaced in the build script
INC="${ROOT}usr/include/GL"
LIB="${ROOT}usr/lib${LIBSUFFIX}"
LIB32="${ROOT}usr/lib"
XMOD="${LIB}/xorg/modules"
XLIB="$XMOD/extensions"
NV_VERSION="PKGVERSION" # This will be replaced in the build script
GL_VERSION="1.2.0"
GLVND="yes" # This will be replaced in the build script (yes | no)
save_GL(){
# backup original mesa and xorg conflicts
@ -48,11 +49,13 @@ save_GL(){
"nvidia")
mv libGL.la libGL.la-xorg
mv libGL.la-nvidia libGL.la
/sbin/ldconfig
;;
"xorg")
mv libGL.la libGL.la-nvidia
mv libGL.la-xorg libGL.la
/sbin/ldconfig
;;
*)
@ -66,11 +69,12 @@ save_GL(){
nvidia_install(){
echo $'Installing to nvidia-driver files!\n'
echo "Make sure the nvidia driver is ENABLED in /etc/X11/xorg.conf"
echo "and in /etc/X11/xorg.conf.d."
echo "Otherwise, this may lead to improperly working drivers."
echo "and/or in either /usr/share/X11/xorg.conf.d or"
echo "/etc/X11/xorg.conf.d. Otherwise, this may lead to improperly"
echo -e "working drivers.\n"
save_GL "nvidia" $LIB
# Check for multilib configuration
if [ "$COMPAT32" = "yes" ]; then
save_GL "nvidia" $LIB32
@ -79,33 +83,29 @@ nvidia_install(){
nvidia_remove(){
echo $'Returning to stock xorg files!\n'
echo "Make sure the nvidia driver is DISABLED in /usr/share/X11/xorg.conf.d"
echo "/etc/X11/xorg.conf and in /etc/X11/xorg.conf.d."
echo "Make sure the nvidia driver is DISABLED in /etc/X11/xorg.conf"
echo "and in /usr/share/X11/xorg.conf.d and /etc/X11/xorg.conf.d."
echo "(Removing nvidia-kernelis recommended to accomplish this.)"
echo "Otherwise, this may lead to improperly working drivers."
echo -e "\nPlease run /sbin/ldconfing after removing nvidia-driver."
save_GL "xorg" $LIB
# Check for multilib configuration
if [ "$COMPAT32" = "yes" ]; then
save_GL "xorg" $LIB32
fi
if [ -e $NV_CONF ]; then
echo "You will need to remove/save $NV_CONF from nvidia-driver to use"
echo "any open source drivers."
fi
}
usage(){
echo "Usage:"
echo " --install Set up nvidia driver files (do not use!)"
echo " --remove Return to stock xorg files and restore all symlinks"
echo " --install Set up nvidia driver files and update symlinks"
echo " --remove Return to stock xorg files and restore symlinks"
echo " --help Show this help message"
}
case "$1" in
"--install")
nvidia_install
;;
"--remove")
nvidia_remove

View File

@ -0,0 +1,80 @@
#!/bin/sh -e
#
# NVIDIA Persistence Daemon Init Script
#
# Copyright (c) 2013 NVIDIA Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# This is a sample System V init script, designed to show how the NVIDIA
# Persistence Daemon can be started.
#
# This sample does not rely on any init system functions, to ensure the
# widest portability possible.
#
# chkconfig: 2345 99 01
# description: Starts and stops the NVIDIA Persistence Daemon
# processname: nvidia-persistenced
#
### BEGIN INIT INFO
# Provides: nvidia-persistenced
# Required-Start: $ALL
# Required-Stop: $ALL
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Starts and stops the NVIDIA Persistence Daemon
### END INIT INFO
NVPD=nvidia-persistenced
NVPD_BIN=/usr/bin/${NVPD}
NVPD_RUNTIME=/var/run/${NVPD}
NVPD_PIDFILE=${NVPD_RUNTIME}/${NVPD}.pid
NVPD_USER=__USER__
if [ -f ${NVPD_PIDFILE} ]; then
read -r NVPD_PID < "${NVPD_PIDFILE}"
# Remove stale runtime files
if [ "${NVPD_PID}" ] && [ ! -d /proc/${NVPD_PID} ]; then
unset NVPD_PID
rm -rf "${NVPD_RUNTIME}"
fi
fi
case "${1}" in
start)
echo "Starting NVIDIA Persistence Daemon"
# Execute the daemon as the intended user
${NVPD_BIN} --user ${NVPD_USER}
;;
stop)
echo "Stopping NVIDIA Persistence Daemon"
# Stop the daemon - its PID should have been read in
[ ! -z "${NVPD_PID}" ] && kill ${NVPD_PID} &> /dev/null
;;
restart)
$0 stop
sleep 2
$0 start
;;
*) echo "usage: $0 {start|stop|restart}"
esac
exit 0

View File

@ -15,5 +15,5 @@ nvidia-driver:
nvidia-driver: See /usr/doc/nvidia-driver-PKGVERSION/README.Slackware
nvidia-driver: for more information.
nvidia-driver:
nvidia-driver:
nvidia-driver: https://www.nvidia.com
nvidia-driver: