mirror of
https://gitlab.com/nonguix/nonguix.git
synced 2024-11-24 17:38:14 +01:00
nongnu: nvidia-driver: Rewrite logic for creating short name symbolic links.
* nongnu/packages/nvidia.scm (nvidia-driver)[arguments]<#:phases>: Rewrite logic for creating short name symbolic links, utilizing patchelf. Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
parent
fe9813a3ee
commit
df03530aed
1 changed files with 33 additions and 26 deletions
|
@ -107,6 +107,8 @@
|
||||||
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
|
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys)
|
||||||
(chdir "..")
|
(chdir "..")
|
||||||
(use-modules (ice-9 ftw)
|
(use-modules (ice-9 ftw)
|
||||||
|
(ice-9 popen)
|
||||||
|
(ice-9 rdelim)
|
||||||
(ice-9 regex)
|
(ice-9 regex)
|
||||||
(ice-9 textual-ports))
|
(ice-9 textual-ports))
|
||||||
(let* ((libdir (string-append #$output "/lib"))
|
(let* ((libdir (string-append #$output "/lib"))
|
||||||
|
@ -201,10 +203,11 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
(string-append #$(this-package-input "wayland") "/lib"))
|
(string-append #$(this-package-input "wayland") "/lib"))
|
||||||
":")))
|
":")))
|
||||||
(define (patch-elf file)
|
(define (patch-elf file)
|
||||||
(format #t "Patching ~a ...~%" file)
|
(format #t "Patching ~a ..." file)
|
||||||
(unless (string-contains file ".so")
|
(unless (string-contains file ".so")
|
||||||
(invoke "patchelf" "--set-interpreter" ld.so file))
|
(invoke "patchelf" "--set-interpreter" ld.so file))
|
||||||
(invoke "patchelf" "--set-rpath" rpath file))
|
(invoke "patchelf" "--set-rpath" rpath file)
|
||||||
|
(display " done\n"))
|
||||||
(for-each (lambda (file)
|
(for-each (lambda (file)
|
||||||
(when (elf-file? file)
|
(when (elf-file? file)
|
||||||
(patch-elf file)))
|
(patch-elf file)))
|
||||||
|
@ -213,30 +216,34 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
|
||||||
|
|
||||||
;; ------------------------------
|
;; ------------------------------
|
||||||
;; Create short name symbolic links
|
;; Create short name symbolic links
|
||||||
(for-each (lambda (file)
|
(define (get-soname file)
|
||||||
(let* ((short (regexp-substitute
|
(when elf-file? file
|
||||||
#f
|
(let* ((cmd (string-append "patchelf --print-soname " file))
|
||||||
(string-match "([^/]*\\.so).*" file)
|
(port (open-input-pipe cmd))
|
||||||
1))
|
(soname (read-line port)))
|
||||||
(major (cond
|
(close-pipe port)
|
||||||
((or (string=? short "libGLX.so")
|
soname)))
|
||||||
(string=? short "libGLX_nvidia.so")
|
|
||||||
(string=? short "libEGL_nvidia.so")) "0")
|
(for-each
|
||||||
((string=? short "libGLESv2.so") "2")
|
(lambda (lib)
|
||||||
(else "1")))
|
(let ((lib-soname (get-soname lib)))
|
||||||
(mid (string-append short "." major))
|
(when (string? lib-soname)
|
||||||
(short-file (string-append libdir "/" short))
|
(let* ((soname (string-append
|
||||||
(mid-file (string-append libdir "/" mid)))
|
(dirname lib) "/" lib-soname))
|
||||||
;; FIXME the same name, print out warning at least
|
(base (string-append
|
||||||
;; [X] libEGL.so.1.1.0
|
(regexp-substitute
|
||||||
;; [ ] libEGL.so.435.21
|
#f (string-match "(.*)\\.so.*" soname) 1)
|
||||||
(when (not (file-exists? short-file))
|
".so"))
|
||||||
(format #t "Linking ~a to ~a ...~%" short file)
|
(source (basename lib)))
|
||||||
(symlink (basename file) short-file))
|
(for-each
|
||||||
(when (not (file-exists? mid-file))
|
(lambda (target)
|
||||||
(format #t "Linking ~a to ~a ...~%" mid file)
|
(unless (file-exists? target)
|
||||||
(symlink (basename file) mid-file))))
|
(format #t "Symlinking ~a -> ~a..."
|
||||||
(find-files libdir "\\.so\\."))
|
target source)
|
||||||
|
(symlink source target)
|
||||||
|
(display " done\n")))
|
||||||
|
(list soname base))))))
|
||||||
|
(find-files #$output "\\.so"))
|
||||||
(symlink (string-append "libglxserver_nvidia.so." #$version)
|
(symlink (string-append "libglxserver_nvidia.so." #$version)
|
||||||
(string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so"))))))))
|
(string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so"))))))))
|
||||||
(supported-systems '("x86_64-linux"))
|
(supported-systems '("x86_64-linux"))
|
||||||
|
|
Loading…
Reference in a new issue