utils: Have `substitute' restore the file's permission bits.
* guix/build/utils.scm (substitute): Restore FILE's mode before renaming TEMPLATE.master
parent
4fa697e932
commit
d9dbab18e2
|
@ -159,7 +159,8 @@ as (PROC MATCH OUTPUT-PORT)."
|
||||||
proc)))
|
proc)))
|
||||||
pattern+procs))
|
pattern+procs))
|
||||||
(template (string-append file ".XXXXXX"))
|
(template (string-append file ".XXXXXX"))
|
||||||
(out (mkstemp! template)))
|
(out (mkstemp! template))
|
||||||
|
(mode (stat:mode (stat file))))
|
||||||
(with-throw-handler #t
|
(with-throw-handler #t
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(call-with-input-file file
|
(call-with-input-file file
|
||||||
|
@ -168,18 +169,20 @@ as (PROC MATCH OUTPUT-PORT)."
|
||||||
(if (eof-object? line)
|
(if (eof-object? line)
|
||||||
#t
|
#t
|
||||||
(begin
|
(begin
|
||||||
(for-each (match-lambda
|
(or (any (match-lambda
|
||||||
((regexp . proc)
|
((regexp . proc)
|
||||||
(cond ((regexp-exec regexp line)
|
(and=> (regexp-exec regexp line)
|
||||||
=>
|
(lambda (m)
|
||||||
(lambda (m)
|
(proc m out)
|
||||||
(proc m out)))
|
#t))))
|
||||||
(else
|
rx+proc)
|
||||||
(display line out)
|
(begin
|
||||||
(newline out)))))
|
(display line out)
|
||||||
rx+proc)
|
(newline out)
|
||||||
|
#t))
|
||||||
(loop (read-line in)))))))
|
(loop (read-line in)))))))
|
||||||
(close out)
|
(close out)
|
||||||
|
(chmod template mode)
|
||||||
(rename-file template file))
|
(rename-file template file))
|
||||||
(lambda (key . args)
|
(lambda (key . args)
|
||||||
(false-if-exception (delete-file template))))))
|
(false-if-exception (delete-file template))))))
|
||||||
|
|
Reference in New Issue