all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Attila Lendvai <attila@lendvai.name>
To: 50878@debbugs.gnu.org
Cc: Attila Lendvai <attila@lendvai.name>
Subject: [bug#50878] [PATCH 3/4] guix: build: Factor out and export default-collision-resolver.
Date: Sun,  3 Oct 2021 14:43:02 +0200	[thread overview]
Message-ID: <20211003124303.8277-3-attila@lendvai.name> (raw)
In-Reply-To: <20211003124303.8277-1-attila@lendvai.name>

This prepares the stage for new collision resolvers, but no semantic changes.

* guix/build/union.scm (resolve-collision/pick-first): New function.
(resolve-collision-and-maybe-warn): New function.
(default-collision-resolver): New function.
---
 guix/build/union.scm | 16 ++++++++++------
 guix/gexp.scm        |  2 +-
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/guix/build/union.scm b/guix/build/union.scm
index 961ac3298b..9e8c2af4f5 100644
--- a/guix/build/union.scm
+++ b/guix/build/union.scm
@@ -27,7 +27,7 @@
   #:use-module (rnrs io ports)
   #:export (union-build
 
-            warn-about-collision
+            default-collision-resolver
 
             relative-file-name
             symlink-relative))
@@ -102,10 +102,11 @@ identical, #f otherwise."
   ;; applications via 'glib-or-gtk-build-system'.
   '("icon-theme.cache" "gschemas.compiled"))
 
-(define (warn-about-collision files)
-  "Handle the collision among FILES by emitting a warning and choosing the
-first one of THEM."
-  (let ((file (first files)))
+(define (resolve-collision/pick-first files)
+  (first files))
+
+(define (resolve-collision-and-maybe-warn files resolver)
+  (let ((file (resolver files)))
     (unless (member (basename file) %harmless-collisions)
       (format (current-error-port)
               "~%warning: collision encountered:~%~{  ~a~%~}"
@@ -113,11 +114,14 @@ first one of THEM."
       (format (current-error-port) "warning: choosing ~a~%" file))
     file))
 
+(define (default-collision-resolver files)
+  (resolve-collision-and-maybe-warn files resolve-collision/pick-first))
+
 (define* (union-build output inputs
                       #:key (log-port (current-error-port))
                       (create-all-directories? #f)
                       (symlink symlink)
-                      (resolve-collision warn-about-collision))
+                      (resolve-collision default-collision-resolver))
   "Build in the OUTPUT directory a symlink tree that is the union of all the
 INPUTS, using SYMLINK to create symlinks.  As a special case, if
 CREATE-ALL-DIRECTORIES?, creates the subdirectories in the output directory to
diff --git a/guix/gexp.scm b/guix/gexp.scm
index f3d278b3e6..32e8748443 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1983,7 +1983,7 @@ This yields an 'etc' directory containing these two files."
 
 (define* (directory-union name things
                           #:key (copy? #f) (quiet? #f)
-                          (resolve-collision 'warn-about-collision))
+                          (resolve-collision 'default-collision-resolver))
   "Return a directory that is the union of THINGS, where THINGS is a list of
 file-like objects denoting directories.  For example:
 
-- 
2.33.0





  parent reply	other threads:[~2021-10-03 12:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 21:40 [bug#50878] [PATCH] union: Resolve collisions by stable-sort'ing them Attila Lendvai
2021-09-29 13:48 ` Maxime Devos
2021-09-29 16:03   ` Attila Lendvai
2021-09-29 21:00     ` Maxime Devos
2021-09-29 17:42 ` Liliana Marie Prikler
2021-09-30  8:10   ` Attila Lendvai
2021-09-30  8:42     ` Maxime Devos
2021-09-30 14:00       ` Ludovic Courtès
2021-09-30 14:12       ` Attila Lendvai
2021-09-30 15:18         ` Maxime Devos
2021-09-30 18:13       ` Liliana Marie Prikler
2021-09-30 18:52     ` Liliana Marie Prikler
2021-10-03 12:43 ` [bug#50878] [PATCH 1/4] guix: build: Promote local define-inline to a define-constant util Attila Lendvai
2021-10-03 12:43   ` [bug#50878] [PATCH 2/4] guix: build: Avoid using magic literals in the code for hash length Attila Lendvai
2021-10-03 12:43   ` Attila Lendvai [this message]
2021-10-03 12:43   ` [bug#50878] [PATCH 4/4] WIP guix: build: Add resolve-collision/alphanumeric-last for union Attila Lendvai
2021-10-03 12:59 ` [bug#50878] (No Subject) Attila Lendvai
2022-09-02 16:04   ` Liliana Marie Prikler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211003124303.8277-3-attila@lendvai.name \
    --to=attila@lendvai.name \
    --cc=50878@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.