From: Attila Lendvai <attila@lendvai.name>
To: 55242@debbugs.gnu.org
Cc: Attila Lendvai <attila@lendvai.name>
Subject: [bug#55242] [PATCH 10/10] guix: import: go: Better handling of /v2 in the module path.
Date: Tue, 3 May 2022 13:43:01 +0200 [thread overview]
Message-ID: <20220503114301.9524-10-attila@lendvai.name> (raw)
In-Reply-To: <20220503114301.9524-2-attila@lendvai.name>
* guix/import/go.scm (module-path->repository-root): Delete version param.
(*module-path->import-path*): New mapping, initialized with a small db of
projects.
(go-module->guix-package): Return packages with #:unpack-path when needed.
---
guix/import/go.scm | 93 +++++++++++++++++++++++++++-------------------
1 file changed, 54 insertions(+), 39 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index 25d424c1ac..fbed3ca88b 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -75,6 +75,7 @@ (define-module (guix import go)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
+ #:use-module (srfi srfi-71) ; let*
#:use-module (sxml match)
#:use-module ((sxml xpath) #:renamer (lambda (s)
(if (eq? 'filter s)
@@ -608,19 +609,15 @@ (define (vcs-qualified-module-path->root-repo-url module-path)
(vcs-qualified-module-path->root-repo-url module-path)
module-path))
-(define* (go-module->guix-package-name module-path #:optional version)
- "Converts a module's path to the canonical Guix format for Go packages.
-Optionally include a VERSION string to append to the name."
+(define* (go-module->guix-package-name module-path)
+ "Converts a module's path to the canonical Guix format for Go packages."
;; Map dot, slash, underscore and tilde characters to hyphens.
(let ((module-path* (string-map (lambda (c)
(if (member c '(#\. #\/ #\_ #\~))
#\-
c))
module-path)))
- (string-downcase (string-append "go-" module-path*
- (if version
- (string-append "-" version)
- "")))))
+ (string-downcase (string-append "go-" module-path*))))
(define (strip-.git-suffix/maybe repo-url)
"Strip a repository URL '.git' suffix from REPO-URL if hosted at GitHub."
@@ -771,6 +768,14 @@ (define (validate-version version available-versions module-path)
available versions:~{ ~a~}.")
(map strip-v-prefix
available-versions)))))))))
+(define *module-path->import-path*
+ ;; There's no other way to derive this information, at least that I know of.
+ '(("github.com/google/go-cmp" . "github.com/google/go-cmp/cmp")
+ ("github.com/sergi/go-diff" . "github.com/sergi/go-diff/diffmatchpatch")
+ ("github.com/davecgh/go-spew" . "github.com/davecgh/go-spew/spew")
+ ("github.com/beorn7/perks" . "github.com/beorn7/perks/quantile")
+ ("github.com/census-instrumentation/opencensus-proto" .
+ "github.com/census-instrumentation/opencensus-proto/gen-go")))
(define* (go-module->guix-package module-path #:key
(goproxy "https://proxy.golang.org")
@@ -864,38 +869,48 @@ (define* (go-module->guix-package module-path #:key
major-version: ~S"
meta-data raw-subdir module-subdirectory major-version)
(log.debug " dependencies:~%~S" dependencies+versions)
- (values
- `(package
- (name ,guix-name)
- (version ,(strip-v-prefix version*))
- (source
- ,(vcs->origin vcs-type vcs-repo-url vcs-tag))
- (build-system go-build-system)
- (arguments
- '(#:tests? #false ; some packages have unrecorded dependencies needed only by their tests
- #:import-path ,module-path
- ,@(if module-subdirectory
- `(#:unpack-path ,module-root-path)
- '())))
- ,@(maybe-propagated-inputs
- (map (match-lambda
- ((name version)
- (go-module->guix-package-name name (strip-v-prefix version)))
- (name
- (go-module->guix-package-name name)))
- dependencies))
- (home-page ,(format #f "https://~a" module-root-path))
- (synopsis ,synopsis)
- (description ,(and=> description beautify-description))
- (license ,(match (list->licenses licenses)
- (() #f) ;unknown license
- ((license) ;a single license
- license)
- ((license ...) ;a list of licenses
- `(list ,@license)))))
- (if pin-versions?
- dependencies+versions
- dependencies))))
+ (let* ((import-path unpack-path
+ (if module-subdirectory
+ (values module-path module-root-path)
+ (let ((import-path (assoc-ref *module-path->import-path*
+ module-path)))
+ (if import-path
+ (begin
+ (log.debug "matched as an import-path exception: ~S" import-path)
+ (values import-path module-path))
+ (values module-path #f))))))
+ (values
+ `(package
+ (name ,guix-name)
+ (version ,(strip-v-prefix version*))
+ (source
+ ,(vcs->origin vcs-type vcs-repo-url vcs-tag))
+ (build-system go-build-system)
+ (arguments
+ '(#:import-path ,import-path
+ ,@(if unpack-path
+ `(#:unpack-path ,unpack-path)
+ '())))
+ ,@(maybe-propagated-inputs
+ (map (match-lambda
+ ((name version)
+ (list (go-module->guix-package-name name)
+ (strip-v-prefix version)))
+ (name
+ (go-module->guix-package-name name)))
+ dependencies))
+ (home-page ,(format #f "https://~a" module-root-path))
+ (synopsis ,synopsis)
+ (description ,(and=> description beautify-description))
+ (license ,(match (list->licenses licenses)
+ (() #f) ;unknown license
+ ((license) ;a single license
+ license)
+ ((license ...) ;a list of licenses
+ `(list ,@license)))))
+ (if pin-versions?
+ dependencies+versions
+ dependencies)))))
(define (go-module->guix-package* . args)
;; Disable output buffering so that the following warning gets printed
--
2.35.1
next prev parent reply other threads:[~2022-05-03 11:46 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-03 11:16 [bug#55242] [PATCH 01/10] guix: import: Print the number of packages at the end Attila Lendvai
2022-05-03 11:42 ` [bug#55242] [PATCH 02/10] guix: import: go: Rename go.pkg.dev-info to pkg.go.dev-info Attila Lendvai
2022-05-03 11:42 ` [bug#55242] [PATCH 03/10] guix: import: go: Add mockup logging facility Attila Lendvai
2022-05-03 16:23 ` Maxime Devos
2022-06-14 19:46 ` [bug#55242] [PATCH 01/10] guix: import: Print the number of packages at the end Maxim Cournoyer
2022-05-03 11:42 ` [bug#55242] [PATCH 04/10] guix: import: go: Fix the interpretation of the replace directive Attila Lendvai
2022-05-03 16:25 ` Maxime Devos
2022-05-03 16:26 ` Maxime Devos
2022-05-03 16:27 ` Maxime Devos
2022-05-03 16:28 ` Maxime Devos
2022-05-03 11:42 ` [bug#55242] [PATCH 05/10] guix: import: go: Harden sxml->texi conversion Attila Lendvai
2022-05-03 16:32 ` Maxime Devos
2022-05-03 11:42 ` [bug#55242] [PATCH 06/10] guix: import: go: Add a local duplicate of http-fetch Attila Lendvai
2022-05-03 11:42 ` [bug#55242] [PATCH 07/10] guix: import: go: More resilience wrt network errors; add logging Attila Lendvai
2022-05-03 16:12 ` Maxime Devos
2022-05-03 17:00 ` Attila Lendvai
2022-05-03 17:38 ` Maxime Devos
2022-05-09 12:34 ` Attila Lendvai
2022-05-09 17:45 ` Maxime Devos
2022-05-09 20:02 ` Attila Lendvai
2022-05-09 20:08 ` Maxime Devos
2022-05-03 16:17 ` Maxime Devos
2022-05-03 16:36 ` Maxime Devos
2022-05-03 16:37 ` Maxime Devos
2022-05-03 11:42 ` [bug#55242] [PATCH 08/10] guix: import: go: Modules in a subdir and prefixed tags Attila Lendvai
2022-05-03 16:42 ` Maxime Devos
2022-05-03 16:48 ` Maxime Devos
2022-05-03 16:50 ` Maxime Devos
2022-05-09 12:50 ` Attila Lendvai
2022-05-03 16:51 ` Maxime Devos
2022-05-03 16:53 ` Maxime Devos
2022-05-03 16:55 ` Maxime Devos
2022-05-03 16:56 ` Maxime Devos
2022-05-03 16:59 ` Maxime Devos
2022-05-03 17:00 ` Maxime Devos
2022-05-03 17:01 ` Maxime Devos
2022-05-03 11:43 ` [bug#55242] [PATCH 09/10] guix: import: go: module-name -> module-path to be consistent Attila Lendvai
2022-05-03 11:43 ` Attila Lendvai [this message]
2022-05-09 20:39 ` [bug#55242] [PATCH 10/10] guix: import: go: Better handling of /v2 in the module path Maxime Devos
2022-05-03 16:22 ` [bug#55242] [PATCH 02/10] guix: import: go: Rename go.pkg.dev-info to pkg.go.dev-info Maxime Devos
2022-05-03 16:21 ` [bug#55242] [PATCH 01/10] guix: import: Print the number of packages at the end Maxime Devos
2022-05-03 17:29 ` Maxime Devos
2022-05-09 12:37 ` Attila Lendvai
2022-05-14 7:09 ` Maxime Devos
2022-05-14 7:15 ` Maxime Devos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220503114301.9524-10-attila@lendvai.name \
--to=attila@lendvai.name \
--cc=55242@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.