import: Enable recursive import for texlive packages.

* guix/import/texlive.scm (tlpdb->package): Add VERSION argument; include
explicit version field in output.
(texlive->guix-package): Set default value for VERSION argument; adjust call
of tlpdb->package.
(texlive-recursive-import): Accept REPO and VERSION keyword arguments.
* guix/import/utils.scm (package->definition): Add a clause to deal with
output from tlpdb->package.
* guix/scripts/import/texlive.scm (%options): Add "recursive" option.
(guix-import-texlive): Honor "recursive" option.
* doc/guix.texi (Using TeX and LaTeX): Mention "recursive" option.
This commit is contained in:
Ricardo Wurmus 2022-07-19 23:44:11 +02:00
parent 22530b2645
commit be7b314f3f
No known key found for this signature in database
GPG key ID: 197A5888235FACAC
4 changed files with 46 additions and 11 deletions

View file

@ -40965,6 +40965,16 @@ package, you can try and import it (@pxref{Invoking guix import}):
guix import texlive @var{package} guix import texlive @var{package}
@end example @end example
Additional options include:
@table @code
@item --recursive
@itemx -r
Traverse the dependency graph of the given upstream package recursively
and generate package expressions for all those packages that are not yet
in Guix.
@end table
@quotation Note @quotation Note
@TeX{} Live packaging is still very much work in progress, but you can @TeX{} Live packaging is still very much work in progress, but you can
help! @xref{Contributing}, for more information. help! @xref{Contributing}, for more information.

View file

@ -246,7 +246,7 @@ (define name->parts (cut string-split <> #\/))
;; entries with the same prefix. ;; entries with the same prefix.
(lambda (x y) (every equal? x y))))) (lambda (x y) (every equal? x y)))))
(define (tlpdb->package name package-database) (define (tlpdb->package name version package-database)
(and-let* ((data (assoc-ref package-database name)) (and-let* ((data (assoc-ref package-database name))
(dirs (files->directories (dirs (files->directories
(map (lambda (dir) (map (lambda (dir)
@ -255,7 +255,9 @@ (define (tlpdb->package name package-database)
(or (assoc-ref data 'runfiles) (list)) (or (assoc-ref data 'runfiles) (list))
(or (assoc-ref data 'srcfiles) (list)))))) (or (assoc-ref data 'srcfiles) (list))))))
(name (guix-name name)) (name (guix-name name))
(version (number->string %texlive-revision)) ;; TODO: we're ignoring the VERSION argument because that
;; information is distributed across %texlive-tag and
;; %texlive-revision.
(ref (svn-multi-reference (ref (svn-multi-reference
(url (string-append "svn://www.tug.org/texlive/tags/" (url (string-append "svn://www.tug.org/texlive/tags/"
%texlive-tag "/Master/texmf-dist")) %texlive-tag "/Master/texmf-dist"))
@ -276,6 +278,9 @@ (define (tlpdb->package name package-database)
(force-output port) (force-output port)
(get-hash)))) (get-hash))))
,@(if (assoc-ref data 'srcfiles) '() '(#:trivial? #true)))) ,@(if (assoc-ref data 'srcfiles) '() '(#:trivial? #true))))
;; package->definition in (guix import utils) expects to see a
;; version field.
(version ,version)
,@(or (and=> (assoc-ref data 'depend) ,@(or (and=> (assoc-ref data 'depend)
(lambda (inputs) (lambda (inputs)
`((propagated-inputs `((propagated-inputs
@ -297,13 +302,18 @@ (define (tlpdb->package name package-database)
(define texlive->guix-package (define texlive->guix-package
(memoize (memoize
(lambda* (name #:key repo version (package-database tlpdb)) (lambda* (name #:key
repo
(version (number->string %texlive-revision))
(package-database tlpdb))
"Find the metadata for NAME in the tlpdb and return the `package' "Find the metadata for NAME in the tlpdb and return the `package'
s-expression corresponding to that package, or #f on failure." s-expression corresponding to that package, or #f on failure."
(tlpdb->package name (package-database))))) (tlpdb->package name version (package-database)))))
(define (texlive-recursive-import name) (define* (texlive-recursive-import name #:key repo version)
(recursive-import name (recursive-import name
#:repo repo
#:version version
#:repo->guix-package texlive->guix-package #:repo->guix-package texlive->guix-package
#:guix-name guix-name)) #:guix-name guix-name))

View file

@ -341,6 +341,8 @@ (define* (package->definition guix-package #:optional append-version?/string)
(match guix-package (match guix-package
((or ((or
('package ('name name) ('version version) . rest) ('package ('name name) ('version version) . rest)
('package ('inherit ('simple-texlive-package name . _))
('version version) . rest)
('let _ ('package ('name name) ('version version) . rest))) ('let _ ('package ('name name) ('version version) . rest)))
`(define-public ,(string->symbol `(define-public ,(string->symbol

View file

@ -22,11 +22,13 @@ (define-module (guix scripts import texlive)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix scripts) #:use-module (guix scripts)
#:use-module (guix import texlive) #:use-module (guix import texlive)
#:use-module (guix import utils)
#:use-module (guix scripts import) #:use-module (guix scripts import)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-11) #:use-module (srfi srfi-11)
#:use-module (srfi srfi-37) #:use-module (srfi srfi-37)
#:use-module (srfi srfi-41) #:use-module (srfi srfi-41)
#:use-module (srfi srfi-71)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:use-module (ice-9 format) #:use-module (ice-9 format)
#:export (guix-import-texlive)) #:export (guix-import-texlive))
@ -58,6 +60,9 @@ (define %options
(option '(#\V "version") #f #f (option '(#\V "version") #f #f
(lambda args (lambda args
(show-version-and-exit "guix import texlive"))) (show-version-and-exit "guix import texlive")))
(option '(#\r "recursive") #f #f
(lambda (opt name arg result)
(alist-cons 'recursive #t result)))
%standard-import-options)) %standard-import-options))
@ -78,12 +83,20 @@ (define (parse-options)
(_ #f)) (_ #f))
(reverse opts)))) (reverse opts))))
(match args (match args
((name) ((spec)
(let ((sexp (texlive->guix-package name))) (let ((name version (package-name->name+version spec)))
(if (assoc-ref opts 'recursive)
;; Recursive import
(with-error-handling
(map package->definition
(filter identity (texlive-recursive-import name
#:version version))))
;; Single import
(let ((sexp (texlive->guix-package name #:version version)))
(unless sexp (unless sexp
(leave (G_ "failed to import package '~a'~%") (leave (G_ "failed to download description for package '~a'~%")
name)) name))
sexp)) sexp))))
(() (()
(leave (G_ "too few arguments~%"))) (leave (G_ "too few arguments~%")))
((many ...) ((many ...)