aboutsummaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-01-05 00:19:35 +0100
committerLudovic Courtès <ludo@gnu.org>2018-01-07 23:51:46 +0100
commitc04ffadbed7412545555b8be6b78f23eed150d26 (patch)
treeab4d7f076ea394eacfcad6b8540b2976e8ba16fa /guix/scripts
parent152b7beeacb72fe96fd5d3c0fd8b321e247c2c6c (diff)
downloadgnu-guix-c04ffadbed7412545555b8be6b78f23eed150d26.tar
gnu-guix-c04ffadbed7412545555b8be6b78f23eed150d26.tar.gz
publish: Publish build logs.
* guix/scripts/publish.scm (render-log-file): New procedure. (make-request-handler): Add "log" case. * tests/publish.scm ("/log/NAME") ("/log/NAME not found"): New tests. * doc/guix.texi (Invoking guix publish): Document /log URLs.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/publish.scm29
1 files changed, 29 insertions, 0 deletions
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 3f73197239..6eb5397c8d 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -572,6 +572,31 @@ has the given HASH of type ALGO."
(not-found request)))
(not-found request)))
+(define (render-log-file store request name)
+ "Render the log file for NAME, the base name of a store item. Don't attempt
+to compress or decompress the log file; just return it as-is."
+ (define (response-headers file)
+ ;; XXX: We're not returning the actual contents, deferring instead to
+ ;; 'http-write'. This is a hack to work around
+ ;; <http://bugs.gnu.org/21093>.
+ (cond ((string-suffix? ".gz" file)
+ `((content-type . (text/plain (charset . "UTF-8")))
+ (content-encoding . (gzip))
+ (x-raw-file . ,file)))
+ ((string-suffix? ".bz2" file)
+ `((content-type . (application/x-bzip2
+ (charset . "ISO-8859-1")))
+ (x-raw-file . ,file)))
+ (else ;uncompressed
+ `((content-type . (text/plain (charset . "UTF-8")))
+ (x-raw-file . ,file)))))
+
+ (let ((log (log-file store
+ (string-append (%store-prefix) "/" name))))
+ (if log
+ (values (response-headers log) log)
+ (not-found request))))
+
(define (render-home-page request)
"Render the home page."
(values `((content-type . (text/html (charset . "UTF-8"))))
@@ -772,6 +797,10 @@ blocking."
(render-content-addressed-file store request
name 'sha256 hash))))
+ ;; /log/OUTPUT
+ (("log" name)
+ (render-log-file store request name))
+
;; Use different URLs depending on the compression type. This
;; guarantees that /nar URLs remain valid even when 'guix publish'
;; is restarted with different compression parameters.