diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2017-04-21 22:43:28 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2017-04-21 22:45:29 +0200 |
| commit | 9231ef12f2a595b8f1e677dbe50cc499555302b6 (patch) | |
| tree | 0b43e1e56e5e196c5d7592f67affb719e02fe451 | |
| parent | 0a3bed8819551c94fd715828f0522f55af836ea0 (diff) | |
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
2dce88d5bbe7a65e101c0734d1c6db44ecc8c299.
* tests/derivations.scm ("build-expression->derivation and builder
encoding"): New test.
| -rw-r--r-- | guix/derivations.scm | 10 | ||||
| -rw-r--r-- | tests/derivations.scm | 13 |
2 files changed, 17 insertions, 6 deletions
diff --git a/guix/derivations.scm b/guix/derivations.scm index 410c41083e4..d5e0f453e25 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm | |||
| @@ -1238,16 +1238,15 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, and SUBSTITUTABLE?." | |||
| 1238 | ;; Guile sets it, but remove it to avoid conflicts when | 1238 | ;; Guile sets it, but remove it to avoid conflicts when |
| 1239 | ;; building Guile-using packages. | 1239 | ;; building Guile-using packages. |
| 1240 | (unsetenv "LD_LIBRARY_PATH"))) | 1240 | (unsetenv "LD_LIBRARY_PATH"))) |
| 1241 | (builder (add-data-to-store store | 1241 | (builder (add-text-to-store store |
| 1242 | (string-append name "-guile-builder") | 1242 | (string-append name "-guile-builder") |
| 1243 | 1243 | ||
| 1244 | ;; Explicitly use UTF-8 for determinism, | 1244 | ;; Explicitly use UTF-8 for determinism, |
| 1245 | ;; and also because UTF-8 output is faster. | 1245 | ;; and also because UTF-8 output is faster. |
| 1246 | (with-fluids ((%default-port-encoding | 1246 | (with-fluids ((%default-port-encoding |
| 1247 | "UTF-8")) | 1247 | "UTF-8")) |
| 1248 | (call-with-values | 1248 | (call-with-output-string |
| 1249 | open-bytevector-output-port | 1249 | (lambda (port) |
| 1250 | (lambda (port get-bv) | ||
| 1251 | (write prologue port) | 1250 | (write prologue port) |
| 1252 | (write | 1251 | (write |
| 1253 | `(exit | 1252 | `(exit |
| @@ -1255,8 +1254,7 @@ ALLOWED-REFERENCES, DISALLOWED-REFERENCES, LOCAL-BUILD?, and SUBSTITUTABLE?." | |||
| 1255 | ((_ ...) | 1254 | ((_ ...) |
| 1256 | (remove module-form? exp)) | 1255 | (remove module-form? exp)) |
| 1257 | (_ `(,exp)))) | 1256 | (_ `(,exp)))) |
| 1258 | port) | 1257 | port)))) |
| 1259 | (get-bv)))) | ||
| 1260 | 1258 | ||
| 1261 | ;; The references don't really matter | 1259 | ;; The references don't really matter |
| 1262 | ;; since the builder is always used in | 1260 | ;; since the builder is always used in |
diff --git a/tests/derivations.scm b/tests/derivations.scm index 75c8d1dfb1a..626e4d20e2a 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm | |||
| @@ -701,6 +701,19 @@ | |||
| 701 | #:modules '((guix module that | 701 | #:modules '((guix module that |
| 702 | does not exist))))) | 702 | does not exist))))) |
| 703 | 703 | ||
| 704 | (test-equal "build-expression->derivation and builder encoding" | ||
| 705 | '("UTF-8" #t) | ||
| 706 | (let* ((exp '(λ (α) (+ α 1))) | ||
| 707 | (drv (build-expression->derivation %store "foo" exp))) | ||
| 708 | (match (derivation-builder-arguments drv) | ||
| 709 | ((... builder) | ||
| 710 | (call-with-input-file builder | ||
| 711 | (lambda (port) | ||
| 712 | (list (port-encoding port) | ||
| 713 | (->bool | ||
| 714 | (string-contains (get-string-all port) | ||
| 715 | "(λ (α) (+ α 1))"))))))))) | ||
| 716 | |||
| 704 | (test-assert "build-expression->derivation and derivation-prerequisites" | 717 | (test-assert "build-expression->derivation and derivation-prerequisites" |
| 705 | (let ((drv (build-expression->derivation %store "fail" #f))) | 718 | (let ((drv (build-expression->derivation %store "fail" #f))) |
| 706 | (any (match-lambda | 719 | (any (match-lambda |
