unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#52362: guix import go error
@ 2021-12-07 22:08 Stephen Paul Weber
  2022-01-12  3:58 ` Stephen Paul Weber
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Stephen Paul Weber @ 2021-12-07 22:08 UTC (permalink / raw)
  To: 52362

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]

$ guix import go github.com/Azure/go-autorest/autorest

guix import: warning: Failed to import package "github.com/Azure/go-autorest/autorest".
reason: (#<<git-error> code: -3 message: "reference 'refs/tags/v0.11.22' not found" class: 4>).
guix import: error: failed to download meta-data for module 'github.com/Azure/go-autorest/autorest'.

Similarly:

$ guix import go github.com/Azure/go-autorest/autorest/adal

guix import: warning: Failed to import package "github.com/Azure/go-autorest/autorest/adal".
reason: (#<<git-error> code: -3 message: "reference 'refs/tags/v0.9.17' not found" class: 4>).
guix import: error: failed to download meta-data for module 'github.com/Azure/go-autorest/autorest/adal'.

And, from a different package but seems also similar:

$ guix import go cloud.google.com/go/storage

guix import: warning: Failed to import package "cloud.google.com/go/storage".
reason: (#<<git-error> code: -3 message: "reference 'refs/tags/v1.18.2' not found" class: 4>).
guix import: error: failed to download meta-data for module 'cloud.google.com/go/storage'.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52362: guix import go error
  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
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Stephen Paul Weber @ 2022-01-12  3:58 UTC (permalink / raw)
  To: 52362

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

Ran into another like this today:

     guix import go github.com/aws/aws-sdk-go-v2/service/s3

Gives:

Backtrace:
           14 (primitive-load "/gnu/store/6rjb4c80l53n98cl6h0s3q1zmkg…")
In guix/ui.scm:
    2209:7 13 (run-guix . _)
   2172:10 12 (run-guix-command _ . _)
In guix/scripts/import.scm:
    124:11 11 (guix-import . _)
In ice-9/boot-9.scm:
   1752:10 10 (with-exception-handler _ _ #:unwind? _ # _)
In guix/scripts/import/go.scm:
    116:29  9 (_)
In ice-9/exceptions.scm:
    406:15  8 (go-module->guix-package* . _)
In ice-9/boot-9.scm:
   1752:10  7 (with-exception-handler _ _ #:unwind? _ # _)
In guix/import/go.scm:
    519:18  6 (go-module->guix-package "github.com/aws/aws-sdk-go-v2…" …)
In guix/git.scm:
     277:4  5 (update-cached-checkout _ #:ref _ #:recursive? _ # _ # _ …)
    266:18  4 (resolve _)
In git/reference.scm:
      60:8  3 (_ _ _)
In git/bindings.scm:
      77:2  2 (raise-git-error _)
In ice-9/boot-9.scm:
   1685:16  1 (raise-exception _ #:continuable? _)
   1683:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1683:16: In procedure raise-exception:
Git error: reference 'refs/tags/v1.23.0' not found

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52362: guix import go error
  2022-01-12  3:58 ` Stephen Paul Weber
@ 2022-01-12  4:28   ` Stephen Paul Weber
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Paul Weber @ 2022-01-12  4:28 UTC (permalink / raw)
  To: 52362

[-- Attachment #1: Type: text/plain, Size: 793 bytes --]

Alright, I think I have found the issue.  https://go.dev/ref/mod says:

> If a module is defined in a subdirectory within the repository, that is,
> the module subdirectory portion of the module path is not empty, then each
> tag name must be prefixed with the module subdirectory, followed by a slash.
> For example, the module golang.org/x/tools/gopls is defined in the gopls
> subdirectory of the repository with root path golang.org/x/tools. The version
> v0.4.0 of that module must have the tag named gopls/v0.4.0 in that repository.

Right now the importer code assumes that either we have a pseudo version (and
thus can extract a raw commit hash) or else that the tag will be exactly
(string-append "v" version) but this does not take into account the rule about
subdirectory packages.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52362: [PATCH] guix: import: go: Use correct tag for go module in subdirectory.
  2021-12-07 22:08 bug#52362: guix import go error Stephen Paul Weber
  2022-01-12  3:58 ` Stephen Paul Weber
@ 2022-01-15  1:43 ` 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 ` bug#52362: [PATCH v3] " Stephen Paul Weber
  3 siblings, 1 reply; 7+ messages in thread
From: Stephen Paul Weber @ 2022-01-15  1:43 UTC (permalink / raw)
  To: 52362; +Cc: Stephen Paul Weber

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-name): New variable.
(vcs->origin): New argument module-path-subdirectory.
---
 guix/import/go.scm | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index d00c13475a..6fae1994b8 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -521,28 +521,30 @@ 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-name version subdirectory)
+  (if (string=? subdirectory "")
+      version
+      (string-append (substring subdirectory 1) "/" version)))
+
+(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 ((git-commit (if (string=? version (go-version->git-ref version))
+                           (version+subdirectory->tag-name
+                              version module-path-subdirectory)
+                           (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)
-                             '(go-version->git-ref version)))))
+                (commit ,git-commit)))
           (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
@@ -621,6 +623,8 @@ When VERSION is unspecified, the latest version available is used."
           (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))
+         (module-path-subdirectory
+           (substring module-path (string-length root-module-path)))
          ;; 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))
@@ -634,7 +638,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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52362: [PATCH] guix: import: go: Use correct tag for go module in subdirectory.
  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
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Paul Weber @ 2022-01-15  1:56 UTC (permalink / raw)
  To: 52362

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]

Somebody claiming to be Stephen Paul Weber wrote:
>https://go.dev/ref/mod says a module in a subdirectory has a tag prefixed with
>the subdirectory.

Dang.  This patch as written causes import of guix import go
github.com/jackc/pgx/v4 to fail. The /v4 suffix in this case appears to refer to
a branch and not a subdirectory, but the syntax is identical?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52362: [PATCH v2] guix: import: go: Use correct tag for go module in subdirectory.
  2021-12-07 22:08 bug#52362: guix import go error Stephen Paul Weber
  2022-01-12  3:58 ` 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-16  2:56 ` Stephen Paul Weber
  2022-01-16  3:32 ` bug#52362: [PATCH v3] " Stephen Paul Weber
  3 siblings, 0 replies; 7+ messages in thread
From: Stephen Paul Weber @ 2022-01-16  2:56 UTC (permalink / raw)
  To: 52362; +Cc: Stephen Paul Weber

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 | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index d00c13475a..b6f8686c0d 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,9 +627,13 @@ 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))
+         (module-path-subdirectory
+           (substring module-path-sans-suffix (string-length root-module-path)))
          ;; 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))
@@ -634,7 +647,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




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#52362: [PATCH v3] guix: import: go: Use correct tag for go module in subdirectory.
  2021-12-07 22:08 bug#52362: guix import go error Stephen Paul Weber
                   ` (2 preceding siblings ...)
  2022-01-16  2:56 ` bug#52362: [PATCH v2] " Stephen Paul Weber
@ 2022-01-16  3:32 ` Stephen Paul Weber
  3 siblings, 0 replies; 7+ messages in thread
From: Stephen Paul Weber @ 2022-01-16  3:32 UTC (permalink / raw)
  To: 52362; +Cc: Stephen Paul Weber

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




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-16  3:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` bug#52362: [PATCH v3] " Stephen Paul Weber

Code repositories for project(s) associated with this 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).