summaryrefslogtreecommitdiff
path: root/guix/download.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-10-03 11:02:11 +0200
committerLudovic Courtès <ludo@gnu.org>2014-10-03 18:03:09 +0200
commit882383a9aa5fbeef6f29d359a786a6db7c9e03db (patch)
tree323b5cffbe95c01b070064f1c89f3f968ba95ba2 /guix/download.scm
parentb497a85be8490f0f91279119904fd76ae13cbea5 (diff)
downloadgnu-guix-882383a9aa5fbeef6f29d359a786a6db7c9e03db.tar
gnu-guix-882383a9aa5fbeef6f29d359a786a6db7c9e03db.tar.gz
download: Allow raw file names or file:// URLs.
* guix/download.scm (url-fetch): When URL is a string, if it's not a URI or if it's a URI with 'file' or #f scheme, use 'add-to-store'. * tests/builders.scm ("url-fetch, file", "url-fetch, file URI"): New tests.
Diffstat (limited to 'guix/download.scm')
-rw-r--r--guix/download.scm31
1 files changed, 18 insertions, 13 deletions
diff --git a/guix/download.scm b/guix/download.scm
index e956e08470..2d4bf74951 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -242,20 +242,25 @@ must be a list of symbol/URL-list pairs."
(url-fetch '#$url #$output
#:mirrors '#$mirrors)))
- (run-with-store store
- (gexp->derivation (or name file-name) builder
- #:system system
- #:hash-algo hash-algo
- #:hash hash
- #:modules '((guix build download)
- (guix build utils)
- (guix ftp-client))
- #:guile-for-build guile-for-build
+ (let ((uri (and (string? url) (string->uri url))))
+ (if (or (and (string? url) (not uri))
+ (and uri (memq (uri-scheme uri) '(#f file))))
+ (add-to-store store (or name file-name)
+ #f "sha256" (if uri (uri-path uri) url))
+ (run-with-store store
+ (gexp->derivation (or name file-name) builder
+ #:system system
+ #:hash-algo hash-algo
+ #:hash hash
+ #:modules '((guix build download)
+ (guix build utils)
+ (guix ftp-client))
+ #:guile-for-build guile-for-build
- ;; In general, offloading downloads is not a good idea.
- #:local-build? #t)
- #:guile-for-build guile-for-build
- #:system system))
+ ;; In general, offloading downloads is not a good idea.
+ #:local-build? #t)
+ #:guile-for-build guile-for-build
+ #:system system))))
(define* (download-to-store store url #:optional (name (basename url))
#:key (log (current-error-port)))