Unverified Commit 4e854488 authored by K900's avatar K900 Committed by GitHub
Browse files

linuxPackages.nvidia_x11: install libraries with correct sonames (#343706)

parents d52c8e7c 66635912
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -185,20 +185,27 @@ installPhase() {
        patchelf --set-rpath "$out/lib:$libPath" "$libname"
      fi

      libname_short=`echo -n "$libname" | sed 's/so\..*/so/'`
      # Manually create the right symlinks for the libraries.
      #
      # We can't just use ldconfig, because it does not create libfoo.so symlinks,
      # only libfoo.so.1.
      # Also, the symlink chain must be libfoo.so -> libfoo.so.1 -> libfoo.so.123.45,
      # or ldconfig will explode.
      # See: https://github.com/bminor/glibc/blob/6f3f6c506cdaf981a4374f1f12863b98ac7fea1a/elf/ldconfig.c#L854-L877

      if [[ "$libname" != "$libname_short" ]]; then
        ln -srnf "$libname" "$libname_short"
      fi
      libbase=$(basename "$libname")
      libdir=$(dirname "$libname")
      soname=$(patchelf --print-soname "$libname")
      unversioned=${libbase/\.so\.[0-9\.]*/.so}

      if [[ $libname_short =~ libEGL.so || $libname_short =~ libEGL_nvidia.so || $libname_short =~ libGLX.so || $libname_short =~ libGLX_nvidia.so ]]; then
          major=0
      else
          major=1
      if [[ -n "$soname" ]]; then
        if [[ "$soname" != "$libbase" ]]; then
          ln -s "$libbase" "$libdir/$soname"
        fi

      if [[ "$libname" != "$libname_short.$major" ]]; then
        ln -srnf "$libname" "$libname_short.$major"
        if [[ "$soname" != "$unversioned" ]]; then
          ln -s "$soname" "$libdir/$unversioned"
        fi
      fi
    done