[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
22/169: import/go: Add diagnostics.
From: |
guix-commits |
Subject: |
22/169: import/go: Add diagnostics. |
Date: |
Thu, 26 Sep 2024 09:25:33 -0400 (EDT) |
sharlatan pushed a commit to branch go-team
in repository guix.
commit d47965fc174bbb4081d29241d66c96592242216a
Author: Christina O'Donnell <cdo@mutix.org>
AuthorDate: Sat Mar 16 10:30:39 2024 +0000
import/go: Add diagnostics.
guix/import/go.scm (go-module-available-versions): Add warning when fetching
a list of versions from the proxy fails and raise exception when no version
can be found at all.
(module-path->repository-root): Warn when all attempts to find the
repository
root have failed.
(fetch-module-meta-data): Raise exception when no meta element could be
found.
(go-module->guix-package): Catch general exceptions and warn that the
package
could not be imported.
Change-Id: I6dcdccc71f54bfec7110f6bfc5aeb8855502d1e3
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
---
guix/import/go.scm | 58 +++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 46 insertions(+), 12 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index 34bccd6a0c..53ada83040 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -39,7 +39,9 @@
#:autoload (htmlprag) (html->sxml) ;from Guile-Lib
#:autoload (guix base32) (bytevector->nix-base32-string)
#:autoload (guix build utils) (mkdir-p)
+ #:autoload (guix ui) (warning)
#:autoload (gcrypt hash) (hash-algorithm sha256)
+ #:autoload (git structs) (git-error-message)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (ice-9 peg)
@@ -144,10 +146,15 @@ styles for the same package."
(versions (remove string-null? (string-split body #\newline))))
(if (null? versions)
(begin
+ (warning (G_ "Empty list of versions on proxy ~a for package '~a'.
Using latest.~%")
+ goproxy name)
;; If we haven't recieved any versions, look in the version-info json
;; object and return a one-element list if found.
(or (and=> (assoc-ref (go-module-version-info goproxy name)
"Version")
- list))))
+ list)
+ (raise (make-compound-condition
+ (formatted-message (G_ "No versions available for '~a'
on proxy ~a.")
+ name goproxy))))))
versions))
(define (go-package-licenses name)
@@ -471,7 +478,10 @@ hence the need to derive this information."
(+ 1 (string-length subdir)))
#f)))))
(vcs-qualified-module-path->root-repo-url module-path)
- module-path))
+ (begin
+ (warning (G_ "Unable to determine repository root of '~a'. Guessing
'~a'.~%")
+ module-path 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.
@@ -516,14 +526,19 @@ build a package."
(select (sxpath `(// (meta (@ (equal? (name "go-import"))))
// content))))
(match (select (html->sxml meta-data #:strict? #t))
- (() #f) ;nothing selected
+ (() (raise (make-compound-condition
+ (formatted-message (G_ "no <meta/> element in result when
accessing module path '~a' using go-get")
+ module-path))))
((('content content-text) ..1)
(or
(find (lambda (meta)
(string-prefix? (module-meta-import-prefix meta) module-path))
(map go-import->module-meta content-text))
;; Fallback to the first meta if no import prefixes match.
- (go-import->module-meta (first content-text)))))))
+ (go-import->module-meta (first content-text))
+ (raise (make-compound-condition
+ (formatted-message (G_ "unable to parse <meta/> when accessing
module path '~a' using go-get")
+ module-path))))))))
(define (module-meta-data-repo-url meta-data goproxy)
"Return the URL where the fetcher which will be used can download the
@@ -720,16 +735,35 @@ When VERSION is unspecified, the latest version available
is used."
;; consistently.
(setvbuf (current-error-port) 'none)
(let ((package-name (match args ((name _ ...) name))))
- (guard (c ((http-get-error? c)
- (warning (G_ "Failed to import package ~s.
+ (begin
+ (info (G_ "Importing package ~s...~%") package-name)
+ (guard (c ((http-get-error? c)
+ (warning (G_ "Failed to import package ~s.
reason: ~s could not be fetched: HTTP error ~a (~s).
This package and its dependencies won't be imported.~%")
- package-name
- (uri->string (http-get-error-uri c))
- (http-get-error-code c)
- (http-get-error-reason c))
- (values #f '())))
- (apply go-module->guix-package args)))))
+ package-name
+ (uri->string (http-get-error-uri c))
+ (http-get-error-code c)
+ (http-get-error-reason c))
+
+ (values #f '()))
+ ((formatted-message? c)
+ (warning (G_ "Failed to import package ~s.
+reason: ~a
+This package and its dependencies won't be imported.~%")
+ package-name
+ (apply format #f
+ (formatted-message-string c)
+ (formatted-message-arguments c)))
+ (values #f '()))
+ ((eq? (exception-kind c) 'git-error)
+ (warning (G_ "Failed to import package ~s.
+reason: ~a
+This package and its dependencies won't be imported.~%")
+ package-name
+ (git-error-message c))
+ (values #f '())))
+ (apply go-module->guix-package args))))))
(define* (go-module-recursive-import package-name
#:key (goproxy "https://proxy.golang.org")
- 49/169: gnu: Add go-golang-org-x-telemetry-config., (continued)
- 49/169: gnu: Add go-golang-org-x-telemetry-config., guix-commits, 2024/09/26
- 50/169: gnu: go-github-com-google-go-cmdtest: Update to 0.4.0., guix-commits, 2024/09/26
- 54/169: gnu: go-github-com-google-go-cmdtest: Move to golang-build., guix-commits, 2024/09/26
- 55/169: gnu: go-golang-org-x-vuln: Update to 1.1.3., guix-commits, 2024/09/26
- 56/169: gnu: go-golang-org-x-vuln: Move to golang-build., guix-commits, 2024/09/26
- 07/169: gnu: go-github-com-jaytaylor-html2text: Enable tests., guix-commits, 2024/09/26
- 14/169: gnu: Remove go-github-com-rylans-getlang., guix-commits, 2024/09/26
- 17/169: build-system/go: Allow providing additional test flags., guix-commits, 2024/09/26
- 31/169: gnu: go-golang-org-x-xerrors: Fix indentation., guix-commits, 2024/09/26
- 38/169: gnu: go-github-com-libp2p-go-msgio: Fix build., guix-commits, 2024/09/26
- 22/169: import/go: Add diagnostics.,
guix-commits <=
- 19/169: gnu: go-1.20: Build with gccgo-12 on some systems., guix-commits, 2024/09/26
- 42/169: gnu: go-github-com-prometheus-exporter-toolkit: Fix build., guix-commits, 2024/09/26
- 34/169: gnu: go-google-golang-org-protobuf: Enable all tests, guix-commits, 2024/09/26
- 16/169: import/go: Add comment about monorepo., guix-commits, 2024/09/26
- 30/169: gnu: go-golang-org-x-xerrors: Update to 0.0.0-20200804184101-5ec99f83aff1., guix-commits, 2024/09/26
- 26/169: gnu: go-golang-org-x-net: Update to 0.29.0., guix-commits, 2024/09/26
- 33/169: gnu: go-github-com-golang-protobuf: Update to 1.5.4., guix-commits, 2024/09/26
- 24/169: gnu: go-golang-org-x-image: Update to 0.20.0., guix-commits, 2024/09/26
- 45/169: gnu: go-github-com-libp2p-go-libp2p: Fix build., guix-commits, 2024/09/26
- 51/169: gnu: go-github-com-google-go-cmdtest: Fix indentation, guix-commits, 2024/09/26