upstream: Gracefully handle archive type changes.

Previously, if the currently used archive type (e.g., "bz2") was
unavailable for the new version, 'guix refresh -u' would crash instead
of updating to the archive with the new type.

* guix/upstream.scm (package-update/url-fetch): When URL is #f, pick the
first of URLS; likewise for SIGNATURE-URL.
This commit is contained in:
Ludovic Courtès 2019-08-17 22:50:58 +02:00
parent 4496ea74aa
commit 0ea009db9d
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 8 additions and 1 deletions

View File

@ -362,6 +362,7 @@ SOURCE, an <upstream-source>."
(_
"gz")))
((url signature-url)
;; Try to find a URL that matches ARCHIVE-TYPE.
(find2 (lambda (url sig-url)
;; Some URIs lack a file extension, like
;; 'https://crates.io/???/0.1/download'. In that
@ -370,7 +371,13 @@ SOURCE, an <upstream-source>."
(string-suffix? archive-type url)))
urls
(or signature-urls (circular-list #f)))))
(let ((tarball (download-tarball store url signature-url
;; If none of URLS matches ARCHIVE-TYPE, then URL is #f; in that case,
;; pick up the first element of URLS.
(let ((tarball (download-tarball store
(or url (first urls))
(and (pair? signature-urls)
(or signature-url
(first signature-urls)))
#:key-download key-download)))
(values version tarball source))))))