Archived
1
0
Fork 0

gnu: bzip2: Use gexps.

* gnu/packages/compression.scm (bzip2)[arguments]: Use gexps.
This commit is contained in:
Ludovic Courtès 2023-02-28 17:07:22 +01:00
parent 2aee6bb90c
commit 36ea77f5d7
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015, 2017, 2019, 2020, 2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com> ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
@ -297,93 +297,91 @@ file; as a result, it is often used in conjunction with \"tar\", resulting in
"0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb")))) "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:modules ((guix build gnu-build-system) (list #:modules '((guix build gnu-build-system)
(guix build utils) (guix build utils)
(ice-9 ftw) (ice-9 ftw)
(srfi srfi-1)) (srfi srfi-1))
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'set-paths 'hide-input-bzip2 (add-after 'set-paths 'hide-input-bzip2
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let ((bzip2 (assoc-ref inputs "bzip2"))) (let ((bzip2 (assoc-ref inputs "bzip2")))
(if bzip2 (if bzip2
;; Prevent the build system from retaining a reference to ;; Prevent the build system from retaining a reference to
;; BZIP2 from INPUTS. ;; BZIP2 from INPUTS.
(begin (begin
(setenv "LIBRARY_PATH" (setenv "LIBRARY_PATH"
(string-join (delete (string-append bzip2 "/lib") (string-join (delete (string-append bzip2 "/lib")
(string-split (getenv "LIBRARY_PATH") (string-split (getenv "LIBRARY_PATH")
#\:)) #\:))
":")) ":"))
(format #t "environment variable `LIBRARY_PATH' set to `~a'~%" (format #t "environment variable `LIBRARY_PATH' set to `~a'~%"
(getenv "LIBRARY_PATH"))) (getenv "LIBRARY_PATH")))
(format #t "no bzip2 found, nothing done~%")) (format #t "no bzip2 found, nothing done~%"))
#t))) #t)))
(replace 'configure (replace 'configure
(lambda* (#:key target #:allow-other-keys) (lambda* (#:key target #:allow-other-keys)
(when ,(%current-target-system) (when #$(%current-target-system)
;; Cross-compilation: use the cross tools. ;; Cross-compilation: use the cross tools.
(substitute* (find-files "." "Makefile") (substitute* (find-files "." "Makefile")
(("CC=.*$") (("CC=.*$")
(string-append "CC = " target "-gcc\n")) (string-append "CC = " target "-gcc\n"))
(("AR=.*$") (("AR=.*$")
(string-append "AR = " target "-ar\n")) (string-append "AR = " target "-ar\n"))
(("RANLIB=.*$") (("RANLIB=.*$")
(string-append "RANLIB = " target "-ranlib\n")) (string-append "RANLIB = " target "-ranlib\n"))
(("^all:(.*)test" _ prerequisites) (("^all:(.*)test" _ prerequisites)
;; Remove 'all' -> 'test' dependency. ;; Remove 'all' -> 'test' dependency.
(string-append "all:" prerequisites "\n")))) (string-append "all:" prerequisites "\n"))))
#t)) #t))
(add-before 'build 'build-shared-lib (add-before 'build 'build-shared-lib
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(patch-makefile-SHELL "Makefile-libbz2_so") (patch-makefile-SHELL "Makefile-libbz2_so")
(invoke "make" "-f" "Makefile-libbz2_so"))) (invoke "make" "-f" "Makefile-libbz2_so")))
(add-after 'install 'install-shared-lib (add-after 'install 'install-shared-lib
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
;; The Makefile above does not have an 'install' target, nor does ;; The Makefile above does not have an 'install' target, nor does
;; it create all the (un)versioned symlinks, so we handle it here. ;; it create all the (un)versioned symlinks, so we handle it here.
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(libdir (string-append out "/lib")) (libdir (string-append out "/lib"))
(soname "libbz2.so") (soname "libbz2.so")
;; Locate the built library (e.g. "libbz2.so.1.0.6"). ;; Locate the built library (e.g. "libbz2.so.1.0.6").
(lib (car (scandir "." (lib (car (scandir "."
(lambda (file) (lambda (file)
(and (string-prefix? soname file) (and (string-prefix? soname file)
(eq? 'regular (eq? 'regular
(stat:type (lstat file)))))))) (stat:type (lstat file))))))))
(soversion (string-drop lib (+ 1 (string-length soname))))) (soversion (string-drop lib (+ 1 (string-length soname)))))
(install-file lib libdir) (install-file lib libdir)
(with-directory-excursion libdir (with-directory-excursion libdir
;; Create symlinks libbz2.so.1 -> libbz2.so.1.0, etc. ;; Create symlinks libbz2.so.1 -> libbz2.so.1.0, etc.
(let loop ((base soname) (let loop ((base soname)
(numbers (string-split soversion #\.))) (numbers (string-split soversion #\.)))
(unless (null? numbers) (unless (null? numbers)
(let ((so-file (string-append base "." (car numbers)))) (let ((so-file (string-append base "." (car numbers))))
(symlink so-file base) (symlink so-file base)
(loop so-file (cdr numbers)))))) (loop so-file (cdr numbers))))))
#t))) #t)))
(add-after 'install-shared-lib 'move-static-lib (add-after 'install-shared-lib 'move-static-lib
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")) (let ((out (assoc-ref outputs "out"))
(static (assoc-ref outputs "static"))) (static (assoc-ref outputs "static")))
(with-directory-excursion (string-append out "/lib") (with-directory-excursion (string-append out "/lib")
(install-file "libbz2.a" (string-append static "/lib")) (install-file "libbz2.a" (string-append static "/lib"))
(delete-file "libbz2.a") (delete-file "libbz2.a")
#t)))) #t))))
(add-after 'install-shared-lib 'patch-scripts (add-after 'install-shared-lib 'patch-scripts
(lambda* (#:key outputs inputs #:allow-other-keys) (lambda* (#:key outputs inputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))) (let* ((out (assoc-ref outputs "out")))
(substitute* (string-append out "/bin/bzdiff") (substitute* (string-append out "/bin/bzdiff")
(("/bin/rm") "rm"))) (("/bin/rm") "rm")))
#t))) #t)))
#:make-flags (list (string-append "PREFIX=" #:make-flags #~(list (string-append "PREFIX="
(assoc-ref %outputs "out"))) (assoc-ref %outputs "out")))
;; Don't attempt to run the tests when cross-compiling. ;; Don't attempt to run the tests when cross-compiling.
,@(if (%current-target-system) #:tests? (not (%current-target-system))))
'(#:tests? #f)
'())))
(inputs (inputs
`(,@(if (%current-target-system) `(,@(if (%current-target-system)
`(("bash" ,bash-minimal)) `(("bash" ,bash-minimal))