aboutsummaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-01-05 22:31:34 +0100
committerLudovic Courtès <ludo@gnu.org>2015-03-23 22:28:49 +0100
commit0561e9ae16c2894d19432f1c6eb8e99ad508dc47 (patch)
tree180898a0367e9855312e89146b2821dabd0c26f5 /guix/scripts
parent87db65507e0385c139593ffb6749ffe1e85fa82b (diff)
downloadgnu-guix-0561e9ae16c2894d19432f1c6eb8e99ad508dc47.tar
gnu-guix-0561e9ae16c2894d19432f1c6eb8e99ad508dc47.tar.gz
substitute-binary: Allow callers to specify the size of a narinfo.
* guix/scripts/substitute-binary.scm (read-narinfo): Add #:size parameter and honor it.
Diffstat (limited to 'guix/scripts')
-rwxr-xr-xguix/scripts/substitute-binary.scm10
1 files changed, 7 insertions, 3 deletions
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm
index a4d153d4a0..85c2c74520 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -309,12 +309,16 @@ NARINFO, doesn't match HASH, a bytevector containing the hash of NARINFO."
(corrupt-signature
(leave (_ "signature on '~a' is corrupt~%") uri)))))
-(define* (read-narinfo port #:optional url)
+(define* (read-narinfo port #:optional url
+ #:key size)
"Read a narinfo from PORT. If URL is true, it must be a string used to
-build full URIs from relative URIs found while reading PORT.
+build full URIs from relative URIs found while reading PORT. When SIZE is
+true, read at most SIZE bytes from PORT; otherwise, read as much as possible.
No authentication and authorization checks are performed here!"
- (let ((str (utf8->string (get-bytevector-all port))))
+ (let ((str (utf8->string (if size
+ (get-bytevector-n port size)
+ (get-bytevector-all port)))))
(alist->record (call-with-input-string str fields->alist)
(narinfo-maker str url)
'("StorePath" "URL" "Compression"