summaryrefslogtreecommitdiff
path: root/guix/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-12-26 23:01:05 +0100
committerLudovic Courtès <ludo@gnu.org>2021-01-13 22:24:19 +0100
commitdb0cecdf6b2f2b8f9c5a3cebe8fc60e79a692be0 (patch)
tree80b9adeaf22272c6fdbb708d4c2ccd137dccb431 /guix/utils.scm
parent0d046587107a56467cf2027799ac79ce8c203ce0 (diff)
utils: Support zstd compression via Guile-zstd.
* guix/utils.scm (lzip-port): Return a single value. (zstd-port): New procedure. (decompressed-port, compressed-output-port): Add 'zstd' case. * tests/utils.scm (test-compression/decompression): Test 'zstd' when the (zstd) module is available.
Diffstat (limited to 'guix/utils.scm')
-rw-r--r--guix/utils.scm12
1 files changed, 11 insertions, 1 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index c321ad9943..f8b05e7e80 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -210,7 +210,13 @@ buffered data is lost."
"Return the lzip port produced by calling PROC (a symbol) on PORT and ARGS.
Raise an error if lzlib support is missing."
(let ((make-port (module-ref (resolve-interface '(lzlib)) proc)))
- (values (make-port port) '())))
+ (make-port port)))
+
+(define (zstd-port proc port . args)
+ "Return the zstd port produced by calling PROC (a symbol) on PORT and ARGS.
+Raise an error if zstd support is missing."
+ (let ((make-port (module-ref (resolve-interface '(zstd)) proc)))
+ (make-port port)))
(define (decompressed-port compression input)
"Return an input port where INPUT is decompressed according to COMPRESSION,
@@ -222,6 +228,8 @@ a symbol such as 'xz."
('gzip (filtered-port `(,%gzip "-dc") input))
('lzip (values (lzip-port 'make-lzip-input-port input)
'()))
+ ('zstd (values (zstd-port 'make-zstd-input-port input)
+ '()))
(_ (error "unsupported compression scheme" compression))))
(define (call-with-decompressed-port compression port proc)
@@ -281,6 +289,8 @@ program--e.g., '(\"--fast\")."
('gzip (filtered-output-port `(,%gzip "-c" ,@options) output))
('lzip (values (lzip-port 'make-lzip-output-port output)
'()))
+ ('zstd (values (zstd-port 'make-zstd-output-port output)
+ '()))
(_ (error "unsupported compression scheme" compression))))
(define* (call-with-compressed-output-port compression port proc