summaryrefslogtreecommitdiff
path: root/guix/import
diff options
context:
space:
mode:
authorFederico Beffa <beffa@fbengineering.ch>2017-02-09 17:05:41 +0100
committerFederico Beffa <beffa@fbengineering.ch>2017-02-09 19:36:08 +0100
commita4824c60ef5ffc0cae3771a16524287904a1c8bd (patch)
treeab531d77f9a247451d4b3ab21185663b70222a20 /guix/import
parentbc5844d14955c09330d47984d930e1e9aa8c0ee0 (diff)
downloadgnu-guix-a4824c60ef5ffc0cae3771a16524287904a1c8bd.tar
gnu-guix-a4824c60ef5ffc0cae3771a16524287904a1c8bd.tar.gz
import: hackage: Handle unknown packages gracefully.
* guix/import/hackage.scm (hackage-fetch): Add 'guard'.
Diffstat (limited to 'guix/import')
-rw-r--r--guix/import/hackage.scm16
1 files changed, 10 insertions, 6 deletions
diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 4d01ed23ea..2c9df073d3 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -21,6 +21,7 @@
(define-module (guix import hackage)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
+ #:use-module (srfi srfi-34)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-1)
@@ -115,12 +116,15 @@ version is returned."
"Return the Cabal file for the package NAME-VERSION, or #f on failure. If
the version part is omitted from the package name, then return the latest
version."
- (let-values (((name version) (package-name->name+version name-version)))
- (let* ((url (hackage-cabal-url name version))
- (port (http-fetch url))
- (result (read-cabal (canonical-newline-port port))))
- (close-port port)
- result)))
+ (guard (c ((and (http-get-error? c)
+ (= 404 (http-get-error-code c)))
+ #f)) ;"expected" if package is unknown
+ (let-values (((name version) (package-name->name+version name-version)))
+ (let* ((url (hackage-cabal-url name version))
+ (port (http-fetch url))
+ (result (read-cabal (canonical-newline-port port))))
+ (close-port port)
+ result))))
(define string->license
;; List of valid values from