summaryrefslogtreecommitdiff
path: root/guix/scripts/import/egg.scm
diff options
context:
space:
mode:
authorXinglu Chen <public@yoctocell.xyz>2021-11-01 11:55:26 +0100
committerLudovic Courtès <ludo@gnu.org>2021-11-07 23:10:41 +0100
commitb999c80c2e71bd4b3f26a18a321b7e7e7b580103 (patch)
treee56d06ff022d3233066cb0a0516937998cf15bc8 /guix/scripts/import/egg.scm
parent2f665d4309053d5a9fe25bc93ee78d55dbc30cb7 (diff)
downloadguix-patches-b999c80c2e71bd4b3f26a18a321b7e7e7b580103.tar
guix-patches-b999c80c2e71bd4b3f26a18a321b7e7e7b580103.tar.gz
import: egg: Allow imports of a specific version.
* guix/import/egg.scm (eggs-repository): Change URL. (egg-metadata): Accept optional #:version keyword argument. (egg->guix-package): Accept ‘version’ argument. (egg-recursive-import): Add ‘version’ argument and honor it. * guix/scripts/import/egg.scm (guix-import-egg): Parse a specification instead of just a package name. * doc/guix.texi (Invoking guix import): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/scripts/import/egg.scm')
-rw-r--r--guix/scripts/import/egg.scm34
1 files changed, 19 insertions, 15 deletions
diff --git a/guix/scripts/import/egg.scm b/guix/scripts/import/egg.scm
index 829cdc2ca0..6a9657d12c 100644
--- a/guix/scripts/import/egg.scm
+++ b/guix/scripts/import/egg.scm
@@ -26,6 +26,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-37)
+ #:use-module (srfi srfi-71)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:export (guix-import-egg))
@@ -83,21 +84,24 @@ Import and convert the egg package for PACKAGE-NAME.\n"))
(_ #f))
(reverse opts))))
(match args
- ((package-name)
- (if (assoc-ref opts 'recursive)
- ;; Recursive import
- (map (match-lambda
- ((and ('package ('name name) . rest) pkg)
- `(define-public ,(string->symbol name)
- ,pkg))
- (_ #f))
- (egg-recursive-import package-name))
- ;; Single import
- (let ((sexp (egg->guix-package package-name)))
- (unless sexp
- (leave (G_ "failed to download meta-data for package '~a'~%")
- package-name))
- sexp)))
+ ((spec)
+ (let ((name version (package-name->name+version spec)))
+ (if (assoc-ref opts 'recursive)
+ ;; Recursive import
+ (map (match-lambda
+ ((and ('package ('name name) . rest) pkg)
+ `(define-public ,(string->symbol name)
+ ,pkg))
+ (_ #f))
+ (egg-recursive-import name version))
+ ;; Single import
+ (let ((sexp (egg->guix-package name version)))
+ (unless sexp
+ (leave (G_ "failed to download meta-data for package '~a'~%")
+ (if version
+ (string-append name "@" version)
+ name)))
+ sexp))))
(()
(leave (G_ "too few arguments~%")))
((many ...)