From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id oCAnO1+WU2QISQEASxT56A (envelope-from ) for ; Thu, 04 May 2023 13:26:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id MI/nOl+WU2S1SAAAauVa8A (envelope-from ) for ; Thu, 04 May 2023 13:26:23 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8FE873890B for ; Thu, 4 May 2023 13:26:23 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puX67-00021P-G5; Thu, 04 May 2023 07:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puX63-00020w-Q6 for guix-patches@gnu.org; Thu, 04 May 2023 07:26:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1puX63-0006em-Hl for guix-patches@gnu.org; Thu, 04 May 2023 07:26:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1puX63-0006FN-Ca for guix-patches@gnu.org; Thu, 04 May 2023 07:26:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63263] [PATCH] gexp: Stop generating unreadable builder scripts. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 04 May 2023 11:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63263@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.168319953123949 (code B ref -1); Thu, 04 May 2023 11:26:03 +0000 Received: (at submit) by debbugs.gnu.org; 4 May 2023 11:25:31 +0000 Received: from localhost ([127.0.0.1]:48730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puX5X-0006EC-5W for submit@debbugs.gnu.org; Thu, 04 May 2023 07:25:31 -0400 Received: from lists.gnu.org ([209.51.188.17]:42212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puX5T-0006Dq-7j for submit@debbugs.gnu.org; Thu, 04 May 2023 07:25:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puX5J-00018S-Lq for guix-patches@gnu.org; Thu, 04 May 2023 07:25:23 -0400 Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puX5F-0006Dq-HG for guix-patches@gnu.org; Thu, 04 May 2023 07:25:15 -0400 Received: from localhost (unknown [IPv6:2a02:8010:68c1:0:54d1:d5d4:280e:f699]) by mira.cbaines.net (Postfix) with ESMTPSA id 81B8527BBE2 for ; Thu, 4 May 2023 12:24:49 +0100 (BST) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 4f989652 for ; Thu, 4 May 2023 11:24:48 +0000 (UTC) From: Christopher Baines Date: Thu, 4 May 2023 12:24:48 +0100 Message-Id: <20230504112448.22462-1-mail@cbaines.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683199583; a=rsa-sha256; cv=none; b=q0w/alepCDFbiqmL42sRn+XVynmyecdei2w9ae3oykusEFRmb5IX1pPwBcAr4c+ziT+STs 4y9WuLaY0uNbdDrCZvPoErVeIoWDkUeL2XaXMIox0oqwAhi3eF2q7CafOw9u26dD+fPWeo YvKh/SD8/MfOTFmTRluPrx3eu8HVUO2Nxx8xKtPGF2sdusf7bQG/cy7bd4X30sJncFEUKH K4a3+V9tF/D0RcAsQ8lsRMMiRv6P6dK8b3mAqG9f/yuGxgctKbcAiakAAz3P7Nu8L+mKH5 5jWfEzGHk9OdyDS77KxrOdbhJm2hFA5EyF0hP4Rn0V2Xx65tW718Y5zhKyH9tQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683199583; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=taUORnIls4qO6ceStT7F9lBSJ+0dslD3segkiEy5XcE=; b=XKlONB4Xv14QbEks9h1ERkSS3t31Za82XX2LpDZbOaafYn8o/GWr0J5RtSPxW4WL3cbK+e fKqrJG3c00F0goiUik0aPpXwrBrPJR+Cu318V9nBn5GoY44iWcgG1W6R82C3cXKs06LSF/ anMFd4IfWHRFhRZUGaBJ9bchbhwYFDFk0wHkCybkNMMUdlSZZqPSX0SZ85c/xAB2vzEmOP VKfcY1ErwhLovQR//Ydemxc8LYJWtic6lIA4KZJBm3Vq/it72/4FOMQCyjqfdtZqDB/II6 jnxEX5zfGRf2fLGA8rfSSDVNkXgF4Tphd5SZP1h1vc8UKIV16bBUzF4F6reaTA== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.41 X-Spam-Score: -0.41 X-Migadu-Queue-Id: 8FE873890B X-TUID: EWMfOVx0uhbC In Guile, it's possible to produce output from write that can't be read, and this applies to the code staged through g-expressions for derivations. This commit detects this early when the derivation is being created, rather than leaving the error to happen when the derivation is built. This is important as it means that tools like guix lint will indicate that there's a problem, hopefully reducing the number of broken derivations in Guix. * guix/gexp.scm (gexp->derivation): Check that the builder script can be read. --- guix/gexp.scm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/guix/gexp.scm b/guix/gexp.scm index 0fe4f1c98a..7af9302ccf 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -1215,9 +1215,18 @@ (define (add-modules exp modules) #:target target) (return #f))) (guile -> (lowered-gexp-guile lowered)) - (builder (text-file script-name - (sexp->string - (lowered-gexp-sexp lowered))))) + (builder (text-file + script-name + (let ((builder-string + (sexp->string + (lowered-gexp-sexp lowered)))) + (catch 'read-error + (lambda () + (call-with-input-string builder-string + read) + builder-string) + (lambda (key . args) + (error "invalid gexp" name exp args))))))) (mbegin %store-monad (set-grafting graft?) ;restore the initial setting (raw-derivation name -- 2.39.1