aboutsummaryrefslogtreecommitdiff
path: root/guix/download.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-04-21 22:40:23 +0200
committerLudovic Courtès <ludo@gnu.org>2013-04-21 22:40:40 +0200
commit861693f3e71fed8663a3ef9c336c3f3345e1e039 (patch)
tree5f798b6915114f4658bcbd764ada7a84e4fd6238 /guix/download.scm
parent6c365eca6dafca37f0ac34d55221bcf197df49a3 (diff)
downloadgnu-guix-861693f3e71fed8663a3ef9c336c3f3345e1e039.tar
gnu-guix-861693f3e71fed8663a3ef9c336c3f3345e1e039.tar.gz
Factorize `download-and-store'.
* guix/download.scm (download-to-store): New procedure. * guix/scripts/download.scm (fetch-and-store): Remove. (guix-download): Use `download-to-store' instead. * guix/ui.scm (call-with-temporary-output-file): Move to... * guix/utils.scm (call-with-temporary-output-file): ... here.
Diffstat (limited to 'guix/download.scm')
-rw-r--r--guix/download.scm19
1 files changed, 17 insertions, 2 deletions
diff --git a/guix/download.scm b/guix/download.scm
index ea00798b4b..b315b4c1d0 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -21,13 +21,15 @@
#:use-module (ice-9 match)
#:use-module (guix derivations)
#:use-module (guix packages)
- #:use-module ((guix store) #:select (derivation-path?))
+ #:use-module ((guix store) #:select (derivation-path? add-to-store))
+ #:use-module ((guix build download) #:renamer (symbol-prefix-proc 'build:))
#:use-module (guix utils)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:export (%mirrors
- url-fetch))
+ url-fetch
+ download-to-store))
;;; Commentary:
;;;
@@ -231,4 +233,17 @@ must be a list of symbol/URL-list pairs."
#:guile-for-build guile-for-build
#:env-vars env-vars)))
+(define* (download-to-store store url #:optional (name (basename url))
+ #:key (log (current-error-port)))
+ "Download from URL to STORE, either under NAME or URL's basename if
+omitted. Write progress reports to LOG."
+ (call-with-temporary-output-file
+ (lambda (temp port)
+ (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