guix.scm 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ;;;; guix.scm -- Guix package definition
  2. ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
  3. ;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org>
  4. ;;;
  5. ;;; This file is part of Cuirass.
  6. ;;;
  7. ;;; Cuirass is free software: you can redistribute it and/or modify
  8. ;;; it under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation, either version 3 of the License, or
  10. ;;; (at your option) any later version.
  11. ;;;
  12. ;;; Cuirass is distributed in the hope that it will be useful,
  13. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>.
  19. (use-modules (ice-9 popen)
  20. (ice-9 rdelim)
  21. (gnu)
  22. (guix)
  23. (srfi srfi-1))
  24. (define (keep-cuirass-file? file stat)
  25. ;; Return #t if FILE in Cuirass repository must be kept, #f otherwise. FILE
  26. ;; is an absolute file name and STAT is the result of 'lstat' applied to
  27. ;; FILE.
  28. (not (or (any (λ (str) (string-contains file str))
  29. '(".git" "autom4te" "Makefile.in" ".go" ".log"
  30. "stamp-vti" ".dirstamp"))
  31. (any (λ (str) (string-suffix? str file))
  32. '("trs""configure" "Makefile" "config.status" "pre-inst-env"
  33. "aclocal.m4" "bin/cuirass" "bin/evaluate" "config.cache"
  34. "guix.scm")))))
  35. (define %aux-dir
  36. (current-source-directory))
  37. (define %srcdir
  38. (dirname %aux-dir))
  39. (define (git-version-gen)
  40. ;; Return a string containing Cuirass version number.
  41. (let* ((cmd "git-version-gen .tarball-version")
  42. (port (open-input-pipe (string-append %aux-dir "/" cmd)))
  43. (str (read-line port)))
  44. (close-pipe port)
  45. str))
  46. (define (spec+package-list spec)
  47. (list spec (specification->package spec)))
  48. (package
  49. (inherit (specification->package "cuirass"))
  50. (version (git-version-gen))
  51. (source (local-file %srcdir #:recursive? #t
  52. #:select? keep-cuirass-file?))
  53. (arguments
  54. '(#:phases
  55. (modify-phases %standard-phases
  56. (add-after 'unpack 'disable-repo-tests
  57. ;; Disable tests that use a connection to the Guix daemon.
  58. (λ _
  59. (substitute* "Makefile.am"
  60. (("tests/repo.scm \\\\") "\\"))
  61. #t))
  62. (add-before 'configure 'bootstrap
  63. (λ _ (zero? (system* "sh" "bootstrap"))))
  64. (add-after 'install 'wrap-program
  65. (lambda* (#:key inputs outputs #:allow-other-keys)
  66. ;; Wrap the 'cuirass' command to refer to the right modules.
  67. (let* ((out (assoc-ref outputs "out"))
  68. (json (assoc-ref inputs "guile-json"))
  69. (sqlite (assoc-ref inputs "guile-sqlite3"))
  70. (guix (assoc-ref inputs "guix"))
  71. (mods (string-append json "/share/guile/site/2.0:"
  72. sqlite "/share/guile/site/2.0:"
  73. guix "/share/guile/site/2.0")))
  74. (wrap-program (string-append out "/bin/cuirass")
  75. `("GUILE_LOAD_PATH" ":" prefix (,mods))
  76. `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,mods)))))))))
  77. (inputs
  78. (map spec+package-list
  79. '("guile@2.0"
  80. "guile-json"
  81. "guile-sqlite3"
  82. "guix")))
  83. (native-inputs
  84. (map spec+package-list
  85. '("autoconf"
  86. "automake"
  87. "bash"
  88. "pkg-config"
  89. "texinfo"))))