aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain GARBAGE <romain.garbage@inria.fr>2024-01-12 16:24:04 +0100
committerLudovic Courtès <ludo@gnu.org>2024-08-31 10:44:40 +0200
commitaf15de3d6aa13ed3d0454524bf277602da40a6fb (patch)
tree66c38e53bfdc7788d1b18f6effa8db15a5d933ac
parent92f66ab60d840094b59705f2e13c94bbcef6433b (diff)
downloadguix-af15de3d6aa13ed3d0454524bf277602da40a6fb.tar.gz
guix-af15de3d6aa13ed3d0454524bf277602da40a6fb.zip
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>
-rw-r--r--guix/build/utils.scm42
1 files changed, 24 insertions, 18 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 9c1e19f6d8..94714bf397 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -432,32 +432,38 @@ name."
(log (current-output-port))
(follow-symlinks? #f)
(copy-file copy-file)
- keep-mtime? keep-permissions?)
- "Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS?
-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
-those of DESTINATION. When KEEP-PERMISSIONS? is true, preserve file
-permissions. Write verbose output to the LOG port."
+ keep-mtime? keep-permissions?
+ (select? (const #t)))
+ "Copy SOURCE directory to DESTINATION. Follow symlinks if FOLLOW-SYMLINKS? 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 those of
+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
(let ((len (string-length source)))
(lambda (file)
(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
(let ((dest (string-append destination
(strip-source file))))
- (format log "`~a' -> `~a'~%" file dest)
- (case (stat:type stat)
- ((symlink)
- (let ((target (readlink file)))
- (symlink target dest)))
- (else
- (copy-file file dest)
- (when keep-permissions?
- (chmod dest (stat:perms stat)))))
- (when keep-mtime?
- (set-file-time dest stat))))
+ (when (select? file stat)
+ (format log "`~a' -> `~a'~%" file dest)
+ (case (stat:type stat)
+ ((symlink)
+ (let ((target (readlink file)))
+ (symlink target dest)))
+ (else
+ (copy-file file dest)
+ (when keep-permissions?
+ (chmod dest (stat:perms stat)))))
+ (when keep-mtime?
+ (set-file-time dest stat)))))
(lambda (dir stat result) ; down
(let ((target (string-append destination
(strip-source dir))))