derivations: Restore UTF-8 encoding of build scripts.
Reported by Mark H Weaver <mhw@netris.org>
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
2dce88d5bb
.
* tests/derivations.scm ("build-expression->derivation and builder
encoding"): New test.
This commit is contained in:
parent
0a3bed8819
commit
9231ef12f2
|
@ -1238,16 +1238,15 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, and SUBSTITUTABLE?."
|
||||||
;; Guile sets it, but remove it to avoid conflicts when
|
;; Guile sets it, but remove it to avoid conflicts when
|
||||||
;; building Guile-using packages.
|
;; building Guile-using packages.
|
||||||
(unsetenv "LD_LIBRARY_PATH")))
|
(unsetenv "LD_LIBRARY_PATH")))
|
||||||
(builder (add-data-to-store store
|
(builder (add-text-to-store store
|
||||||
(string-append name "-guile-builder")
|
(string-append name "-guile-builder")
|
||||||
|
|
||||||
;; Explicitly use UTF-8 for determinism,
|
;; Explicitly use UTF-8 for determinism,
|
||||||
;; and also because UTF-8 output is faster.
|
;; and also because UTF-8 output is faster.
|
||||||
(with-fluids ((%default-port-encoding
|
(with-fluids ((%default-port-encoding
|
||||||
"UTF-8"))
|
"UTF-8"))
|
||||||
(call-with-values
|
(call-with-output-string
|
||||||
open-bytevector-output-port
|
(lambda (port)
|
||||||
(lambda (port get-bv)
|
|
||||||
(write prologue port)
|
(write prologue port)
|
||||||
(write
|
(write
|
||||||
`(exit
|
`(exit
|
||||||
|
@ -1255,8 +1254,7 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, and SUBSTITUTABLE?."
|
||||||
((_ ...)
|
((_ ...)
|
||||||
(remove module-form? exp))
|
(remove module-form? exp))
|
||||||
(_ `(,exp))))
|
(_ `(,exp))))
|
||||||
port)
|
port))))
|
||||||
(get-bv))))
|
|
||||||
|
|
||||||
;; The references don't really matter
|
;; The references don't really matter
|
||||||
;; since the builder is always used in
|
;; since the builder is always used in
|
||||||
|
|
|
@ -701,6 +701,19 @@
|
||||||
#:modules '((guix module that
|
#:modules '((guix module that
|
||||||
does not exist)))))
|
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"
|
(test-assert "build-expression->derivation and derivation-prerequisites"
|
||||||
(let ((drv (build-expression->derivation %store "fail" #f)))
|
(let ((drv (build-expression->derivation %store "fail" #f)))
|
||||||
(any (match-lambda
|
(any (match-lambda
|
||||||
|
|
Loading…
Reference in New Issue