From: Stephen Paul Weber <singpolyma@singpolyma.net>
To: 52362@debbugs.gnu.org
Cc: Stephen Paul Weber <singpolyma@singpolyma.net>
Subject: bug#52362: [PATCH v3] guix: import: go: Use correct tag for go module in subdirectory.
Date: Sat, 15 Jan 2022 22:32:08 -0500 [thread overview]
Message-ID: <20220116033208.54370-1-singpolyma@singpolyma.net> (raw)
In-Reply-To: <Ya/bU8a43auuMRP0@singpolyma-beefy.lan>
https://go.dev/ref/mod says a module in a subdirectory has a tag prefixed with
the subdirectory.
* guix/import/go.scm (version+subdirectory->tag-prefix): New variable.
(vcs->origin): New argument module-path-subdirectory.
---
guix/import/go.scm | 36 +++++++++++++++++++++++++-----------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index d00c13475a..f2ea9dbbae 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -521,28 +521,37 @@ tag."
`(tag-or-commit . ,reference)))))
(file-hash* checkout #:algorithm algorithm #:recursive? #true)))
-(define (vcs->origin vcs-type vcs-repo-url version)
+(define (version+subdirectory->tag-prefix subdirectory)
+ (if (string=? subdirectory "")
+ ""
+ (string-append (substring subdirectory 1) "/")))
+
+(define (vcs->origin vcs-type vcs-repo-url module-path-subdirectory version)
"Generate the `origin' block of a package depending on what type of source
control system is being used."
(case vcs-type
((git)
- (let ((plain-version? (string=? version (go-version->git-ref version)))
- (v-prefixed? (string-prefix? "v" version)))
+ (let* ((plain-version? (string=? version (go-version->git-ref version)))
+ (v-prefixed? (string-prefix? "v" version))
+ (tag-prefix (version+subdirectory->tag-prefix
+ module-path-subdirectory))
+ (git-commit (if plain-version?
+ (string-append tag-prefix version)
+ (go-version->git-ref version))))
`(origin
(method git-fetch)
(uri (git-reference
(url ,vcs-repo-url)
- ;; This is done because the version field of the package,
- ;; which the generated quoted expression refers to, has been
- ;; stripped of any 'v' prefixed.
(commit ,(if (and plain-version? v-prefixed?)
- '(string-append "v" version)
+ (if (string=? module-path-subdirectory "")
+ '(string-append "v" version)
+ `(string-append ,tag-prefix "v" version))
'(go-version->git-ref version)))))
(file-name (git-file-name name version))
(sha256
(base32
,(bytevector->nix-base32-string
- (git-checkout-hash vcs-repo-url (go-version->git-ref version)
+ (git-checkout-hash vcs-repo-url git-commit
(hash-algorithm sha256))))))))
((hg)
`(origin
@@ -618,12 +627,17 @@ When VERSION is unspecified, the latest version available is used."
dependencies+versions
(map car dependencies+versions)))
(module-path-sans-suffix
- (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path)))
+ (if (string-prefix? "gopkg.in" module-path)
+ module-path
+ (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path))))
(guix-name (go-module->guix-package-name module-path))
- (root-module-path (module-path->repository-root module-path))
+ (root-module-path (module-path->repository-root module-path-sans-suffix))
;; The VCS type and URL are not included in goproxy information. For
;; this we need to fetch it from the official module page.
(meta-data (fetch-module-meta-data root-module-path))
+ (module-path-subdirectory
+ (substring module-path-sans-suffix
+ (string-length (module-meta-import-prefix meta-data))))
(vcs-type (module-meta-vcs meta-data))
(vcs-repo-url (module-meta-data-repo-url meta-data goproxy))
(synopsis (go-package-synopsis module-path))
@@ -634,7 +648,7 @@ When VERSION is unspecified, the latest version available is used."
(name ,guix-name)
(version ,(strip-v-prefix version*))
(source
- ,(vcs->origin vcs-type vcs-repo-url version*))
+ ,(vcs->origin vcs-type vcs-repo-url module-path-subdirectory version*))
(build-system go-build-system)
(arguments
'(#:import-path ,module-path
--
2.30.2
next prev parent reply other threads:[~2022-01-16 3:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 22:08 bug#52362: guix import go error Stephen Paul Weber
2022-01-12 3:58 ` Stephen Paul Weber
2022-01-12 4:28 ` Stephen Paul Weber
2022-01-15 1:43 ` bug#52362: [PATCH] guix: import: go: Use correct tag for go module in subdirectory Stephen Paul Weber
2022-01-15 1:56 ` Stephen Paul Weber
2022-01-16 2:56 ` bug#52362: [PATCH v2] " Stephen Paul Weber
2022-01-16 3:32 ` Stephen Paul Weber [this message]
2023-05-25 16:13 ` bug#52362: guix import go error Simon Tournier
2022-02-28 23:55 ` bug#52362: [PATCH v3] guix: import: go: Use correct tag for go module in subdirectory Nicolas Goaziou
2023-05-25 14:21 ` bug#52362: guix import go error Simon Tournier
2023-05-25 18:58 ` Nicolas Goaziou
2023-05-25 19:08 ` Simon Tournier
2022-04-13 14:26 ` bug#52362: another patchset Attila Lendvai
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220116033208.54370-1-singpolyma@singpolyma.net \
--to=singpolyma@singpolyma.net \
--cc=52362@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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).