diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-12-27 12:10:15 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-01-13 22:24:19 +0100 |
commit | d288a4de7df90bcd7288f779883279c1202fbe23 (patch) | |
tree | 61c801b64cd63ab6a4bce2e688da4eff5b1b7fb9 /tests | |
parent | db0cecdf6b2f2b8f9c5a3cebe8fc60e79a692be0 (diff) | |
download | guix-d288a4de7df90bcd7288f779883279c1202fbe23.tar.gz |
publish: Add support for zstd compression.
* guix/scripts/publish.scm (compress-nar)[write-compressed-file]: New procedure. Use it for 'gzip' and 'lzip'. Add 'zstd. (nar-response-port, string->compression-type): Add case for 'zstd'. * tests/publish.scm (zstd-supported?): New procedure. ("/nar/zstd/*"): New test. * doc/guix.texi (Invoking guix publish): Document zstd compression. (Base Services): Add cross-reference to the above node.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/publish.scm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/publish.scm b/tests/publish.scm index cafd0f13a2..52101876b5 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -38,6 +38,7 @@ #:use-module ((guix pki) #:select (%public-key-file %private-key-file)) #:use-module (zlib) #:use-module (lzlib) + #:autoload (zstd) (call-with-zstd-input-port) #:use-module (web uri) #:use-module (web client) #:use-module (web response) @@ -54,6 +55,9 @@ (define %store (open-connection-for-tests)) +(define (zstd-supported?) + (resolve-module '(zstd) #t #f #:ensure #f)) + (define %reference (add-text-to-store %store "ref" "foo")) (define %item (add-text-to-store %store "item" "bar" (list %reference))) @@ -237,6 +241,18 @@ References: ~%" (cut restore-file <> temp))) (call-with-input-file temp read-string)))) +(unless (zstd-supported?) (test-skip 1)) +(test-equal "/nar/zstd/*" + "bar" + (call-with-temporary-output-file + (lambda (temp port) + (let ((nar (http-get-port + (publish-uri + (string-append "/nar/zstd/" (basename %item)))))) + (call-with-zstd-input-port nar + (cut restore-file <> temp))) + (call-with-input-file temp read-string)))) + (test-equal "/*.narinfo with compression" `(("StorePath" . ,%item) ("URL" . ,(string-append "nar/gzip/" (basename %item))) |