texlive.scm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (guix scripts import texlive)
  19. #:use-module (guix ui)
  20. #:use-module (guix utils)
  21. #:use-module (guix scripts)
  22. #:use-module (guix import texlive)
  23. #:use-module (guix scripts import)
  24. #:use-module (srfi srfi-1)
  25. #:use-module (srfi srfi-11)
  26. #:use-module (srfi srfi-37)
  27. #:use-module (srfi srfi-41)
  28. #:use-module (ice-9 match)
  29. #:use-module (ice-9 format)
  30. #:export (guix-import-texlive))
  31. ;;;
  32. ;;; Command-line options.
  33. ;;;
  34. (define %default-options
  35. '())
  36. (define (show-help)
  37. (display (G_ "Usage: guix import texlive PACKAGE-NAME
  38. Import and convert the Texlive package for PACKAGE-NAME.\n"))
  39. (display (G_ "
  40. -a, --archive=ARCHIVE specify the archive repository"))
  41. (display (G_ "
  42. -h, --help display this help and exit"))
  43. (display (G_ "
  44. -V, --version display version information and exit"))
  45. (newline)
  46. (show-bug-report-information))
  47. (define %options
  48. ;; Specification of the command-line options.
  49. (cons* (option '(#\h "help") #f #f
  50. (lambda args
  51. (show-help)
  52. (exit 0)))
  53. (option '(#\V "version") #f #f
  54. (lambda args
  55. (show-version-and-exit "guix import texlive")))
  56. (option '(#\a "archive") #t #f
  57. (lambda (opt name arg result)
  58. (alist-cons 'component arg
  59. (alist-delete 'component result))))
  60. %standard-import-options))
  61. ;;;
  62. ;;; Entry point.
  63. ;;;
  64. (define (guix-import-texlive . args)
  65. (define (parse-options)
  66. ;; Return the alist of option values.
  67. (args-fold* args %options
  68. (lambda (opt name arg result)
  69. (leave (G_ "~A: unrecognized option~%") name))
  70. (lambda (arg result)
  71. (alist-cons 'argument arg result))
  72. %default-options))
  73. (let* ((opts (parse-options))
  74. (args (filter-map (match-lambda
  75. (('argument . value)
  76. value)
  77. (_ #f))
  78. (reverse opts))))
  79. (match args
  80. ((package-name)
  81. (let ((sexp (texlive->guix-package package-name
  82. (or (assoc-ref opts 'component)
  83. "latex"))))
  84. (unless sexp
  85. (leave (G_ "failed to download description for package '~a'~%")
  86. package-name))
  87. sexp))
  88. (()
  89. (leave (G_ "too few arguments~%")))
  90. ((many ...)
  91. (leave (G_ "too many arguments~%"))))))