mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 13:28:12 -05:00
utils: Have `substitute' restore the file's permission bits.
* guix/build/utils.scm (substitute): Restore FILE's mode before renaming TEMPLATE.
This commit is contained in:
parent
4fa697e932
commit
d9dbab18e2
1 changed files with 14 additions and 11 deletions
|
@ -159,7 +159,8 @@ (define (substitute file pattern+procs)
|
|||
proc)))
|
||||
pattern+procs))
|
||||
(template (string-append file ".XXXXXX"))
|
||||
(out (mkstemp! template)))
|
||||
(out (mkstemp! template))
|
||||
(mode (stat:mode (stat file))))
|
||||
(with-throw-handler #t
|
||||
(lambda ()
|
||||
(call-with-input-file file
|
||||
|
@ -168,18 +169,20 @@ (define (substitute file pattern+procs)
|
|||
(if (eof-object? line)
|
||||
#t
|
||||
(begin
|
||||
(for-each (match-lambda
|
||||
(or (any (match-lambda
|
||||
((regexp . proc)
|
||||
(cond ((regexp-exec regexp line)
|
||||
=>
|
||||
(and=> (regexp-exec regexp line)
|
||||
(lambda (m)
|
||||
(proc m out)))
|
||||
(else
|
||||
(display line out)
|
||||
(newline out)))))
|
||||
(proc m out)
|
||||
#t))))
|
||||
rx+proc)
|
||||
(begin
|
||||
(display line out)
|
||||
(newline out)
|
||||
#t))
|
||||
(loop (read-line in)))))))
|
||||
(close out)
|
||||
(chmod template mode)
|
||||
(rename-file template file))
|
||||
(lambda (key . args)
|
||||
(false-if-exception (delete-file template))))))
|
||||
|
|
Loading…
Reference in a new issue