emacs-build-system: Do not patch files containing NULs.
This is a temporary workaround for <https://bugs.gnu.org/30116>, where 'substitute*' throws on files containing NUL characters. * guix/build/emacs-build-system.scm (patch-el-files): Filter out elisp files that contain NUL characters. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
58b6812fd4
commit
7c599eac0c
|
@ -97,23 +97,40 @@ archive, a directory, or an Emacs Lisp file."
|
||||||
(define* (patch-el-files #:key outputs #:allow-other-keys)
|
(define* (patch-el-files #:key outputs #:allow-other-keys)
|
||||||
"Substitute the absolute \"/bin/\" directory with the right location in the
|
"Substitute the absolute \"/bin/\" directory with the right location in the
|
||||||
store in '.el' files."
|
store in '.el' files."
|
||||||
|
|
||||||
|
(define (file-contains-nul-char? file)
|
||||||
|
(call-with-input-file file
|
||||||
|
(lambda (in)
|
||||||
|
(let loop ((line (read-line in 'concat)))
|
||||||
|
(cond
|
||||||
|
((eof-object? line) #f)
|
||||||
|
((string-index line #\nul) #t)
|
||||||
|
(else (loop (read-line in 'concat))))))
|
||||||
|
#:binary #t))
|
||||||
|
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let* ((out (assoc-ref outputs "out"))
|
||||||
(elpa-name-ver (store-directory->elpa-name-version out))
|
(elpa-name-ver (store-directory->elpa-name-version out))
|
||||||
(el-dir (string-append out %install-suffix "/" elpa-name-ver))
|
(el-dir (string-append out %install-suffix "/" elpa-name-ver))
|
||||||
(substitute-cmd (lambda ()
|
|
||||||
(substitute* (find-files "." "\\.el$")
|
;; (ice-9 regex) uses libc's regexp routines, which cannot deal with
|
||||||
(("\"/bin/([^.]\\S*)\"" _ cmd-name)
|
;; strings containing NULs. Filter out such files. TODO: Remove
|
||||||
(let ((cmd (which cmd-name)))
|
;; this workaround when <https://bugs.gnu.org/30116> is fixed.
|
||||||
(unless cmd
|
(el-files (remove file-contains-nul-char?
|
||||||
(error
|
(find-files (getcwd) "\\.el$"))))
|
||||||
"patch-el-files: unable to locate " cmd-name))
|
(define (substitute-program-names)
|
||||||
(string-append "\"" cmd "\"")))))))
|
(substitute* el-files
|
||||||
|
(("\"/bin/([^.]\\S*)\"" _ cmd-name)
|
||||||
|
(let ((cmd (which cmd-name)))
|
||||||
|
(unless cmd
|
||||||
|
(error "patch-el-files: unable to locate " cmd-name))
|
||||||
|
(string-append "\"" cmd "\"")))))
|
||||||
|
|
||||||
(with-directory-excursion el-dir
|
(with-directory-excursion el-dir
|
||||||
;; Some old '.el' files (e.g., tex-buf.el in AUCTeX) are still encoded
|
;; Some old '.el' files (e.g., tex-buf.el in AUCTeX) are still
|
||||||
;; with the "ISO-8859-1" locale.
|
;; ISO-8859-1-encoded.
|
||||||
(unless (false-if-exception (substitute-cmd))
|
(unless (false-if-exception (substitute-program-names))
|
||||||
(with-fluids ((%default-port-encoding "ISO-8859-1"))
|
(with-fluids ((%default-port-encoding "ISO-8859-1"))
|
||||||
(substitute-cmd))))
|
(substitute-program-names))))
|
||||||
#t))
|
#t))
|
||||||
|
|
||||||
(define* (install #:key outputs
|
(define* (install #:key outputs
|
||||||
|
|
Loading…
Reference in New Issue