From 149590380adb240e0993931b4f72e6f285b24483 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 17 May 2016 13:41:07 +0200 Subject: 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. --- guix/import/gnu.scm | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'guix/import') diff --git a/guix/import/gnu.scm b/guix/import/gnu.scm index 834f0ae5cf..2cfb46beb9 100644 --- a/guix/import/gnu.scm +++ b/guix/import/gnu.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015 Ludovic Courtès +;;; Copyright © 2014, 2015, 2016 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -55,8 +55,8 @@ (define* (gnu-package->sexp package release #:key (key-download 'interactive)) "Return the 'package' sexp for the RELEASE (a ) of PACKAGE (a -). Use KEY-DOWNLOAD as the OpenPGP key download policy (see -'download-tarball' for details.)" +), or #f upon failure. Use KEY-DOWNLOAD as the OpenPGP key +download policy (see 'download-tarball' for details.)" (define name (gnu-package-name package)) @@ -79,25 +79,29 @@ (find (cute string-suffix? (string-append archive-type ".sig") <>) (upstream-source-signature-urls release))) - (let ((tarball (with-store store - (download-tarball store url sig-url - #:key-download key-download)))) - `(package - (name ,name) - (version ,(upstream-source-version release)) - (source (origin - (method url-fetch) - (uri (string-append ,url-base version - ,(string-append ".tar." archive-type))) - (sha256 - (base32 - ,(bytevector->nix-base32-string (file-sha256 tarball)))))) - (build-system gnu-build-system) - (synopsis ,(gnu-package-doc-summary package)) - (description ,(gnu-package-doc-description package)) - (home-page ,(match (gnu-package-doc-urls package) - ((head . tail) (qualified-url head)))) - (license find-by-yourself!)))) + (with-store store + (match (download-tarball store url sig-url + #:key-download key-download) + ((? string? tarball) + `(package + (name ,name) + (version ,(upstream-source-version release)) + (source (origin + (method url-fetch) + (uri (string-append ,url-base version + ,(string-append ".tar." archive-type))) + (sha256 + (base32 + ,(bytevector->nix-base32-string + (file-sha256 tarball)))))) + (build-system gnu-build-system) + (synopsis ,(gnu-package-doc-summary package)) + (description ,(gnu-package-doc-description package)) + (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 #:key (key-download 'interactive)) -- cgit v1.2.3