texlive-build-system.scm 2.7 KB

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