summaryrefslogtreecommitdiff
path: root/guix/scripts/download.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-04-26 16:43:08 +0200
committerLudovic Courtès <ludo@gnu.org>2013-04-26 16:43:08 +0200
commita9db7d10b6e4e86fb2b87a4161db3b1f202002fd (patch)
tree4a22481ab65447d8bc1cc307a76a884a7e7bbee9 /guix/scripts/download.scm
parente33d9d6f09874f83bb5a03f49cb969a84588e10e (diff)
parent2b6bdf7eb3c95716ac107ea6caea2e0b7077ae77 (diff)
Merge branch 'master' into core-updates
Conflicts: Makefile.am gnu/packages/autotools.scm gnu/packages/guile.scm gnu/packages/python.scm gnu/packages/shishi.scm guix/gnu-maintenance.scm guix/scripts/build.scm guix/scripts/gc.scm guix/scripts/package.scm guix/scripts/substitute-binary.scm guix/ui.scm nix/nix-daemon/guix-daemon.cc test-env.in tests/nar.scm tests/store.scm
Diffstat (limited to 'guix/scripts/download.scm')
-rw-r--r--guix/scripts/download.scm36
1 files changed, 11 insertions, 25 deletions
diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index 7c00312c74..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.
@@ -55,11 +40,14 @@ store path."
`((format . ,bytevector->nix-base32-string)))
(define (show-help)
- (display (_ "Usage: guix download [OPTION]... URL
+ (display (_ "Usage: guix download [OPTION] URL
Download the file at URL, add it to the store, and print its store path
-and the hash of its contents.\n"))
+and the hash of its contents.
+
+Supported formats: 'nix-base32' (default), 'base32', and 'base16'
+('hex' and 'hexadecimal' can be used as well).\n"))
(format #t (_ "
- -f, --format=FMT write the hash in the given format (default: `nix-base32')"))
+ -f, --format=FMT write the hash in the given format"))
(newline)
(display (_ "
-h, --help display this help and exit"))
@@ -114,20 +102,18 @@ and the hash of its contents.\n"))
(store (open-connection))
(arg (assq-ref opts 'argument))
(uri (or (string->uri arg)
- (leave (_ "guix-download: ~a: failed to parse URI~%")
+ (leave (_ "~a: failed to parse URI~%")
arg)))
(path (case (uri-scheme uri)
((file)
(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 (_ "guix-download: ~a: download failed~%")
+ (leave (_ "~a: download failed~%")
arg))
(compose sha256 get-bytevector-all)))
(fmt (assq-ref opts 'format)))