From: Christopher Baines <mail@cbaines.net>
To: 63263@debbugs.gnu.org
Subject: [bug#63263] [PATCH] gexp: Stop generating unreadable builder scripts.
Date: Thu, 4 May 2023 12:24:48 +0100 [thread overview]
Message-ID: <20230504112448.22462-1-mail@cbaines.net> (raw)
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
next reply other threads:[~2023-05-04 11:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 11:24 Christopher Baines [this message]
2023-05-04 12:47 ` [bug#63263] [PATCH] gexp: Stop generating unreadable builder scripts Ludovic Courtès
2023-05-04 12:57 ` Christopher Baines
2023-05-04 19:14 ` Josselin Poiret via Guix-patches via
2023-05-06 8:05 ` Christopher Baines
2023-05-05 21:45 ` Ludovic Courtès
2023-05-06 7:39 ` Christopher Baines
2023-05-10 15:22 ` Ludovic Courtès
2023-05-10 16:02 ` Christopher Baines
2023-09-01 14:16 ` Maxim Cournoyer
2023-09-02 10:36 ` bug#63263: " Christopher Baines
2023-09-03 14:54 ` [bug#63263] " Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230504112448.22462-1-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=63263@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.