From 5d22261db3d5099d745b9e8c8484545e546b319e Mon Sep 17 00:00:00 2001 From: Taiju HIGASHI Date: Fri, 9 Sep 2022 22:47:36 +0900 Subject: import: gem: Support importing a specific version of a gem. * guix/import/gem.scm: (rubygems-fetch, gem->guix-package) (gem-recursive-import): Fix to fetch the specified version of the gem. * guix/scripts/import/gem.scm (show-help): Update the help message. (guix-import-gem): Modify so the version number to be passed to subsequent procedures. * tests/gem.scm: Add tests. * doc/guix.texi (Invoking guix import): Document. Signed-off-by: Christopher Baines --- guix/scripts/import/gem.scm | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'guix/scripts/import') diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm index 82deac16ad..7f1e73332b 100644 --- a/guix/scripts/import/gem.scm +++ b/guix/scripts/import/gem.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2021 Sarah Morgensen ;;; Copyright © 2021 Brice Waegeneire ;;; Copyright © 2021 Simon Tournier +;;; Copyright © 2022 Taiju HIGASHI ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (ice-9 format) + #:use-module (ice-9 receive) #:export (guix-import-gem)) @@ -42,8 +44,9 @@ '()) (define (show-help) - (display (G_ "Usage: guix import gem PACKAGE-NAME -Import and convert the RubyGems package for PACKAGE-NAME.\n")) + (display (G_ "Usage: guix import gem PACKAGE-NAME[@VERSION] Import and +convert the RubyGems package for PACKAGE-NAME. Optionally, a version can be +specified after the at-sign (@) character.\n")) (display (G_ " -h, --help display this help and exit")) (display (G_ " @@ -86,21 +89,23 @@ Import and convert the RubyGems package for PACKAGE-NAME.\n")) (_ #f)) (reverse opts)))) (match args - ((package-name) - (let ((code (if (assoc-ref opts 'recursive) - (map (match-lambda - ((and ('package ('name name) . rest) pkg) - `(define-public ,(string->symbol name) - ,pkg)) - (_ #f)) - (gem-recursive-import package-name 'rubygems)) - (let ((sexp (gem->guix-package package-name))) - (if sexp sexp #f))))) - (match code - ((or #f '(#f)) - (leave (G_ "failed to download meta-data for package '~a'~%") - package-name)) - (_ code)))) + ((spec) + (receive (package-name package-version) + (package-name->name+version spec) + (let ((code (if (assoc-ref opts 'recursive) + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (gem-recursive-import package-name package-version)) + (let ((sexp (gem->guix-package package-name #:version package-version))) + (if sexp sexp #f))))) + (match code + ((or #f '(#f)) + (leave (G_ "failed to download meta-data for package '~a'~%") + package-name)) + (_ code))))) (() (leave (G_ "too few arguments~%"))) ((many ...) -- cgit v1.2.3