texlive.scm 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017, 2021, 2022 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
  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 scripts import texlive)
  20. #:use-module (guix ui)
  21. #:use-module (guix utils)
  22. #:use-module (guix scripts)
  23. #:use-module (guix import texlive)
  24. #:use-module (guix scripts import)
  25. #:use-module (srfi srfi-1)
  26. #:use-module (srfi srfi-11)
  27. #:use-module (srfi srfi-37)
  28. #:use-module (srfi srfi-41)
  29. #:use-module (ice-9 match)
  30. #:use-module (ice-9 format)
  31. #:export (guix-import-texlive))
  32. ;;;
  33. ;;; Command-line options.
  34. ;;;
  35. (define %default-options
  36. '())
  37. (define (show-help)
  38. (display (G_ "Usage: guix import texlive PACKAGE-NAME
  39. Import and convert the Texlive package for PACKAGE-NAME.\n"))
  40. (display (G_ "
  41. -h, --help display this help and exit"))
  42. (display (G_ "
  43. -V, --version display version information and exit"))
  44. (newline)
  45. (show-bug-report-information))
  46. (define %options
  47. ;; Specification of the command-line options.
  48. (cons* (option '(#\h "help") #f #f
  49. (lambda args
  50. (show-help)
  51. (exit 0)))
  52. (option '(#\V "version") #f #f
  53. (lambda args
  54. (show-version-and-exit "guix import texlive")))
  55. %standard-import-options))
  56. ;;;
  57. ;;; Entry point.
  58. ;;;
  59. (define (guix-import-texlive . args)
  60. (define (parse-options)
  61. ;; Return the alist of option values.
  62. (parse-command-line args %options (list %default-options)
  63. #:build-options? #f))
  64. (let* ((opts (parse-options))
  65. (args (filter-map (match-lambda
  66. (('argument . value)
  67. value)
  68. (_ #f))
  69. (reverse opts))))
  70. (match args
  71. ((name)
  72. (let ((sexp (texlive->guix-package name)))
  73. (unless sexp
  74. (leave (G_ "failed to import package '~a'~%")
  75. name))
  76. sexp))
  77. (()
  78. (leave (G_ "too few arguments~%")))
  79. ((many ...)
  80. (leave (G_ "too many arguments~%"))))))