From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Package Definitions and Maintenance Date: Mon, 03 Apr 2017 15:42:44 +0200 Message-ID: <87pogtmwtn.fsf@gnu.org> References: <20170402114445.33e505b3@hitpoints> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cv2Fv-0003MU-Vg for help-guix@gnu.org; Mon, 03 Apr 2017 09:42:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cv2Fr-0003oJ-Tx for help-guix@gnu.org; Mon, 03 Apr 2017 09:42:52 -0400 In-Reply-To: <20170402114445.33e505b3@hitpoints> (Thomas Sigurdsen's message of "Sun, 2 Apr 2017 11:44:45 +0200") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Thomas Sigurdsen Cc: "help-guix@gnu.org" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thomas Sigurdsen skribis: > WARNING: (wkhtmltopdf): `freetype' imported from both (guix licenses) and > (gnu packages fontutils) Backtrace: > In ice-9/boot-9.scm: > 4056: 19 [#] > 1727: 18 [%start-stack load-stack ...] > 1732: 17 [#] > In unknown file: > ?: 16 [primitive-load > "/gnu/store/0icg6mr0cw74srvp39hms8fvh3s821yf-guix-0.12.0-7.aabe/bin/.guix= -real"] > In guix/ui.scm: 1228: 15 [run-guix-command package "-i" "wkhtmltopdf"] > In ice-9/boot-9.scm: > 160: 14 [catch srfi-34 # ...] > 160: 13 [catch system-error ...] > In guix/scripts/package.scm: > 896: 12 [#] > 863: 11 [process-actions # (# # # # ...)] > In guix/ui.scm: > 729: 10 [show-manifest-transaction # # # ...] > In srfi/srfi-1.scm: > 598: 9 [map # item)> ...] In guix/ui.scm: > 658: 8 [# > "wkhtmltopdf" ...] In guix/packages.scm: > 1134: 7 [package-output # # "out" ...] > 786: 6 [cache! # # # ...] > 1092: 5 [thunk] > 1024: 4 [bag->derivation # # #] > In srfi/srfi-1.scm: > 573: 3 [map # #] > In guix/packages.scm: > 846: 2 [expand-input # # # ...] > In guix/store.scm: > 1176: 1 [# # > # ...] In unknown file: > ?: 0 [#f # "x86_64-linux" #f] The attached patch slightly improves the situation: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build -L /tmp/guixsd-configuration/modules/tms/ wkhtm= ltopdf WARNING: (wkhtmltopdf): `freetype' imported from both (guix licenses) and (= gnu packages fontutils) guix build: error: #< name: "Zlib" uri: "http://www.gzip.org/zlib/= zlib_license.html" comment: "https://www.gnu.org/licenses/license-list#ZLib= ">: invalid G-expression input --8<---------------cut here---------------end--------------->8--- The downside is that there=E2=80=99s no source location info here, and it= =E2=80=99s talking about g-expressions when all the user cares about is packages in this case. Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/gexp.scm b/guix/gexp.scm index 1b8e43e99..80d8f735b 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -26,6 +26,8 @@ #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:use-module (ice-9 match) #:export (gexp gexp? @@ -84,7 +86,13 @@ gexp-compiler? lower-object - lower-inputs)) + lower-inputs + + &gexp-error + gexp-error? + &gexp-input-error + gexp-input-error? + gexp-error-invalid-input)) ;;; Commentary: ;;; @@ -140,6 +148,14 @@ (lower gexp-compiler-lower) (expand gexp-compiler-expand)) ;#f | DRV -> sexp +(define-condition-type &gexp-error &error + gexp-error?) + +(define-condition-type &gexp-input-error &gexp-error + gexp-input-error? + (input gexp-error-invalid-input)) + + (define %gexp-compilers ;; 'eq?' mapping of record type descriptor to . (make-hash-table 20)) @@ -177,8 +193,11 @@ procedure to expand it; otherwise return #f." corresponding to OBJ for SYSTEM, cross-compiling for TARGET if TARGET is true. OBJ must be an object that has an associated gexp compiler, such as a ." - (let ((lower (lookup-compiler obj))) - (lower obj system target))) + (match (lookup-compiler obj) + (#f + (raise (condition (&gexp-input-error (input obj))))) + (lower + (lower obj system target)))) (define-syntax define-gexp-compiler (syntax-rules (=> compiler expander) diff --git a/guix/packages.scm b/guix/packages.scm index 61171b834..d865dd5ad 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -31,7 +31,6 @@ #:use-module (guix memoization) #:use-module (guix build-system) #:use-module (guix search-paths) - #:use-module (guix gexp) #:use-module (guix sets) #:use-module (ice-9 match) #:use-module (ice-9 vlist) @@ -1226,4 +1225,7 @@ outside of the store) or SOURCE itself (if SOURCE is already a store item.)" ((? string? file) (add-to-store store (basename file) #t "sha256" file)) (_ + ;; XXX: 'lower' can throw '&gexp-input-error'. From a UI viewpoint, + ;; this is better than a wrong-type-arg error, but it's not ideal + ;; because gexps don't have source location information yet. (lower store source system)))))) diff --git a/guix/ui.scm b/guix/ui.scm index 345bf490b..b3c94795f 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -26,6 +26,7 @@ ;;; along with GNU Guix. If not, see . (define-module (guix ui) + #:use-module (guix gexp) #:use-module (guix utils) #:use-module (guix store) #:use-module (guix config) @@ -448,6 +449,10 @@ interpreted." (location->string loc) (package-full-name package) (build-system-name system)))) + ((gexp-input-error? c) + (let ((input (package-error-invalid-input c))) + (leave (_ "~s: invalid G-expression input~%") + (gexp-error-invalid-input c)))) ((profile-not-found-error? c) (leave (_ "profile '~a' does not exist~%") (profile-error-profile c))) --=-=-=--