123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- (define-module (guix scripts import cran)
- #:use-module (guix ui)
- #:use-module (guix utils)
- #:use-module (guix scripts)
- #:use-module (guix import cran)
- #:use-module (guix import utils)
- #:use-module (guix scripts import)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-37)
- #:use-module (srfi srfi-71)
- #:use-module (ice-9 match)
- #:use-module (ice-9 format)
- #:export (guix-import-cran))
- (define %default-options
- '())
- (define (show-help)
- (display (G_ "Usage: guix import cran PACKAGE-NAME
- Import and convert the CRAN package for PACKAGE-NAME.\n"))
- (display (G_ "
- -a, --archive=ARCHIVE specify the archive repository"))
- (display (G_ "
- -h, --help display this help and exit"))
- (display (G_ "
- -r, --recursive import packages recursively"))
- (display (G_ "
- -s, --style=STYLE choose output style, either specification or variable"))
- (display (G_ "
- -V, --version display version information and exit"))
- (newline)
- (show-bug-report-information))
- (define %options
-
- (cons* (option '(#\h "help") #f #f
- (lambda args
- (show-help)
- (exit 0)))
- (option '(#\V "version") #f #f
- (lambda args
- (show-version-and-exit "guix import cran")))
- (option '(#\a "archive") #t #f
- (lambda (opt name arg result)
- (alist-cons 'repo (string->symbol arg)
- (alist-delete 'repo result))))
- (option '(#\s "style") #t #f
- (lambda (opt name arg result)
- (alist-cons 'style (string->symbol arg)
- (alist-delete 'style result))))
- (option '(#\r "recursive") #f #f
- (lambda (opt name arg result)
- (alist-cons 'recursive #t result)))
- %standard-import-options))
- (define (guix-import-cran . args)
- (define (parse-options)
-
- (parse-command-line args %options (list %default-options)
- #:build-options? #f))
- (let* ((opts (parse-options))
- (args (filter-map (match-lambda
- (('argument . value)
- value)
- (_ #f))
- (reverse opts))))
- (parameterize ((%input-style (assoc-ref opts 'style)))
- (match args
- ((spec)
- (let ((name version (package-name->name+version spec)))
- (if (assoc-ref opts 'recursive)
-
- (with-error-handling
- (map package->definition
- (filter identity
- (cran-recursive-import name
- #:version version
- #:repo (or (assoc-ref opts 'repo) 'cran)))))
-
- (let ((sexp (cran->guix-package name
- #:version version
- #:repo (or (assoc-ref opts 'repo) 'cran))))
- (unless sexp
- (leave (G_ "failed to download description for package '~a'~%")
- name))
- sexp))))
- (()
- (leave (G_ "too few arguments~%")))
- ((many ...)
- (leave (G_ "too many arguments~%")))))))
|