guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: import: Enable recursive import for texlive packa


From: guix-commits
Subject: branch master updated: import: Enable recursive import for texlive packages.
Date: Tue, 19 Jul 2022 17:56:00 -0400

This is an automated email from the git hooks/post-receive script.

rekado pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new be7b314f3f import: Enable recursive import for texlive packages.
be7b314f3f is described below

commit be7b314f3fe22273e935accac22f313e44d3d970
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Tue Jul 19 23:44:11 2022 +0200

    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.
---
 doc/guix.texi                   | 10 ++++++++++
 guix/import/texlive.scm         | 20 +++++++++++++++-----
 guix/import/utils.scm           |  2 ++
 guix/scripts/import/texlive.scm | 25 +++++++++++++++++++------
 4 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index d8a3d2e90c..3c5864ec1a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40965,6 +40965,16 @@ package, you can try and import it (@pxref{Invoking 
guix import}):
 guix import texlive @var{package}
 @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
 @TeX{} Live packaging is still very much work in progress, but you can
 help!  @xref{Contributing}, for more information.
diff --git a/guix/import/texlive.scm b/guix/import/texlive.scm
index c741555928..116bd1f66a 100644
--- a/guix/import/texlive.scm
+++ b/guix/import/texlive.scm
@@ -246,7 +246,7 @@ of those files are returned that are unexpectedly 
installed."
                           ;; entries with the same prefix.
                           (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))
              (dirs (files->directories
                     (map (lambda (dir)
@@ -255,7 +255,9 @@ of those files are returned that are unexpectedly 
installed."
                                  (or (assoc-ref data 'runfiles) (list))
                                  (or (assoc-ref data 'srcfiles) (list))))))
              (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
                    (url (string-append "svn://www.tug.org/texlive/tags/"
                                        %texlive-tag "/Master/texmf-dist"))
@@ -276,6 +278,9 @@ of those files are returned that are unexpectedly 
installed."
                        (force-output port)
                        (get-hash))))
                   ,@(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)
                      (lambda (inputs)
                        `((propagated-inputs
@@ -297,13 +302,18 @@ of those files are returned that are unexpectedly 
installed."
 
 (define texlive->guix-package
   (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'
 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
+                    #:repo repo
+                    #:version version
                     #:repo->guix-package texlive->guix-package
                     #:guix-name guix-name))
 
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 26eebfece5..668b8c8083 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -341,6 +341,8 @@ APPEND-VERSION?/string is a string, append this string."
   (match guix-package
     ((or
       ('package ('name name) ('version version) . rest)
+      ('package ('inherit ('simple-texlive-package name . _))
+                ('version version) . rest)
       ('let _ ('package ('name name) ('version version) . rest)))
 
      `(define-public ,(string->symbol
diff --git a/guix/scripts/import/texlive.scm b/guix/scripts/import/texlive.scm
index c5dcc07ea1..203386e31c 100644
--- a/guix/scripts/import/texlive.scm
+++ b/guix/scripts/import/texlive.scm
@@ -22,11 +22,13 @@
   #:use-module (guix utils)
   #:use-module (guix scripts)
   #:use-module (guix import texlive)
+  #:use-module (guix import utils)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-37)
   #:use-module (srfi srfi-41)
+  #:use-module (srfi srfi-71)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
   #:export (guix-import-texlive))
@@ -58,6 +60,9 @@ Import and convert the Texlive package for PACKAGE-NAME.\n"))
          (option '(#\V "version") #f #f
                  (lambda args
                    (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))
 
 
@@ -78,12 +83,20 @@ Import and convert the Texlive package for 
PACKAGE-NAME.\n"))
                             (_ #f))
                            (reverse opts))))
     (match args
-      ((name)
-       (let ((sexp (texlive->guix-package name)))
-         (unless sexp
-           (leave (G_ "failed to import package '~a'~%")
-                  name))
-         sexp))
+      ((spec)
+       (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
+                 (leave (G_ "failed to download description for package 
'~a'~%")
+                        name))
+               sexp))))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]