summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-09-25 22:34:16 +0200
committerLudovic Courtès <ludo@gnu.org>2015-09-25 22:35:35 +0200
commit62d2b5715703e244c4877cfdaf8fc150df2192c3 (patch)
tree83f38e8b415a40fdd9dc8ec871d9c0143660c882 /guix
parent1f321f87631c35614e668d518b474319bf854a01 (diff)
utils: Add #:options parameter for compression output ports.
* guix/utils.scm (compressed-output-port, call-with-compressed-output-port): Add #:options parameter and honor it.
Diffstat (limited to 'guix')
-rw-r--r--guix/utils.scm21
1 files changed, 13 insertions, 8 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index 44913c6159..1fe11f52f5 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -283,22 +283,27 @@ data is lost."
(close-port in)
(values out (list child)))))))
-(define (compressed-output-port compression output)
+(define* (compressed-output-port compression output
+ #:key (options '()))
"Return an output port whose input is compressed according to COMPRESSION,
a symbol such as 'xz, and then written to OUTPUT. In addition return a list
-of PIDs to wait for."
+of PIDs to wait for. OPTIONS is a list of strings passed to the compression
+program--e.g., '(\"--fast\")."
(match compression
((or #f 'none) (values output '()))
- ('bzip2 (filtered-output-port `(,%bzip2 "-c") output))
- ('xz (filtered-output-port `(,%xz "-c") output))
- ('gzip (filtered-output-port `(,%gzip "-c") output))
+ ('bzip2 (filtered-output-port `(,%bzip2 "-c" ,@options) output))
+ ('xz (filtered-output-port `(,%xz "-c" ,@options) output))
+ ('gzip (filtered-output-port `(,%gzip "-c" ,@options) output))
(else (error "unsupported compression scheme" compression))))
-(define (call-with-compressed-output-port compression port proc)
+(define* (call-with-compressed-output-port compression port proc
+ #:key (options '()))
"Call PROC with a wrapper around PORT, a file port, that compresses data
-that goes to PORT according to COMPRESSION, a symbol such as 'xz."
+that goes to PORT according to COMPRESSION, a symbol such as 'xz. OPTIONS is
+a list of command-line arguments passed to the compression program."
(let-values (((compressed pids)
- (compressed-output-port compression port)))
+ (compressed-output-port compression port
+ #:options options)))
(dynamic-wind
(const #f)
(lambda ()