utils: Add #:keep-permissions? parameter to 'copy-recursively'.
* guix/build/utils.scm (copy-recursively): Add #:keep-permissions? and honor it. * doc/guix.texi (Build Utilities): Adjust accordingly.
This commit is contained in:
parent
edbd8f3f7e
commit
55d095c653
2 changed files with 15 additions and 9 deletions
|
@ -7779,12 +7779,13 @@ Make @var{file} writable for its owner.
|
||||||
|
|
||||||
@deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
|
@deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
|
||||||
[#:log (current-output-port)] [#:follow-symlinks? #f] @
|
[#:log (current-output-port)] [#:follow-symlinks? #f] @
|
||||||
[#:copy-file copy-file] [#:keep-mtime? #f]
|
[#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t]
|
||||||
Copy @var{source} directory to @var{destination}. Follow symlinks if
|
Copy @var{source} directory to @var{destination}. Follow symlinks if
|
||||||
@var{follow-symlinks?} is true; otherwise, just preserve them. Call
|
@var{follow-symlinks?} is true; otherwise, just preserve them. Call
|
||||||
@var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
|
@var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
|
||||||
keep the modification time of the files in @var{source} on those of
|
keep the modification time of the files in @var{source} on those of
|
||||||
@var{destination}. Write verbose output to the @var{log} port.
|
@var{destination}. When @var{keep-permissions?} is true, preserve file
|
||||||
|
permissions. Write verbose output to the @var{log} port.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Scheme Procedure} delete-file-recursively @var{dir} @
|
@deffn {Scheme Procedure} delete-file-recursively @var{dir} @
|
||||||
|
|
|
@ -344,11 +344,12 @@ name."
|
||||||
(log (current-output-port))
|
(log (current-output-port))
|
||||||
(follow-symlinks? #f)
|
(follow-symlinks? #f)
|
||||||
(copy-file copy-file)
|
(copy-file copy-file)
|
||||||
keep-mtime?)
|
keep-mtime? keep-permissions?)
|
||||||
"Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS?
|
"Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS?
|
||||||
is true; otherwise, just preserve them. Call COPY-FILE to copy regular files.
|
is true; otherwise, just preserve them. Call COPY-FILE to copy regular files.
|
||||||
When KEEP-MTIME? is true, keep the modification time of the files in SOURCE on
|
When KEEP-MTIME? is true, keep the modification time of the files in SOURCE on
|
||||||
those of DESTINATION. Write verbose output to the LOG port."
|
those of DESTINATION. When KEEP-PERMISSIONS? is true, preserve file
|
||||||
|
permissions. Write verbose output to the LOG port."
|
||||||
(define strip-source
|
(define strip-source
|
||||||
(let ((len (string-length source)))
|
(let ((len (string-length source)))
|
||||||
(lambda (file)
|
(lambda (file)
|
||||||
|
@ -366,16 +367,20 @@ those of DESTINATION. Write verbose output to the LOG port."
|
||||||
(else
|
(else
|
||||||
(copy-file file dest)
|
(copy-file file dest)
|
||||||
(when keep-mtime?
|
(when keep-mtime?
|
||||||
(set-file-time dest stat))))))
|
(set-file-time dest stat))
|
||||||
|
(when keep-permissions?
|
||||||
|
(chmod dest (stat:perms stat)))))))
|
||||||
(lambda (dir stat result) ; down
|
(lambda (dir stat result) ; down
|
||||||
(let ((target (string-append destination
|
(let ((target (string-append destination
|
||||||
(strip-source dir))))
|
(strip-source dir))))
|
||||||
(mkdir-p target)))
|
(mkdir-p target)))
|
||||||
(lambda (dir stat result) ; up
|
(lambda (dir stat result) ; up
|
||||||
(when keep-mtime?
|
(let ((target (string-append destination
|
||||||
(let ((target (string-append destination
|
(strip-source dir))))
|
||||||
(strip-source dir))))
|
(when keep-mtime?
|
||||||
(set-file-time target stat))))
|
(set-file-time target stat))
|
||||||
|
(when keep-permissions?
|
||||||
|
(chmod target (stat:perms stat)))))
|
||||||
(const #t) ; skip
|
(const #t) ; skip
|
||||||
(lambda (file stat errno result)
|
(lambda (file stat errno result)
|
||||||
(format (current-error-port) "i/o error: ~a: ~a~%"
|
(format (current-error-port) "i/o error: ~a: ~a~%"
|
||||||
|
|
Reference in a new issue