gnu: zstd: Use G-expressions.

* gnu/packages/compression.scm (zstd)[arguments]: Use G-expressions.

Change-Id: Ic5dba01331a0c3c6f119ab9f800ac51829767ec2
This commit is contained in:
Zheng Junjie 2025-02-07 12:16:44 +08:00 committed by Andreas Enge
parent f48719a585
commit 00e2697620
No known key found for this signature in database
GPG key ID: F7D5C9BF765C61E3

View file

@ -1777,79 +1777,78 @@ or junctions, and always follows hard links.")
"lib" ;1.2MiB shared library and headers "lib" ;1.2MiB shared library and headers
"static")) ;1.2MiB static library "static")) ;1.2MiB static library
(arguments (arguments
`(#:phases (list #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'patch-command-file-names (add-after 'unpack 'patch-command-file-names
;; Don't require hard requirements to be in $PATH. ;; Don't require hard requirements to be in $PATH.
(lambda* (#:key outputs #:allow-other-keys) (lambda _
(let* ((out (assoc-ref outputs "out")) (let* ((our (lambda (name) (string-append #$output "/bin/" name))))
(our (lambda (name) (string-append out "/bin/" name)))) (substitute* "programs/zstdgrep"
(substitute* "programs/zstdgrep" (("(:-)(grep)" _ prefix command)
(("(:-)(grep)" _ prefix command) (string-append prefix (which command)))
(string-append prefix (which command))) (("(:-)(zstdcat)" _ prefix command)
(("(:-)(zstdcat)" _ prefix command) (string-append prefix (our command))))
(string-append prefix (our command)))) (substitute* "programs/zstdless"
(substitute* "programs/zstdless" (("zstdcat" command)
(("zstdcat" command) (our command))))))
(our command)))))) (delete 'configure) ;no configure script
(delete 'configure) ;no configure script (add-after 'install 'adjust-library-locations
(add-after 'install 'adjust-library-locations (lambda _
(lambda* (#:key outputs #:allow-other-keys) (let* ((out #$output)
(let* ((out (assoc-ref outputs "out")) (lib #$output:lib)
(lib (assoc-ref outputs "lib")) (static #$output:static)
(static (assoc-ref outputs "static")) (shared-libs (string-append lib "/lib"))
(shared-libs (string-append lib "/lib")) (static-libs (string-append static "/lib")))
(static-libs (string-append static "/lib"))) (mkdir-p static-libs)
(mkdir-p static-libs) ;; This is based on the win64 release zip file from zstd.
;; This is based on the win64 release zip file from zstd. #$@(if (target-mingw?)
,@(if (target-mingw?) #~((for-each delete-file (find-files out "\\.so"))
`((for-each delete-file (find-files out "\\.so")) (for-each delete-file (find-files shared-libs "\\.so"))
(for-each delete-file (find-files shared-libs "\\.so")) (rename-file (string-append shared-libs "/libzstd.a")
(rename-file (string-append shared-libs "/libzstd.a") (string-append static-libs "/libzstd_static.lib"))
(string-append static-libs "/libzstd_static.lib")) (delete-file-recursively
(delete-file-recursively (string-append shared-libs "/pkgconfig"))
(string-append shared-libs "/pkgconfig")) ;; no binary for interpreter `sh' found in $PATH
;; no binary for interpreter `sh' found in $PATH (delete-file (string-append out "/bin/zstdgrep"))
(delete-file (string-append out "/bin/zstdgrep")) (delete-file (string-append out "/bin/zstdless"))
(delete-file (string-append out "/bin/zstdless")) (delete-file (string-append out "/share/man/man1/zstdgrep.1"))
(delete-file (string-append out "/share/man/man1/zstdgrep.1")) (delete-file (string-append out "/share/man/man1/zstdless.1")))
(delete-file (string-append out "/share/man/man1/zstdless.1"))) #~(;; Move the static library to its own output to save ~1MiB.
`(;; Move the static library to its own output to save ~1MiB. (for-each (lambda (ar)
(for-each (lambda (ar) (link ar (string-append static-libs "/"
(link ar (string-append static-libs "/" (basename ar)))
(basename ar))) (delete-file ar))
(delete-file ar)) (find-files shared-libs "\\.a$"))
(find-files shared-libs "\\.a$"))
;; Make sure the pkg-config file refers to the right output. ;; Make sure the pkg-config file refers to the right output.
(substitute* (string-append shared-libs "/pkgconfig/libzstd.pc") (substitute* (string-append shared-libs "/pkgconfig/libzstd.pc")
(("^prefix=.*") (("^prefix=.*")
;; Note: The .pc file expects a trailing slash for 'prefix'. ;; Note: The .pc file expects a trailing slash for 'prefix'.
(string-append "prefix=" lib "/\n"))))))))) (string-append "prefix=" lib "/\n")))))))))
#:make-flags #:make-flags
(list ,(string-append "CC=" (cc-for-target)) #~(list (string-append "CC=" #$(cc-for-target))
(string-append "prefix=" (assoc-ref %outputs "out")) (string-append "prefix=" #$output)
(string-append "libdir=" (assoc-ref %outputs "lib") "/lib") (string-append "libdir=" #$output:lib "/lib")
(string-append "includedir=" (assoc-ref %outputs "lib") "/include") (string-append "includedir=" #$output:lib "/include")
,@(if (target-mingw?) #$@(if (target-mingw?)
`(;; See the note in the Makefile. `(;; See the note in the Makefile.
"TARGET_SYSTEM=Windows" "TARGET_SYSTEM=Windows"
;; Don't try to link with pthread. ;; Don't try to link with pthread.
"THREAD_LD=" "THREAD_LD="
;; This isn't picked up correctly in the Makefiles. ;; This isn't picked up correctly in the Makefiles.
"EXT=.exe") "EXT=.exe")
'()) '())
;; Auto-detection is over-engineered and buggy. ;; Auto-detection is over-engineered and buggy.
"PCLIBDIR=lib" "PCLIBDIR=lib"
"PCINCDIR=include" "PCINCDIR=include"
;; Skip auto-detection of, and creating a dependency on, the build ;; Skip auto-detection of, and creating a dependency on, the build
;; environment's xz for what amounts to a dubious feature anyway. ;; environment's xz for what amounts to a dubious feature anyway.
"HAVE_LZMA=0" "HAVE_LZMA=0"
;; Not currently detected, but be explicit & avoid surprises later. ;; Not currently detected, but be explicit & avoid surprises later.
"HAVE_LZ4=0" "HAVE_LZ4=0"
"HAVE_ZLIB=0") "HAVE_ZLIB=0")
#:tests? ,(not (or (target-hurd?) #:tests? (not (or (target-hurd?)
(%current-target-system))))) (%current-target-system)))))
(home-page "https://facebook.github.io/zstd/") (home-page "https://facebook.github.io/zstd/")
(synopsis "Zstandard real-time compression algorithm") (synopsis "Zstandard real-time compression algorithm")
(description "Zstandard (@command{zstd}) is a lossless compression algorithm (description "Zstandard (@command{zstd}) is a lossless compression algorithm