nongnu: nvidia-driver: Remove unused dirname variables in post-install phase.

* nongnu/packages/nvidia.scm (nvidia-driver)[arguments]<#:phases>: Remove
dirname variables.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
Hilton Chain 2022-11-21 13:19:39 +08:00 committed by Jonathan Brielmaier
parent 61c61bd8c2
commit 3c0e54efbf
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -172,75 +172,71 @@ KERNEL==\"nvidia_uvm\", RUN+=\"@sh@ -c '@mknod@ -m 666 /dev/nvidia-uvm-tools c $
(("@\\<(sh|grep|mknod|cut)\\>@" all cmd) (("@\\<(sh|grep|mknod|cut)\\>@" all cmd)
(search-input-file inputs (string-append "/bin/" cmd))))))) (search-input-file inputs (string-append "/bin/" cmd)))))))
(add-after 'install 'post-install (add-after 'install 'post-install
(lambda* (#:key inputs native-inputs outputs #:allow-other-keys) (lambda _
(let* ((libdir (string-append #$output "/lib")) ;; ------------------------------
(bindir (string-append #$output "/bin")) ;; patchelf
(etcdir (string-append #$output "/etc"))) (let* ((ld.so (string-append #$(this-package-input "glibc")
#$(glibc-dynamic-linker)))
(rpath (string-join
(list "$ORIGIN"
(string-append #$output "/lib")
(string-append #$gcc:lib "/lib")
(string-append #$gtk+-2 "/lib")
(string-append #$(this-package-input "atk") "/lib")
(string-append #$(this-package-input "cairo") "/lib")
(string-append #$(this-package-input "gdk-pixbuf") "/lib")
(string-append #$(this-package-input "glib") "/lib")
(string-append #$(this-package-input "glibc") "/lib")
(string-append #$(this-package-input "gtk+") "/lib")
(string-append #$(this-package-input "libx11") "/lib")
(string-append #$(this-package-input "libxext") "/lib")
(string-append #$(this-package-input "pango") "/lib")
(string-append #$(this-package-input "wayland") "/lib"))
":")))
(define (patch-elf file)
(format #t "Patching ~a ..." file)
(unless (string-contains file ".so")
(invoke "patchelf" "--set-interpreter" ld.so file))
(invoke "patchelf" "--set-rpath" rpath file)
(display " done\n"))
(for-each (lambda (file)
(when (elf-file? file)
(patch-elf file)))
(append (find-files #$output ".*\\.so")
(find-files (string-append #$output "/bin")))))
;; ------------------------------ ;; ------------------------------
;; patchelf ;; Create short name symbolic links
(let* ((ld.so (string-append #$(this-package-input "glibc") (define (get-soname file)
#$(glibc-dynamic-linker))) (when elf-file? file
(rpath (string-join (let* ((cmd (string-append "patchelf --print-soname " file))
(list "$ORIGIN" (port (open-input-pipe cmd))
(string-append #$output "/lib") (soname (read-line port)))
(string-append #$gcc:lib "/lib") (close-pipe port)
(string-append #$gtk+-2 "/lib") soname)))
(string-append #$(this-package-input "atk") "/lib")
(string-append #$(this-package-input "cairo") "/lib")
(string-append #$(this-package-input "gdk-pixbuf") "/lib")
(string-append #$(this-package-input "glib") "/lib")
(string-append #$(this-package-input "glibc") "/lib")
(string-append #$(this-package-input "gtk+") "/lib")
(string-append #$(this-package-input "libx11") "/lib")
(string-append #$(this-package-input "libxext") "/lib")
(string-append #$(this-package-input "pango") "/lib")
(string-append #$(this-package-input "wayland") "/lib"))
":")))
(define (patch-elf file)
(format #t "Patching ~a ..." file)
(unless (string-contains file ".so")
(invoke "patchelf" "--set-interpreter" ld.so file))
(invoke "patchelf" "--set-rpath" rpath file)
(display " done\n"))
(for-each (lambda (file)
(when (elf-file? file)
(patch-elf file)))
(find-files #$output ".*\\.so"))
(patch-elf (string-append bindir "/" "nvidia-smi")))
;; ------------------------------ (for-each
;; Create short name symbolic links (lambda (lib)
(define (get-soname file) (let ((lib-soname (get-soname lib)))
(when elf-file? file (when (string? lib-soname)
(let* ((cmd (string-append "patchelf --print-soname " file)) (let* ((soname (string-append
(port (open-input-pipe cmd)) (dirname lib) "/" lib-soname))
(soname (read-line port))) (base (string-append
(close-pipe port) (regexp-substitute
soname))) #f (string-match "(.*)\\.so.*" soname) 1)
".so"))
(for-each (source (basename lib)))
(lambda (lib) (for-each
(let ((lib-soname (get-soname lib))) (lambda (target)
(when (string? lib-soname) (unless (file-exists? target)
(let* ((soname (string-append (format #t "Symlinking ~a -> ~a..."
(dirname lib) "/" lib-soname)) target source)
(base (string-append (symlink source target)
(regexp-substitute (display " done\n")))
#f (string-match "(.*)\\.so.*" soname) 1) (list soname base))))))
".so")) (find-files #$output "\\.so"))
(source (basename lib))) (symlink (string-append "libglxserver_nvidia.so." #$version)
(for-each (string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so")))))))
(lambda (target)
(unless (file-exists? target)
(format #t "Symlinking ~a -> ~a..."
target source)
(symlink source target)
(display " done\n")))
(list soname base))))))
(find-files #$output "\\.so"))
(symlink (string-append "libglxserver_nvidia.so." #$version)
(string-append #$output "/lib/xorg/modules/extensions/" "libglxserver_nvidia.so"))))))))
(supported-systems '("x86_64-linux")) (supported-systems '("x86_64-linux"))
(native-inputs (list patchelf)) (native-inputs (list patchelf))
(inputs (inputs