diff options
Diffstat (limited to 'pkgs/os-specific/linux/nvidia-x11/builder.sh')
-rwxr-xr-x | pkgs/os-specific/linux/nvidia-x11/builder.sh | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/pkgs/os-specific/linux/nvidia-x11/builder.sh b/pkgs/os-specific/linux/nvidia-x11/builder.sh index 61ea120772b4..79dd6c1e8c55 100755 --- a/pkgs/os-specific/linux/nvidia-x11/builder.sh +++ b/pkgs/os-specific/linux/nvidia-x11/builder.sh @@ -185,20 +185,27 @@ installPhase() { patchelf --set-rpath "$out/lib:$libPath" "$libname" fi - libname_short=`echo -n "$libname" | sed 's/so\..*/so/'` - - if [[ "$libname" != "$libname_short" ]]; then - ln -srnf "$libname" "$libname_short" - fi - - 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 - fi + # 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 + + libbase=$(basename "$libname") + libdir=$(dirname "$libname") + soname=$(patchelf --print-soname "$libname") + unversioned=${libbase/\.so\.[0-9\.]*/.so} + + 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 |