guix: import: Report go version for go importer.
* guix/import/go.scm (go-package, go.mod-go-version): New procedures. (go-module->guix-package): Add the #:go keyword in the generated package definition if the required go is newer than the default go. * tests/go.scm (mock-http-get): Use gexps for package arguments. Change-Id: I8d005740a442330ac307a40a53764c803ceffc4fmaster
parent
e35dd13d8a
commit
6aade039e1
|
@ -29,6 +29,7 @@
|
||||||
#:use-module (guix git)
|
#:use-module (guix git)
|
||||||
#:use-module (guix hash)
|
#:use-module (guix hash)
|
||||||
#:use-module (guix i18n)
|
#:use-module (guix i18n)
|
||||||
|
#:use-module ((guix utils) #:select (version>?))
|
||||||
#:use-module (guix diagnostics)
|
#:use-module (guix diagnostics)
|
||||||
#:use-module (guix import utils)
|
#:use-module (guix import utils)
|
||||||
#:use-module (guix import json)
|
#:use-module (guix import json)
|
||||||
|
@ -93,6 +94,11 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(define (go-package)
|
||||||
|
"Return the 'go' package. This is a lazy reference so that we don't
|
||||||
|
depend on (gnu packages golang)."
|
||||||
|
(module-ref (resolve-interface '(gnu packages golang)) 'go))
|
||||||
|
|
||||||
(define http-fetch*
|
(define http-fetch*
|
||||||
;; Like http-fetch, but memoized and returning the body as a string.
|
;; Like http-fetch, but memoized and returning the body as a string.
|
||||||
(memoize (lambda args
|
(memoize (lambda args
|
||||||
|
@ -378,6 +384,17 @@ DIRECTIVE."
|
||||||
;; Prevent inlining of this procedure, which is accessed by unit tests.
|
;; Prevent inlining of this procedure, which is accessed by unit tests.
|
||||||
(set! go.mod-requirements go.mod-requirements)
|
(set! go.mod-requirements go.mod-requirements)
|
||||||
|
|
||||||
|
(define (go.mod-go-version go.mod)
|
||||||
|
"Return the minimum version of go required to specified by GO.MOD."
|
||||||
|
(let ((go-version (go.mod-directives go.mod 'go)))
|
||||||
|
(if (null? go-version)
|
||||||
|
;; If the go directive is missing, go 1.16 is assumed.
|
||||||
|
'(version "1.16")
|
||||||
|
(flatten go-version))))
|
||||||
|
|
||||||
|
;; Prevent inlining of this procedure, which is accessed by unit tests.
|
||||||
|
(set! go.mod-go-version go.mod-go-version)
|
||||||
|
|
||||||
(define-record-type <vcs>
|
(define-record-type <vcs>
|
||||||
(%make-vcs url-prefix root-regex type)
|
(%make-vcs url-prefix root-regex type)
|
||||||
vcs?
|
vcs?
|
||||||
|
@ -610,6 +627,7 @@ When VERSION is unspecified, the latest version available is used."
|
||||||
available-versions
|
available-versions
|
||||||
module-path))
|
module-path))
|
||||||
(content (fetch-go.mod goproxy module-path version*))
|
(content (fetch-go.mod goproxy module-path version*))
|
||||||
|
(min-go-version (second (go.mod-go-version (parse-go.mod content))))
|
||||||
(dependencies+versions (go.mod-requirements (parse-go.mod content)))
|
(dependencies+versions (go.mod-requirements (parse-go.mod content)))
|
||||||
(dependencies (if pin-versions?
|
(dependencies (if pin-versions?
|
||||||
dependencies+versions
|
dependencies+versions
|
||||||
|
@ -634,7 +652,10 @@ When VERSION is unspecified, the latest version available is used."
|
||||||
,(vcs->origin vcs-type vcs-repo-url version*))
|
,(vcs->origin vcs-type vcs-repo-url version*))
|
||||||
(build-system go-build-system)
|
(build-system go-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
'(#:import-path ,module-path
|
(list ,@(if (version>? min-go-version (package-version (go-package)))
|
||||||
|
`(#:go ,(string->number min-go-version))
|
||||||
|
'())
|
||||||
|
#:import-path ,module-path
|
||||||
,@(if (string=? module-path-sans-suffix root-module-path)
|
,@(if (string=? module-path-sans-suffix root-module-path)
|
||||||
'()
|
'()
|
||||||
`(#:unpack-path ,root-module-path))))
|
`(#:unpack-path ,root-module-path))))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2021 François Joulaud <francois.joulaud@radiofrance.com>
|
;;; Copyright © 2021 François Joulaud <francois.joulaud@radiofrance.com>
|
||||||
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
|
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -387,7 +387,7 @@ require github.com/kr/pretty v0.2.1
|
||||||
"0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"))))
|
"0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5"))))
|
||||||
(build-system go-build-system)
|
(build-system go-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
'(#: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)))
|
`(("go-github-com-kr-pretty" ,go-github-com-kr-pretty)))
|
||||||
(home-page "https://github.com/go-check/check")
|
(home-page "https://github.com/go-check/check")
|
||||||
|
|
Reference in New Issue