From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WHIWLvKlVGEdFgEAgWs5BA (envelope-from ) for ; Wed, 29 Sep 2021 19:44:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id aA/IKfKlVGEafgAAB5/wlQ (envelope-from ) for ; Wed, 29 Sep 2021 17:44:18 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DD63689C0 for ; Wed, 29 Sep 2021 19:44:17 +0200 (CEST) Received: from localhost ([::1]:53388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVdcv-0007NU-2j for larch@yhetil.org; Wed, 29 Sep 2021 13:44:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVdcg-0007Ml-Lr for guix-patches@gnu.org; Wed, 29 Sep 2021 13:44:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38583) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVdcg-0007ln-EL for guix-patches@gnu.org; Wed, 29 Sep 2021 13:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVdcg-0007yd-CZ for guix-patches@gnu.org; Wed, 29 Sep 2021 13:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH] union: Resolve collisions by stable-sort'ing them. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 29 Sep 2021 17:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50878 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Attila Lendvai , 50878@debbugs.gnu.org Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.163293738730593 (code B ref 50878); Wed, 29 Sep 2021 17:44:02 +0000 Received: (at 50878) by debbugs.gnu.org; 29 Sep 2021 17:43:07 +0000 Received: from localhost ([127.0.0.1]:50129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVdbn-0007xN-85 for submit@debbugs.gnu.org; Wed, 29 Sep 2021 13:43:07 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:39592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVdbl-0007wn-36 for 50878@debbugs.gnu.org; Wed, 29 Sep 2021 13:43:05 -0400 Received: by mail-wr1-f53.google.com with SMTP id d26so5609748wrb.6 for <50878@debbugs.gnu.org>; Wed, 29 Sep 2021 10:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=G916XrlrGaXMyLnraJ1g/0J6/icsrjzBUinph+KTLMI=; b=OlQP/dqGZ1Mve8uTNJzsWAdRKw42d2r8ITFFdylU+U6Ya77NTHplW4dAFz8PFNQ7Jv FR7Y9O7fMP0gDek0xBQx8phz7O6P8LSEsyUnO/8slutP5+06F1dPDe46WJDJoy/OLFmV TEg6MXF1ELoKLO3B68tNnzxqvo1rwGQ3VslNCe2lVMbJ0BboAZx5zTKLTzAuNhoU5gmr LMrmHkkzStRP1Ht9SIUFZzgmz2Ws0ltwYosOvihnuzWeYibimCzrpxm9Zk1i+ZLyLt2E kOru9bvjsBkp0FzmGbfrs4T5vDEY84GDhBDwoHiDWTSRGkcPagFMJL1QjHLlUVTmBbkr K5fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=G916XrlrGaXMyLnraJ1g/0J6/icsrjzBUinph+KTLMI=; b=Y4t+ij8VEYRFubsZZsP8O5R9zeiOUpfo16hiBcpqcuTgn36FAgfA6S+7XTJAEwkdGf QrmrQ3Bbx5KD/hn0CYy92DJT4Eybn4fM/HThdxQS/nYJWlI3yqt31GBlk/tpLlNm4cPq PEWCAh5WuFAmfTOcNnSK+YUCTLPdrSQM2FMGV/y9OyPhcI7B7xAV8HW8R8r3pilRvBac OM/DPEuVuf+EFTkMOmPXOcMTFsbJ5DsQslNP2po+4/DfTrysMzz79wF/WLF5vozZyva2 l0bZ+0eVCFdKBQPGk2xI9lSflPSkyHyJefiILmV0oMHtrjRZAOiEwAyfHdQ3mYFb4IST roJQ== X-Gm-Message-State: AOAM5331MgEoxaS9Ph4f0AHk7+M+Aaf7FYruSeBztqZdJgzQQ95iBcEL aO8OwtKSdzUWioktYpOiZ70ZaU1lcc0= X-Google-Smtp-Source: ABdhPJwyIWRi7isoaNyeZXs/Tnl/J+Nx7liiwkN8Qhllw8gMODikAJPYkwbKKHPMNRe9S/VB67VzOA== X-Received: by 2002:adf:a10f:: with SMTP id o15mr1430476wro.286.1632937379468; Wed, 29 Sep 2021 10:42:59 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id 10sm2162288wmi.1.2021.09.29.10.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 10:42:58 -0700 (PDT) Message-ID: <57f1435fd83da8c0e0acaef64d5f08e4ca7b3404.camel@gmail.com> From: Liliana Marie Prikler Date: Wed, 29 Sep 2021 19:42:57 +0200 In-Reply-To: <20210928214044.437-1-attila@lendvai.name> References: <20210928214044.437-1-attila@lendvai.name> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632937458; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=G916XrlrGaXMyLnraJ1g/0J6/icsrjzBUinph+KTLMI=; b=XBwmWhn6UUA5zwO2zTQFBEcNlKpce5pvFDzuWtouqbHzWQiRpZDQhX1ADdnWYZpnTETYx3 YhKAHZ6KJjCmhS5f9QJvhUhP0wtrdfqdtS/DheAAcO4I8eMAhLjl71PudWMRWxgA3YXlRC IzQw0DTyK29jjzP/KQuja+oLEVhPEPeXlcXNNuDqOvq+Gz+acT4tMy2qGfyUXaErlP77IG bLyqRi4klthO4+IXD/ukQIw2zIOkJooNWUgagV8G6Sw0b7EDsbBLnroWAxPbZXiAkgkp3u lHoK1JpynigSzvC5b48HXHPgcJaWmx3/S7u2/TNNrni/mZQgGqnLkVVbkKp5wQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632937458; a=rsa-sha256; cv=none; b=RRQJf4pE6PKyVJupl4lmn1PzqgZHBbCT9kO/KMT3HVfYU0huUsQ8c/pGtw6mJsyOpiZXmU 2+UhXc+EXFj6Hng4OYxrZzy2CW8th7TMblgB0/vUGjbxQGVp5JWZK077AwzA+3S9XTeLnG f/R23oyCnJ5zv7iITktzfpi0d0wzr3FQU+BE8kklhwA6KM+t6bXnF01iO+O0afdTa2uuXN GP/4Mww9d36zi9BEzKbYjYPiXaT4O2erzRpfaYXOZpIjJCmp9M3CB8r/cIJ+H8KVGDReIK rLYgLz7IPWNsdjKSNV/U2f5UHROg0qKW872hrmJgYZ1LCUJL5+TrF3hakwBMYQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="OlQP/dqG"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.30 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="OlQP/dqG"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: DD63689C0 X-Spam-Score: -1.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: P061Gl967kMw Hi, Am Dienstag, den 28.09.2021, 23:40 +0200 schrieb Attila Lendvai: > [...] > index 961ac3298b..747902ec6c 100644 > --- a/guix/build/union.scm > +++ b/guix/build/union.scm > @@ -23,11 +23,12 @@ > #:use-module (ice-9 format) > #:use-module (srfi srfi-1) > #:use-module (srfi srfi-26) > + #:use-module (srfi srfi-43) > #:use-module (rnrs bytevectors) > #:use-module (rnrs io ports) > #:export (union-build > > - warn-about-collision > + default-collision-resolver > > relative-file-name > symlink-relative)) > @@ -102,10 +103,23 @@ 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/alphanumeric-last files) > + ;; Let's do a stable-sort at least, so that multiple foo- > 1.2.3/bin/foo > + ;; variants will predictably resolve to the highest versioned one. > + (let* ((original-files (list->vector files)) > + (count (vector-length original-files)) > + (stripped-files (vector-map (lambda (_ el) > + (strip-store-file-name el)) > + original-files)) > + (indices (vector-unfold values count))) > + (stable-sort! indices > + (lambda (a b) > + (string> (vector-ref stripped-files a) > + (vector-ref stripped-files b)))) > + (vector-ref original-files (vector-ref indices 0)))) Instead of stable-sort!-ing the indices of a vector, what about stable- sort!-ing (map strip-store-file-name original-files) in more or less one go? > +(define (default-collision-resolver files) > + (let ((file (resolve-collision/alphanumeric-last files))) > (unless (member (basename file) %harmless-collisions) > (format (current-error-port) > "~%warning: collision encountered:~%~{ ~a~%~}" > @@ -117,7 +131,7 @@ first one of THEM." > #: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 I don't think the default collision resolver ought to sort the files. The rationale behind ignoring certain collisions, e.g. icon caches relies on the fact that Guix will use the correct files because they are put first in the manifest. The hooks themselves have no special names that could put them "always first" and profiles are themselves union-built. I do however support the addition of sorting methods as collision resolvers in general and would welcome a way of doing so for profiles pre-hook. Regards, Liliana