Archived
1
0
Fork 0

download: Support 'file://' URLs.

* guix/download.scm (download-to-store): When URL has a 'file' scheme or
  no scheme, use 'add-to-store' directly.
This commit is contained in:
Ludovic Courtès 2013-10-12 16:39:10 +02:00
parent 39e9f95d05
commit d8907ac43f

View file

@ -24,6 +24,7 @@
#:use-module ((guix store) #:select (derivation-path? add-to-store)) #:use-module ((guix store) #:select (derivation-path? add-to-store))
#:use-module ((guix build download) #:renamer (symbol-prefix-proc 'build:)) #:use-module ((guix build download) #:renamer (symbol-prefix-proc 'build:))
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (web uri)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:export (%mirrors #:export (%mirrors
@ -244,13 +245,18 @@ must be a list of symbol/URL-list pairs."
#:key (log (current-error-port))) #:key (log (current-error-port)))
"Download from URL to STORE, either under NAME or URL's basename if "Download from URL to STORE, either under NAME or URL's basename if
omitted. Write progress reports to LOG." omitted. Write progress reports to LOG."
(call-with-temporary-output-file (define uri
(lambda (temp port) (string->uri url))
(let ((result
(parameterize ((current-output-port log)) (if (memq (uri-scheme uri) '(file #f))
(build:url-fetch url temp #:mirrors %mirrors)))) (add-to-store store name #f "sha256" (uri-path uri))
(close port) (call-with-temporary-output-file
(and result (lambda (temp port)
(add-to-store store name #f "sha256" temp)))))) (let ((result
(parameterize ((current-output-port log))
(build:url-fetch url temp #:mirrors %mirrors))))
(close port)
(and result
(add-to-store store name #f "sha256" temp)))))))
;;; download.scm ends here ;;; download.scm ends here