mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
guix: build: Expand `copy-recursively'.
* guix/build/utils.scm (copy-recursively): Add `select?' key. Change-Id: Icfe226164bb88dfede58ae24c15a98db9b696c3b Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
parent
92f66ab60d
commit
af15de3d6a
1 changed files with 24 additions and 18 deletions
|
@ -432,21 +432,27 @@ 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-permissions?)
|
keep-mtime? keep-permissions?
|
||||||
"Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS?
|
(select? (const #t)))
|
||||||
is true; otherwise, just preserve them. Call COPY-FILE to copy regular files.
|
"Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS? is
|
||||||
When KEEP-MTIME? is true, keep the modification time of the files in SOURCE on
|
true; otherwise, just preserve them. Call COPY-FILE to copy regular files. When
|
||||||
those of DESTINATION. When KEEP-PERMISSIONS? is true, preserve file
|
KEEP-MTIME? is true, keep the modification time of the files in SOURCE on those of
|
||||||
permissions. Write verbose output to the LOG port."
|
DESTINATION. When KEEP-PERMISSIONS? is true, preserve file permissions. Write
|
||||||
|
verbose output to the LOG port. Call (SELECT? FILE STAT) for each entry in source,
|
||||||
|
where FILE is the entry's absolute file name and STAT is the result of 'lstat' (or
|
||||||
|
'stat' if FOLLOW-SYMLINKS? is true); exclude entries for which SELECT? does not
|
||||||
|
return true."
|
||||||
(define strip-source
|
(define strip-source
|
||||||
(let ((len (string-length source)))
|
(let ((len (string-length source)))
|
||||||
(lambda (file)
|
(lambda (file)
|
||||||
(substring file len))))
|
(substring file len))))
|
||||||
|
|
||||||
(file-system-fold (const #t) ; enter?
|
(file-system-fold (lambda (file stat result) ; enter?
|
||||||
|
(select? file stat))
|
||||||
(lambda (file stat result) ; leaf
|
(lambda (file stat result) ; leaf
|
||||||
(let ((dest (string-append destination
|
(let ((dest (string-append destination
|
||||||
(strip-source file))))
|
(strip-source file))))
|
||||||
|
(when (select? file stat)
|
||||||
(format log "`~a' -> `~a'~%" file dest)
|
(format log "`~a' -> `~a'~%" file dest)
|
||||||
(case (stat:type stat)
|
(case (stat:type stat)
|
||||||
((symlink)
|
((symlink)
|
||||||
|
@ -457,7 +463,7 @@ permissions. Write verbose output to the LOG port."
|
||||||
(when keep-permissions?
|
(when keep-permissions?
|
||||||
(chmod dest (stat:perms stat)))))
|
(chmod dest (stat:perms stat)))))
|
||||||
(when keep-mtime?
|
(when keep-mtime?
|
||||||
(set-file-time dest stat))))
|
(set-file-time dest 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))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue