publish: Gracefully handle the lack of a deriver.
* guix/scripts/publish.scm (narinfo-string): Catch 'system-error' around 'load-derivation' call; return BASE-INFO upon ENOENT. This allows us to return the narinfo even if DERIVER is missing. Before that, the exception would be uncaught, leading to 500 Internal Error on the client side.
This commit is contained in:
parent
6fc92598ac
commit
9d2f48df02
|
@ -164,10 +164,19 @@ References: ~a~%"
|
||||||
;; info for a derivation.
|
;; info for a derivation.
|
||||||
(info (if (string-null? deriver)
|
(info (if (string-null? deriver)
|
||||||
base-info
|
base-info
|
||||||
|
(catch 'system-error
|
||||||
|
(lambda ()
|
||||||
(let ((drv (load-derivation deriver)))
|
(let ((drv (load-derivation deriver)))
|
||||||
(format #f "~aSystem: ~a~%Deriver: ~a~%"
|
(format #f "~aSystem: ~a~%Deriver: ~a~%"
|
||||||
base-info (derivation-system drv)
|
base-info (derivation-system drv)
|
||||||
(basename deriver)))))
|
(basename deriver))))
|
||||||
|
(lambda args
|
||||||
|
;; DERIVER might be missing, but that's fine:
|
||||||
|
;; it's only used for <substitutable> where it's
|
||||||
|
;; optional. 'System' is currently unused.
|
||||||
|
(if (= ENOENT (system-error-errno args))
|
||||||
|
base-info
|
||||||
|
(apply throw args))))))
|
||||||
(signature (base64-encode-string
|
(signature (base64-encode-string
|
||||||
(canonical-sexp->string (signed-string info)))))
|
(canonical-sexp->string (signed-string info)))))
|
||||||
(format #f "~aSignature: 1;~a;~a~%" info (gethostname) signature)))
|
(format #f "~aSignature: 1;~a;~a~%" info (gethostname) signature)))
|
||||||
|
|
|
@ -703,7 +703,7 @@ Internal tool to substitute a pre-built binary to a local build.\n"))
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define (display-narinfo-data narinfo)
|
(define (display-narinfo-data narinfo)
|
||||||
"Write to the current output port the contents of NARINFO is the format
|
"Write to the current output port the contents of NARINFO in the format
|
||||||
expected by the daemon."
|
expected by the daemon."
|
||||||
(format #t "~a\n~a\n~a\n"
|
(format #t "~a\n~a\n~a\n"
|
||||||
(narinfo-path narinfo)
|
(narinfo-path narinfo)
|
||||||
|
|
Loading…
Reference in New Issue