import: go: Emit new-style package inputs.

Since PACKAGE-NAMES->PACKAGE-INPUTS is used by both the go and crate
importers, give the crate importer a copy of the original so it
continues to use old-style inputs until it is updated.

* guix/import/utils.scm (package-names->package-inputs)[make-input]:
Return new-style package inputs.
(maybe-inputs): Wrap PACKAGE-INPUTS in 'list' instead of 'quasiquote'.
* guix/import/crate.scm (package-names->package-inputs): New variable.
* tests/go.scm ("go-module->guix-package"): Adjust to new-style package
inputs.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
Sarah Morgensen 2021-07-20 19:59:21 -07:00 committed by Ludovic Courtès
parent b8af6694b9
commit af85c38b01
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 23 additions and 8 deletions

View file

@ -142,6 +142,23 @@ (define (crate-version-dependencies version)
;;; Converting crates to Guix packages. ;;; Converting crates to Guix packages.
;;; ;;;
(define* (package-names->package-inputs names #:optional (output #f))
"Given a list of PACKAGE-NAMES or (PACKAGE-NAME VERSION) pairs, and an
optional OUTPUT, tries to generate a quoted list of inputs, as suitable to
use in an 'inputs' field of a package definition."
(define (make-input input version)
(cons* input (list 'unquote (string->symbol
(if version
(string-append input "-" version)
input)))
(or (and output (list output))
'())))
(map (match-lambda
((input version) (make-input input version))
(input (make-input input #f)))
names))
(define (maybe-cargo-inputs package-names) (define (maybe-cargo-inputs package-names)
(match (package-names->package-inputs package-names) (match (package-names->package-inputs package-names)
(() (()

View file

@ -418,12 +418,10 @@ (define* (package-names->package-inputs names #:optional (output #f))
optional OUTPUT, tries to generate a quoted list of inputs, as suitable to optional OUTPUT, tries to generate a quoted list of inputs, as suitable to
use in an 'inputs' field of a package definition." use in an 'inputs' field of a package definition."
(define (make-input input version) (define (make-input input version)
(cons* input (list 'unquote (string->symbol (let ((name (if version (string-append input "-" version) input)))
(if version (if output
(string-append input "-" version) (list (string->symbol name) output)
input))) (string->symbol name))))
(or (and output (list output))
'())))
(map (match-lambda (map (match-lambda
((input version) (make-input input version)) ((input version) (make-input input version))
@ -444,7 +442,7 @@ (define* (maybe-inputs package-names #:optional (output #f)
(() (()
'()) '())
((package-inputs ...) ((package-inputs ...)
`((,field-name (,'quasiquote ,package-inputs))))))) `((,field-name (list ,@package-inputs)))))))
(define* (maybe-native-inputs package-names #:optional (output #f)) (define* (maybe-native-inputs package-names #:optional (output #f))
"Same as MAYBE-INPUTS, but for native inputs." "Same as MAYBE-INPUTS, but for native inputs."

View file

@ -389,7 +389,7 @@ (define (mock-http-get testcase)
(arguments (arguments
(list #:import-path "github.com/go-check/check")) (list #:import-path "github.com/go-check/check"))
(propagated-inputs (propagated-inputs
`(("go-github-com-kr-pretty" ,go-github-com-kr-pretty))) (list go-github-com-kr-pretty))
(home-page "https://github.com/go-check/check") (home-page "https://github.com/go-check/check")
(synopsis "Instructions") (synopsis "Instructions")
(description "Package check is a rich testing extension for Go's testing \ (description "Package check is a rich testing extension for Go's testing \