unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively'.
@ 2024-01-12 15:24 Romain GARBAGE
  2024-01-19  4:20 ` Maxim Cournoyer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Romain GARBAGE @ 2024-01-12 15:24 UTC (permalink / raw)
  To: 68406; +Cc: Romain GARBAGE

* guix/build/utils.scm (copy-recursively): Add `select?' key.

Change-Id: Icfe226164bb88dfede58ae24c15a98db9b696c3b
---
 guix/build/utils.scm | 42 ++++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 2352a627e9..7567eb9e4d 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -430,32 +430,38 @@ (define* (copy-recursively source destination
                            (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))))
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively'.
  2024-01-12 15:24 [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively' Romain GARBAGE
@ 2024-01-19  4:20 ` Maxim Cournoyer
  2024-01-21 22:57 ` bug#68406: " Maxim Cournoyer
  2024-01-22 11:30 ` [bug#68406] " Ludovic Courtès
  2 siblings, 0 replies; 4+ messages in thread
From: Maxim Cournoyer @ 2024-01-19  4:20 UTC (permalink / raw)
  To: Romain GARBAGE; +Cc: 68406

Hi,

Romain GARBAGE <romain.garbage@inria.fr> writes:

> * guix/build/utils.scm (copy-recursively): Add `select?' key.
>
> Change-Id: Icfe226164bb88dfede58ae24c15a98db9b696c3b

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail>

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#68406: [PATCH core-updates] guix: build: Expand `copy-recursively'.
  2024-01-12 15:24 [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively' Romain GARBAGE
  2024-01-19  4:20 ` Maxim Cournoyer
@ 2024-01-21 22:57 ` Maxim Cournoyer
  2024-01-22 11:30 ` [bug#68406] " Ludovic Courtès
  2 siblings, 0 replies; 4+ messages in thread
From: Maxim Cournoyer @ 2024-01-21 22:57 UTC (permalink / raw)
  To: Romain GARBAGE; +Cc: 68406-done

Hi!

Romain GARBAGE <romain.garbage@inria.fr> writes:

> * guix/build/utils.scm (copy-recursively): Add `select?' key.

Applied to core-updates.

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively'.
  2024-01-12 15:24 [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively' Romain GARBAGE
  2024-01-19  4:20 ` Maxim Cournoyer
  2024-01-21 22:57 ` bug#68406: " Maxim Cournoyer
@ 2024-01-22 11:30 ` Ludovic Courtès
  2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2024-01-22 11:30 UTC (permalink / raw)
  To: Romain GARBAGE; +Cc: 68406, Maxim Cournoyer

Hello!

Romain GARBAGE <romain.garbage@inria.fr> skribis:

> * guix/build/utils.scm (copy-recursively): Add `select?' key.
>
> Change-Id: Icfe226164bb88dfede58ae24c15a98db9b696c3b

[...]

> +  "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."

Could you send a patch that updates ‘doc/guix.texi’ to match the
docstring?

I had completely overlooked that.

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-22 11:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12 15:24 [bug#68406] [PATCH core-updates] guix: build: Expand `copy-recursively' Romain GARBAGE
2024-01-19  4:20 ` Maxim Cournoyer
2024-01-21 22:57 ` bug#68406: " Maxim Cournoyer
2024-01-22 11:30 ` [bug#68406] " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).