texlive-build-system.scm 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (guix build texlive-build-system)
  20. #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  21. #:use-module (guix build utils)
  22. #:use-module (guix build union)
  23. #:use-module (ice-9 match)
  24. #:use-module (ice-9 ftw)
  25. #:use-module (srfi srfi-1)
  26. #:use-module (srfi srfi-26)
  27. #:export (%standard-phases
  28. texlive-build))
  29. ;; Commentary:
  30. ;;
  31. ;; Builder-side code of the standard build procedure for TeX Live packages.
  32. ;;
  33. ;; Code:
  34. (define (compile-with-latex format file)
  35. (invoke format
  36. "-interaction=nonstopmode"
  37. "-output-directory=build"
  38. (string-append "&" format)
  39. file))
  40. (define* (build #:key inputs build-targets tex-format #:allow-other-keys)
  41. (mkdir "build")
  42. (for-each (cut compile-with-latex tex-format <>)
  43. (if build-targets build-targets
  44. (scandir "." (cut string-suffix? ".ins" <>)))))
  45. (define* (install #:key outputs tex-directory #:allow-other-keys)
  46. (let* ((out (assoc-ref outputs "out"))
  47. (target (string-append
  48. out "/share/texmf-dist/tex/" tex-directory)))
  49. (mkdir-p target)
  50. (for-each delete-file (find-files "." "\\.(log|aux)$"))
  51. (for-each (cut install-file <> target)
  52. (find-files "build" ".*"))))
  53. (define %standard-phases
  54. (modify-phases gnu:%standard-phases
  55. (delete 'bootstrap)
  56. (delete 'configure)
  57. (replace 'build build)
  58. (delete 'check)
  59. (replace 'install install)))
  60. (define* (texlive-build #:key inputs (phases %standard-phases)
  61. #:allow-other-keys #:rest args)
  62. "Build the given TeX Live package, applying all of PHASES in order."
  63. (apply gnu:gnu-build #:inputs inputs #:phases phases args))
  64. ;;; texlive-build-system.scm ends here