diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-07-07 18:11:52 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-07-07 18:11:52 +0200 |
commit | d9dbab18e2f5e1854f663bfe760765c29c11cbd9 (patch) | |
tree | f167a73b2c818052fc3c91e32576dab8830170d4 /guix | |
parent | 4fa697e932d5634441e4e281ce6879ca3a082a30 (diff) | |
download | gnu-guix-d9dbab18e2f5e1854f663bfe760765c29c11cbd9.tar gnu-guix-d9dbab18e2f5e1854f663bfe760765c29c11cbd9.tar.gz |
utils: Have `substitute' restore the file's permission bits.
* guix/build/utils.scm (substitute): Restore FILE's mode before renaming
TEMPLATE.
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build/utils.scm | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 3dc7674043..e99afdfcf3 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -159,7 +159,8 @@ as (PROC MATCH OUTPUT-PORT)." 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 @@ as (PROC MATCH OUTPUT-PORT)." (if (eof-object? line) #t (begin - (for-each (match-lambda - ((regexp . proc) - (cond ((regexp-exec regexp line) - => - (lambda (m) - (proc m out))) - (else - (display line out) - (newline out))))) - rx+proc) + (or (any (match-lambda + ((regexp . proc) + (and=> (regexp-exec regexp line) + (lambda (m) + (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)))))) |