From 33033a620e64d64bc549b4472e2f4db61e801d18 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 20 Jan 2018 23:17:23 +0100 Subject: services: shepherd: Make 'shepherd-configuration-file' non-monadic. Suggested by atw on #guix. * gnu/services/shepherd.scm (shepherd-service-file): Use 'scheme-file' instead of 'gexp->file'. (shepherd-configuration-file): Likewise, and adjust to non-monadic style. (shepherd-boot-gexp): Adjust accordingly. * guix/scripts/system.scm (upgrade-shepherd-services): Use 'lower-object' in addition to 'shepherd-service-file'. --- guix/scripts/system.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 55a02fb96d..999ffb010b 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès +;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2016 Alex Kost ;;; Copyright © 2016, 2017 Chris Marusich ;;; Copyright © 2017 Mathieu Othacehe @@ -331,7 +331,9 @@ bring the system down." (let ((to-load-names (map shepherd-service-canonical-name to-load)) (to-start (filter shepherd-service-auto-start? to-load))) (info (G_ "loading new services:~{ ~a~}...~%") to-load-names) - (mlet %store-monad ((files (mapm %store-monad shepherd-service-file + (mlet %store-monad ((files (mapm %store-monad + (compose lower-object + shepherd-service-file) to-load))) ;; Here we assume that FILES are exactly those that were computed ;; as part of the derivation that built OS, which is normally the -- cgit v1.2.3 From 33988f9b5876e4b44cabe1997a91eb604931c1ca Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 22 Jan 2018 10:46:34 +0100 Subject: publish: Restore gzip compression in cache-less mode. Fixes . Regression introduced in 297e04d66010ada31a40f40143d81bf6b62affcc. Reported by Christopher Baines . * guix/scripts/publish.scm (nar-response-port): Add 'compression' parameter and honor it. (http-write): Get 'x-nar-compression' from the initial RESPONSE. --- guix/scripts/publish.scm | 16 +++++++++------- tests/publish.scm | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'guix') diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 1673fb9f33..b5dfdab32f 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -672,10 +672,10 @@ example: \"/foo/bar\" yields '(\"foo\" \"bar\")." exp ...) (const #f))) -(define (nar-response-port response) +(define (nar-response-port response compression) "Return a port on which to write the body of RESPONSE, the response of a /nar request, according to COMPRESSION." - (match (assoc-ref (response-headers response) 'x-nar-compression) + (match compression (($ 'gzip level) ;; Note: We cannot used chunked encoding here because ;; 'make-gzip-output-port' wants a file port. @@ -697,11 +697,13 @@ blocking." (call-with-new-thread (lambda () (set-thread-name "publish nar") - (let* ((response (write-response (sans-content-length response) - client)) - (port (begin - (force-output client) - (nar-response-port response)))) + (let* ((compression (assoc-ref (response-headers response) + 'x-nar-compression)) + (response (write-response (sans-content-length response) + client)) + (port (begin + (force-output client) + (nar-response-port response compression)))) ;; XXX: Given our ugly workaround for in ;; 'render-nar', BODY here is just the file name of the store item. ;; We call 'write-file' from here because we know that's the only diff --git a/tests/publish.scm b/tests/publish.scm index bd1a75cf00..8c88a8c93d 100644 --- a/tests/publish.scm +++ b/tests/publish.scm @@ -111,6 +111,10 @@ (sleep 1) (loop (- i 1)))))) +(define %gzip-magic-bytes + ;; Magic bytes of gzip file. + #vu8(#x1f #x8b)) + ;; Wait until the two servers are ready. (wait-until-ready 6789) @@ -213,6 +217,18 @@ FileSize: ~a~%" (cut restore-file <> temp))) (call-with-input-file temp read-string)))) +(unless (zlib-available?) + (test-skip 1)) +(test-equal "/nar/gzip/* is really gzip" + %gzip-magic-bytes + ;; Since 'gzdopen' (aka. 'call-with-gzip-input-port') transparently reads + ;; uncompressed gzip, the test above doesn't check whether it's actually + ;; gzip. This is what this test does. See . + (let ((nar (http-get-port + (publish-uri + (string-append "/nar/gzip/" (basename %item)))))) + (get-bytevector-n nar (bytevector-length %gzip-magic-bytes)))) + (unless (zlib-available?) (test-skip 1)) (test-equal "/*.narinfo with compression" -- cgit v1.2.3