guix-build: Gracefully handle `&package-input-error' conditions.

* guix/packages.scm: Export `package-error?' and `package-input-error?'.
* guix-build.in (guix-build): Catch `&package-input-error' conditions,
  print a human-readable message, and exit.
This commit is contained in:
Ludovic Courtès 2012-10-27 14:56:38 +02:00
parent 5e6c90121f
commit 0778385802
2 changed files with 79 additions and 62 deletions

View File

@ -30,11 +30,12 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
#:use-module (guix store)
#:use-module (guix derivations)
#:use-module (guix packages)
#:use-module ((guix utils) #:select (%current-system))
#:use-module (guix utils)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-37)
#:autoload (distro) (find-packages-by-name)
#:export (guix-build))
@ -169,6 +170,16 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
(guard (c ((package-input-error? c)
(let* ((package (package-error-package c))
(input (package-error-invalid-input c))
(location (package-location package))
(file (location-file location))
(line (location-line location))
(column (location-column location)))
(leave (_ "~a:~a:~a: error: package `~a' has an invalid input: ~s~%")
file line column
(package-full-name package) input))))
(let* ((opts (parse-options))
(src? (assoc-ref opts 'source?))
(sys (assoc-ref opts 'system))
@ -230,4 +241,8 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(derivation-path->output-path
d out-name)))
(derivation-outputs drv)))))
drv))))))
drv)))))))
;; Local Variables:
;; eval: (put 'guard 'scheme-indent-function 1)
;; End:

View File

@ -61,8 +61,10 @@
package-cross-derivation
&package-error
package-error?
package-error-package
&package-input-error
package-input-error?
package-error-invalid-input))
;;; Commentary: