guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: publish: Gracefully handle the lack of a deriver.


From: Ludovic Courtès
Subject: 01/01: publish: Gracefully handle the lack of a deriver.
Date: Thu, 03 Sep 2015 22:13:13 +0000

civodul pushed a commit to branch master
in repository guix.

commit 9d2f48df024fab5b99f1243cdf912a926c0e1e3d
Author: Ludovic Courtès <address@hidden>
Date:   Thu Sep 3 23:37:33 2015 +0200

    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.
---
 guix/scripts/publish.scm    |   23 ++++++++++++++++-------
 guix/scripts/substitute.scm |    2 +-
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index e3bcac8..cc96355 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -151,7 +151,7 @@ PATH-INFO.  The narinfo is signed with KEY."
          (references (string-join
                       (map basename (path-info-references path-info))
                       " "))
-         (deriver (path-info-deriver path-info))
+         (deriver    (path-info-deriver path-info))
          (base-info  (format #f
                              "StorePath: ~a
 URL: ~a
@@ -162,12 +162,21 @@ References: ~a~%"
                              store-path url hash size references))
          ;; Do not render a "Deriver" or "System" line if we are rendering
          ;; info for a derivation.
-         (info (if (string-null? deriver)
-                   base-info
-                   (let ((drv (load-derivation deriver)))
-                     (format #f "~aSystem: ~a~%Deriver: ~a~%"
-                             base-info (derivation-system drv)
-                             (basename deriver)))))
+         (info       (if (string-null? deriver)
+                         base-info
+                         (catch 'system-error
+                           (lambda ()
+                             (let ((drv (load-derivation deriver)))
+                               (format #f "~aSystem: ~a~%Deriver: ~a~%"
+                                       base-info (derivation-system drv)
+                                       (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
                       (canonical-sexp->string (signed-string info)))))
     (format #f "~aSignature: 1;~a;~a~%" info (gethostname) signature)))
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 95aae2a..e908bc9 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -703,7 +703,7 @@ Internal tool to substitute a pre-built binary to a local 
build.\n"))
 ;;;
 
 (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."
   (format #t "~a\n~a\n~a\n"
           (narinfo-path narinfo)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]