guix-commits
[Top][All Lists]
Advanced

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

01/02: derivations: Restore UTF-8 encoding of build scripts.


From: Ludovic Courtès
Subject: 01/02: derivations: Restore UTF-8 encoding of build scripts.
Date: Fri, 21 Apr 2017 16:55:15 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 9231ef12f2a595b8f1e677dbe50cc499555302b6
Author: Ludovic Courtès <address@hidden>
Date:   Fri Apr 21 22:43:28 2017 +0200

    derivations: Restore UTF-8 encoding of build scripts.
    
    Reported by Mark H Weaver <address@hidden>
    at <https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00457.html>.
    
    * guix/derivations.scm (build-expression->derivation): Use a string
    output port for the expression.  This reverts part of
    2dce88d5bbe7a65e101c0734d1c6db44ecc8c299.
    * tests/derivations.scm ("build-expression->derivation and builder
    encoding"): New test.
---
 guix/derivations.scm  | 10 ++++------
 tests/derivations.scm | 13 +++++++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/guix/derivations.scm b/guix/derivations.scm
index 410c410..d5e0f45 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -1238,16 +1238,15 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, 
LOCAL-BUILD?, and SUBSTITUTABLE?."
                       ;; Guile sets it, but remove it to avoid conflicts when
                       ;; building Guile-using packages.
                       (unsetenv "LD_LIBRARY_PATH")))
-         (builder  (add-data-to-store store
+         (builder  (add-text-to-store store
                                       (string-append name "-guile-builder")
 
                                       ;; Explicitly use UTF-8 for determinism,
                                       ;; and also because UTF-8 output is 
faster.
                                       (with-fluids ((%default-port-encoding
                                                      "UTF-8"))
-                                        (call-with-values
-                                            open-bytevector-output-port
-                                          (lambda (port get-bv)
+                                        (call-with-output-string
+                                          (lambda (port)
                                             (write prologue port)
                                             (write
                                              `(exit
@@ -1255,8 +1254,7 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, 
and SUBSTITUTABLE?."
                                                   ((_ ...)
                                                    (remove module-form? exp))
                                                   (_ `(,exp))))
-                                             port)
-                                            (get-bv))))
+                                             port))))
 
                                       ;; The references don't really matter
                                       ;; since the builder is always used in
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 75c8d1d..626e4d2 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -701,6 +701,19 @@
                                   #:modules '((guix module that
                                                     does not exist)))))
 
+(test-equal "build-expression->derivation and builder encoding"
+  '("UTF-8" #t)
+  (let* ((exp '(λ (α) (+ α 1)))
+         (drv (build-expression->derivation %store "foo" exp)))
+    (match (derivation-builder-arguments drv)
+      ((... builder)
+       (call-with-input-file builder
+         (lambda (port)
+           (list (port-encoding port)
+                 (->bool
+                  (string-contains (get-string-all port)
+                                   "(λ (α) (+ α 1))")))))))))
+
 (test-assert "build-expression->derivation and derivation-prerequisites"
   (let ((drv (build-expression->derivation %store "fail" #f)))
     (any (match-lambda



reply via email to

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