import: Gracefully report import failures.
Previously, something like 'guix import gnu which' would spit out a backtrace if, say, the 'which' tarball could not be authenticated. * guix/upstream.scm (download-tarball): Mention failure modes in docstring. * guix/import/gnu.scm (gnu-package->sexp): Return #f when 'download-tarball' returns #f. * guix/scripts/import.scm (guix-import): Call 'leave' when IMPORTER does not return a (package ...) sexp.
This commit is contained in:
parent
787afdd0f1
commit
149590380a
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -55,8 +55,8 @@
|
||||||
(define* (gnu-package->sexp package release
|
(define* (gnu-package->sexp package release
|
||||||
#:key (key-download 'interactive))
|
#:key (key-download 'interactive))
|
||||||
"Return the 'package' sexp for the RELEASE (a <gnu-release>) of PACKAGE (a
|
"Return the 'package' sexp for the RELEASE (a <gnu-release>) of PACKAGE (a
|
||||||
<gnu-package>). Use KEY-DOWNLOAD as the OpenPGP key download policy (see
|
<gnu-package>), or #f upon failure. Use KEY-DOWNLOAD as the OpenPGP key
|
||||||
'download-tarball' for details.)"
|
download policy (see 'download-tarball' for details.)"
|
||||||
(define name
|
(define name
|
||||||
(gnu-package-name package))
|
(gnu-package-name package))
|
||||||
|
|
||||||
|
@ -79,25 +79,29 @@
|
||||||
(find (cute string-suffix? (string-append archive-type ".sig") <>)
|
(find (cute string-suffix? (string-append archive-type ".sig") <>)
|
||||||
(upstream-source-signature-urls release)))
|
(upstream-source-signature-urls release)))
|
||||||
|
|
||||||
(let ((tarball (with-store store
|
(with-store store
|
||||||
(download-tarball store url sig-url
|
(match (download-tarball store url sig-url
|
||||||
#:key-download key-download))))
|
#:key-download key-download)
|
||||||
`(package
|
((? string? tarball)
|
||||||
(name ,name)
|
`(package
|
||||||
(version ,(upstream-source-version release))
|
(name ,name)
|
||||||
(source (origin
|
(version ,(upstream-source-version release))
|
||||||
(method url-fetch)
|
(source (origin
|
||||||
(uri (string-append ,url-base version
|
(method url-fetch)
|
||||||
,(string-append ".tar." archive-type)))
|
(uri (string-append ,url-base version
|
||||||
(sha256
|
,(string-append ".tar." archive-type)))
|
||||||
(base32
|
(sha256
|
||||||
,(bytevector->nix-base32-string (file-sha256 tarball))))))
|
(base32
|
||||||
(build-system gnu-build-system)
|
,(bytevector->nix-base32-string
|
||||||
(synopsis ,(gnu-package-doc-summary package))
|
(file-sha256 tarball))))))
|
||||||
(description ,(gnu-package-doc-description package))
|
(build-system gnu-build-system)
|
||||||
(home-page ,(match (gnu-package-doc-urls package)
|
(synopsis ,(gnu-package-doc-summary package))
|
||||||
((head . tail) (qualified-url head))))
|
(description ,(gnu-package-doc-description package))
|
||||||
(license find-by-yourself!))))
|
(home-page ,(match (gnu-package-doc-urls package)
|
||||||
|
((head . tail) (qualified-url head))))
|
||||||
|
(license find-by-yourself!)))
|
||||||
|
(#f ;failure to download or authenticate the tarball
|
||||||
|
#f))))
|
||||||
|
|
||||||
(define* (gnu->guix-package name
|
(define* (gnu->guix-package name
|
||||||
#:key (key-download 'interactive))
|
#:key (key-download 'interactive))
|
||||||
|
|
|
@ -107,6 +107,10 @@ Run IMPORTER with ARGS.\n"))
|
||||||
(show-version-and-exit "guix import"))
|
(show-version-and-exit "guix import"))
|
||||||
((importer args ...)
|
((importer args ...)
|
||||||
(if (member importer importers)
|
(if (member importer importers)
|
||||||
(let ((expr (apply (resolve-importer importer) args)))
|
(match (apply (resolve-importer importer) args)
|
||||||
(pretty-print expr (newline-rewriting-port (current-output-port))))
|
((and expr ('package _ ...))
|
||||||
|
(pretty-print expr (newline-rewriting-port
|
||||||
|
(current-output-port))))
|
||||||
|
(x
|
||||||
|
(leave (_ "'~a' import failed~%") importer)))
|
||||||
(leave (_ "~a: invalid importer~%") importer)))))
|
(leave (_ "~a: invalid importer~%") importer)))))
|
||||||
|
|
|
@ -143,8 +143,9 @@ no update is needed or known."
|
||||||
#:key (key-download 'interactive))
|
#:key (key-download 'interactive))
|
||||||
"Download the tarball at URL to the store; check its OpenPGP signature at
|
"Download the tarball at URL to the store; check its OpenPGP signature at
|
||||||
SIGNATURE-URL, unless SIGNATURE-URL is false. On success, return the tarball
|
SIGNATURE-URL, unless SIGNATURE-URL is false. On success, return the tarball
|
||||||
file name. KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys;
|
file name; return #f on failure (network failure or authentication failure).
|
||||||
allowed values: 'interactive' (default), 'always', and 'never'."
|
KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed
|
||||||
|
values: 'interactive' (default), 'always', and 'never'."
|
||||||
(let ((tarball (download-to-store store url)))
|
(let ((tarball (download-to-store store url)))
|
||||||
(if (not signature-url)
|
(if (not signature-url)
|
||||||
tarball
|
tarball
|
||||||
|
|
Loading…
Reference in New Issue