summaryrefslogtreecommitdiff
path: root/guix/scripts
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/scripts
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/scripts')
-rw-r--r--guix/scripts/download.scm23
1 files changed, 3 insertions, 20 deletions
diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index c8760454de..220211e6b8 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -21,30 +21,15 @@
#:use-module (guix store)
#:use-module (guix utils)
#:use-module (guix base32)
- #:use-module ((guix download) #:select (%mirrors))
- #:use-module (guix build download)
+ #:use-module (guix download)
#:use-module (web uri)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
- #:use-module (srfi srfi-11)
- #:use-module (srfi srfi-26)
#:use-module (srfi srfi-37)
#:use-module (rnrs bytevectors)
#:use-module (rnrs io ports)
#:export (guix-download))
-(define (fetch-and-store store fetch name)
- "Call FETCH for URI, and pass it the name of a file to write to; eventually,
-copy data from that port to STORE, under NAME. Return the resulting
-store path."
- (call-with-temporary-output-file
- (lambda (temp port)
- (let ((result
- (parameterize ((current-output-port (current-error-port)))
- (fetch temp))))
- (close port)
- (and result
- (add-to-store store name #f "sha256" temp))))))
;;;
;;; Command-line options.
@@ -124,10 +109,8 @@ Supported formats: 'nix-base32' (default), 'base32', and 'base16'
(add-to-store store (basename (uri-path uri))
#f "sha256" (uri-path uri)))
(else
- (fetch-and-store store
- (cut url-fetch arg <>
- #:mirrors %mirrors)
- (basename (uri-path uri))))))
+ (download-to-store store (uri->string uri)
+ (basename (uri-path uri))))))
(hash (call-with-input-file
(or path
(leave (_ "~a: download failed~%")