From d288a4de7df90bcd7288f779883279c1202fbe23 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 27 Dec 2020 12:10:15 +0100 Subject: 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. --- tests/publish.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') 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))) -- cgit v1.2.3