summaryrefslogtreecommitdiff
path: root/guix/scripts/import/go.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-03-21 00:16:22 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-04-09 23:02:37 -0400
commit83f8b6d32c76c56e4bb58eeb5af1259028d7ee72 (patch)
tree64cd50f8c435d240bdbc704ce14c361dc6674293 /guix/scripts/import/go.scm
parenta8b927a562aad7e5f77d0e4db2d9cee3434446d2 (diff)
import: go: Append version to symbol name in the pinned version mode.
This allows importing packages with complicated version specific dependency chains without the package symbol names colliding. * doc/guix.texi (Invoking guix import): Document the --pin-versions option. Mention that a specific version can be imported. Remove the experimental warning. * guix/import/go.scm (go-module->guix-package-name)[version]: Add optional argument. Rewrite the character translation in terms of string-map. (go-module->guix-package): Conditionally use dependencies whose symbol include their version, based no the value of the PIN-VERSIONS? argument. * guix/import/utils.scm (package->definition): Add a new case where the full version string is appended to the package symbol. * guix/scripts/import.scm (guix-import): Correctly print forms starting with '(define-public [...]'. * guix/scripts/import/go.scm (guix-import-go): Conditionally include the version in the package symbols defined.
Diffstat (limited to 'guix/scripts/import/go.scm')
-rw-r--r--guix/scripts/import/go.scm17
1 files changed, 10 insertions, 7 deletions
diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index 33d2470ce1..04b07f80cc 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -22,9 +22,11 @@
#:use-module (guix utils)
#:use-module (guix scripts)
#:use-module (guix import go)
+ #:use-module (guix import utils)
#:use-module (guix scripts import)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
+ #:use-module (srfi srfi-26)
#:use-module (srfi srfi-37)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
@@ -94,7 +96,12 @@ that are not yet in Guix"))
(('argument . value)
value)
(_ #f))
- (reverse opts))))
+ (reverse opts)))
+ ;; Append the full version to the package symbol name when using
+ ;; pinned versions.
+ (package->definition* (if (assoc-ref opts 'pin-versions?)
+ (cut package->definition <> 'full)
+ package->definition)))
(match args
((spec) ;e.g., github.com/golang/protobuf@v1.3.1
(receive (name version)
@@ -106,18 +113,14 @@ that are not yet in Guix"))
(assoc-ref opts 'pin-versions?))))
(if (assoc-ref opts 'recursive)
;; Recursive import.
- (map (match-lambda
- ((and ('package ('name name) . rest) pkg)
- `(define-public ,(string->symbol name)
- ,pkg))
- (_ #f))
+ (map package->definition*
(apply go-module-recursive-import arguments))
;; Single import.
(let ((sexp (apply go-module->guix-package arguments)))
(unless sexp
(leave (G_ "failed to download meta-data for module '~a'~%")
module-name))
- sexp)))))
+ (package->definition* sexp))))))
(()
(leave (G_ "too few arguments~%")))
((many ...)