From: "Ludovic Courtès" <ludo@gnu.org>
To: 45460@debbugs.gnu.org
Subject: [bug#45460] [PATCH 2/5] utils: Support zstd compression via Guile-zstd.
Date: Sun, 27 Dec 2020 15:38:06 +0100 [thread overview]
Message-ID: <20201227143809.18554-2-ludo@gnu.org> (raw)
In-Reply-To: <20201227143809.18554-1-ludo@gnu.org>
* 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.
---
guix/utils.scm | 12 +++++++++++-
tests/utils.scm | 6 ++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/guix/utils.scm b/guix/utils.scm
index e3c78959ed..09eee0ecfb 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -209,7 +209,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,
@@ -221,6 +227,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)
@@ -280,6 +288,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
diff --git a/tests/utils.scm b/tests/utils.scm
index c278b2a277..9bce446d98 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -228,8 +228,10 @@ skip these tests."
get-bytevector-all)))))
(for-each test-compression/decompression
- '(gzip xz lzip)
- (list (const #t) (const #t) (const #t)))
+ `(gzip xz lzip zstd)
+ (list (const #t) (const #t) (const #t)
+ (lambda ()
+ (resolve-module '(zstd) #t #f #:ensure #f))))
;; This is actually in (guix store).
(test-equal "store-path-package-name"
--
2.29.2
next prev parent reply other threads:[~2020-12-27 14:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-27 14:13 [bug#45460] [PATCH 0/5] Zstd support for 'guix publish' and 'guix substitute' Ludovic Courtès
2020-12-27 14:38 ` [bug#45460] [PATCH 1/5] utils: Remove 'compressed-output-port' Ludovic Courtès
2020-12-27 14:38 ` Ludovic Courtès [this message]
2020-12-27 14:38 ` [bug#45460] [PATCH 3/5] publish: Add support for zstd compression Ludovic Courtès
2020-12-28 9:17 ` Jonathan Brielmaier
2021-01-03 15:18 ` Ludovic Courtès
2020-12-27 14:38 ` [bug#45460] [PATCH 4/5] substitute: Add zstd support Ludovic Courtès
2020-12-27 14:38 ` [bug#45460] [PATCH 5/5] doc: Mention optional dependency on Guile-zstd Ludovic Courtès
2020-12-30 9:30 ` [bug#45460] [PATCH 0/5] Zstd support for 'guix publish' and 'guix substitute' Mathieu Othacehe
2021-01-03 15:17 ` Ludovic Courtès
2021-01-13 22:08 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201227143809.18554-2-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=45460@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.