From 9a58d29c1a8ad1891a74ccd670fc7b23d2e1edf3 Mon Sep 17 00:00:00 2001 From: Lenard Spencer Date: Fri, 17 Apr 2020 10:45:41 +0700 Subject: system/nvidia-legacy390-driver: Fix nvidia-switch. Signed-off-by: Willy Sudiarto Raharjo --- system/nvidia-legacy390-driver/README | 12 +++++----- .../README.nvidia-persistenced | 6 ++--- .../nvidia-legacy390-driver.SlackBuild | 27 ++++++++++++++++------ system/nvidia-legacy390-driver/nvidia-switch | 7 +++++- .../nvidia-legacy390-driver/rc.nvidia-persistenced | 19 --------------- 5 files changed, 35 insertions(+), 36 deletions(-) (limited to 'system/nvidia-legacy390-driver') diff --git a/system/nvidia-legacy390-driver/README b/system/nvidia-legacy390-driver/README index 0fefce671d..3095e866c7 100644 --- a/system/nvidia-legacy390-driver/README +++ b/system/nvidia-legacy390-driver/README @@ -13,8 +13,8 @@ If you build and install this driver on current WITHOUT using the CURRENT="yes" flag, it will corrupt both xorg-server AND libglvnd, so after removing the driver both packages will have to be reinstalled. -This script now installs the nvidia-persistenced daemon. For details see -README.nvidia-persistenced. +This script now gives the option of installing the nvidia-persistenced +daemon. For details see README.nvidia-persistenced. Several useful utilities are included: nvidia-xsettings, nvidia-smi, and nvidia-settings. Please refer to the Nvidia documentation and man pages @@ -42,9 +42,8 @@ NOTES: Since nvidia-legacy390-driver conflicts with some files of xorg, it's a bit complex to install/uninstall the driver. However, installation of the nvidia-legacy390-driver package backs up the conflicting files and puts -the nvidia-specific files into place by automatically running - nvidia-switch --install -in doinst.sh. +the nvidia-specific files into place by automatically running +nvidia-switch --install in doinst.sh. Before uninstalling or upgrading this package, it is IMPORTANT that you execute 'nvidia-switch --remove', which will switch back to the @@ -62,5 +61,6 @@ not working. Here are the affected files (and their packages): /usr/lib[64]/xorg/modules/extensions/libglx.so (xorg-server) Simply remove the dead nvidia symlinks and and reinstall the mesa and -xorg-server packages. (In current, only xorg-server is affected.) +xorg-server packages. (In current, if libglx.so is a dead symlink, +it MUST be removed before reinstalling xorg-server.) diff --git a/system/nvidia-legacy390-driver/README.nvidia-persistenced b/system/nvidia-legacy390-driver/README.nvidia-persistenced index 6a701bb7bd..9b0abc2c73 100644 --- a/system/nvidia-legacy390-driver/README.nvidia-persistenced +++ b/system/nvidia-legacy390-driver/README.nvidia-persistenced @@ -1,9 +1,9 @@ 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: +run it as user nvidia. - # groupadd -g 365 nvidia - # useradd -u 365 -g 365 -c "Nvidia" -d /dev/null -s /bin/false nvidia +To install it, Pass PERSISTENCED=yes to the script. It will create the +user and group nvidia, and install rc.nvidia-persistenced to /etc/rc.d. To activate the daemon, add the following to /etc/rc.d/local: diff --git a/system/nvidia-legacy390-driver/nvidia-legacy390-driver.SlackBuild b/system/nvidia-legacy390-driver/nvidia-legacy390-driver.SlackBuild index c22fca04c2..462e4f800a 100644 --- a/system/nvidia-legacy390-driver/nvidia-legacy390-driver.SlackBuild +++ b/system/nvidia-legacy390-driver/nvidia-legacy390-driver.SlackBuild @@ -173,12 +173,15 @@ cd $TMP/$SRCNAM # 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 -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 +# just in case any other programs make an entry here +if [ -z "$(ls -A /etc/vulkan)" ]; then + rm -rf /etc/vulkan +fi # Compile utilites from source, replacing the precompiled versions # @@ -371,14 +374,24 @@ else 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 +if [ "${PERSISTENCED:-no}" = "yes" ]; then + if ! getent group nvidia > /dev/null 2>&1; then + echo "Creating the group nvidia:" + groupadd -g 365 nvidia || exit 1 + fi + if ! getent passwd nvidia > /dev/null 2>&1; then + echo "Creating the user nvidia:" + useradd -u 365 -g 365 -c "Nvidia" -d /dev/null -s /bin/false nvidia || exit 1 + fi + mkdir -p $PKG/var/run/nvidia-persistenced + chown nvidia:nvidia $PKG/var/run/nvidia-persistenced + mkdir -p $PKG/etc/rc.d + install -m 755 $CWD/rc.nvidia-persistenced $PKG/etc/rc.d/rc.nvidia-persistenced + sed -i "s|__USER__|nvidia|" $PKG/etc/rc.d/rc.nvidia-persistenced +fi cat $CWD/doinst.sh > $PKG/install/doinst.sh -# Flag install as multlib as needed and build package. +# Flag multlib as needed and build package. cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION$MULTI-$TARGET-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/system/nvidia-legacy390-driver/nvidia-switch b/system/nvidia-legacy390-driver/nvidia-switch index aa92b3a01a..2f57366cfd 100644 --- a/system/nvidia-legacy390-driver/nvidia-switch +++ b/system/nvidia-legacy390-driver/nvidia-switch @@ -113,7 +113,7 @@ save_glx(){ case "$1" in "nvidia") if [ -e libglx.so ]; then - mv libglx.so libglx.so-xorg + cp -a libglx.so libglx.so-xorg fi ln -sf libglx.so.$NV_VERSION libglx.so ;; @@ -124,6 +124,11 @@ save_glx(){ else if [ ! -e libglx.so ]; then echo -e "WARNING: libglx.so not found! Please reinstall xorg-server!\n" + else + if [ -L libglx.so ]; then + rm libglx.so + echo -e "WARNING: removed dead symlink libglx.so! Please reinstall xorg-server!\n" + fi fi fi ;; diff --git a/system/nvidia-legacy390-driver/rc.nvidia-persistenced b/system/nvidia-legacy390-driver/rc.nvidia-persistenced index bf53fd9345..59bdf18d11 100644 --- a/system/nvidia-legacy390-driver/rc.nvidia-persistenced +++ b/system/nvidia-legacy390-driver/rc.nvidia-persistenced @@ -22,25 +22,6 @@ # 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} -- cgit v1.2.3