Package: guix-patches;
Reported by: Christina O'Donnell <cdo <at> mutix.org>
Date: Sat, 16 Mar 2024 10:28:02 UTC
Severity: normal
Tags: patch
Done: Sharlatan Hellseher <sharlatanus <at> gmail.com>
Bug is archived. No further changes may be made.
Message #11 received at 69827 <at> debbugs.gnu.org (full text, mbox):
From: Christina O'Donnell <cdo <at> mutix.org> To: 69827 <at> debbugs.gnu.org Cc: Christina O'Donnell <cdo <at> mutix.org> Subject: [PATCH 3/3] import/go: Add diagnostics. Date: Sat, 16 Mar 2024 10:30:39 +0000
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 --- guix/import/go.scm | 56 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index 8276797d9a..5dd5b3d221 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -140,10 +140,15 @@ (define* (go-module-available-versions goproxy name) (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) @@ -467,7 +472,10 @@ (define (module-path->repository-root module-path version-info) (+ 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. @@ -512,14 +520,19 @@ (define (fetch-module-meta-data module-path) (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 @@ -716,16 +729,35 @@ (define go-module->guix-package* ;; 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 '())) + ((git-error? c) + (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") -- 2.41.0
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.