utils: Treat 'configure' and Makefiles with an 8-bit encoding.

* guix/build/utils.scm (patch-makefile-SHELL, patch-/usr/bin/file): Wrap
  'substitute*' in 'with-fluids'.  Fixes <http://hydra.gnu.org/build/262895>.
This commit is contained in:
Ludovic Courtès 2015-02-28 12:25:22 +01:00
parent 4db87162e6
commit dd0a8ef15f

View file

@ -712,16 +712,18 @@ (define (find-shell name)
shell)) shell))
(let ((st (stat file))) (let ((st (stat file)))
(substitute* file ;; Consider FILE is using an 8-bit encoding to avoid errors.
(("^ *SHELL[[:blank:]]*:?=[[:blank:]]*([[:graph:]]*/)([[:graph:]]+)(.*)$" (with-fluids ((%default-port-encoding #f))
_ dir shell args) (substitute* file
(let* ((old (string-append dir shell)) (("^ *SHELL[[:blank:]]*:?=[[:blank:]]*([[:graph:]]*/)([[:graph:]]+)(.*)$"
(new (or (find-shell shell) old))) _ dir shell args)
(unless (string=? new old) (let* ((old (string-append dir shell))
(format (current-error-port) (new (or (find-shell shell) old)))
"patch-makefile-SHELL: ~a: changing `SHELL' from `~a' to `~a'~%" (unless (string=? new old)
file old new)) (format (current-error-port)
(string-append "SHELL = " new args)))) "patch-makefile-SHELL: ~a: changing `SHELL' from `~a' to `~a'~%"
file old new))
(string-append "SHELL = " new args)))))
(when keep-mtime? (when keep-mtime?
(set-file-time file st)))) (set-file-time file st))))
@ -738,13 +740,15 @@ (define* (patch-/usr/bin/file file
"patch-/usr/bin/file: warning: \ "patch-/usr/bin/file: warning: \
no replacement 'file' command, doing nothing~%") no replacement 'file' command, doing nothing~%")
(let ((st (stat file))) (let ((st (stat file)))
(substitute* file ;; Consider FILE is using an 8-bit encoding to avoid errors.
(("/usr/bin/file") (with-fluids ((%default-port-encoding #f))
(begin (substitute* file
(format (current-error-port) (("/usr/bin/file")
"patch-/usr/bin/file: ~a: changing `~a' to `~a'~%" (begin
file "/usr/bin/file" file-command) (format (current-error-port)
file-command))) "patch-/usr/bin/file: ~a: changing `~a' to `~a'~%"
file "/usr/bin/file" file-command)
file-command))))
(when keep-mtime? (when keep-mtime?
(set-file-time file st))))) (set-file-time file st)))))