From patchwork Sun Oct 3 12:43:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33589 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id E82D027BBE3; Sun, 3 Oct 2021 13:44:35 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B8A7D27BBE1 for ; Sun, 3 Oct 2021 13:44:35 +0100 (BST) Received: from localhost ([::1]:37068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX0r4-00070y-RL for patchwork@mira.cbaines.net; Sun, 03 Oct 2021 08:44:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX0qY-0006iD-8C for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX0qY-0000uA-0G for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mX0qX-0006Ir-Tu for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH 1/4] guix: build: Promote local define-inline to a define-constant util. References: <20210928214044.437-1-attila@lendvai.name> In-Reply-To: <20210928214044.437-1-attila@lendvai.name> Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 03 Oct 2021 12:44:01 +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: 50878@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.163326501724164 (code B ref 50878); Sun, 03 Oct 2021 12:44:01 +0000 Received: (at 50878) by debbugs.gnu.org; 3 Oct 2021 12:43:37 +0000 Received: from localhost ([127.0.0.1]:33096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0q9-0006Hf-AP for submit@debbugs.gnu.org; Sun, 03 Oct 2021 08:43:37 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:44812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0q4-0006HQ-In for 50878@debbugs.gnu.org; Sun, 03 Oct 2021 08:43:37 -0400 Received: by mail-wr1-f41.google.com with SMTP id d6so24926620wrc.11 for <50878@debbugs.gnu.org>; Sun, 03 Oct 2021 05:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MusHtuw/9wxb7MJDhJo1+iJh4W7M+pquI/8vKYVGtnU=; b=iX8Yu9Xz5MqNsHrLnFZBf/PrN4JlFOBC52gJ554F4mf1JQqR1MMyU5ok/vAeaVMJ06 igDCPuUBCtlLB6KwKgXYlr5/nkm2IwDImDx1+DDD0rvlKPrYxTnkJLWsGLLVplJUYYYV weUPKiLihvkpYNEwGUrJt5MuaPSRLLQvYqqLqZ7GLH8mO7FMiOLlSACQ/EOclsDhmCp1 lNy/WSn1ShzHL2O9ML9+nIzOEYIqIw+W5+29rG4k0Io+i5vl2J4Fh44/jJT5wjtrXenE z6pFlK6R0ndlCJbSYxYXySxUGB22ZJLi7oCYBflJZ0zPD0joF0f9E+sVdgKsy3fQ+zfk QqHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=MusHtuw/9wxb7MJDhJo1+iJh4W7M+pquI/8vKYVGtnU=; b=GYKYeBV805LE6pCkWQwDueILt6PjLPK8fp9m+KCbuGfChNyebnueQTmpXtKHkdNTOA vv8aL/7zC6k77fvUo4ciXsnc+jgmn8+GLiaeo35i1rbueVM+bQZjUyXL0w47b0IXNDW9 xSOjmb0rd8UOGb+xDWafsQTg398EabRj6krdTv+JlJXXNbxz/YkLdZ4ozdJVvB5Z5d2z PAITY/LpL9aMEU+PkZ3R7WgGy5v55GQE75qyyLpYWTwV10D1yT2T4wR5Krv4hXmfdckF KPavOyhp6ieEkZhEM7uZEiCjYKaUZEWDOKdPkoZAgigeB0aULPDJF/GmaQUbf9PnDK3s U7OQ== X-Gm-Message-State: AOAM533Enp+TGFmO7QxGdNKWlCOsXsjUux6+ju/Af2D5g8Ct1unUZqDD U1dStA3Qfhol8Xa5AyrZLqAE8V3a6Oo= X-Google-Smtp-Source: ABdhPJyYCqNGouxSTvCxEGVNLRPoM1vIPRe5mNjpvtJiN234GqIIvBF2oxN5cZLKfq8D+3IQ/KyHOQ== X-Received: by 2002:a05:6000:168b:: with SMTP id y11mr8346313wrd.350.1633265006473; Sun, 03 Oct 2021 05:43:26 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id v10sm11800474wri.29.2021.10.03.05.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:43:25 -0700 (PDT) From: Attila Lendvai Date: Sun, 3 Oct 2021 14:43:00 +0200 Message-Id: <20211003124303.8277-1-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/build/utils.scm: Moved/renamed define-inline from grafts.scm to an exported define-constant util. --- guix/build/graft.scm | 5 +---- guix/build/utils.scm | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/guix/build/graft.scm b/guix/build/graft.scm index f04c35fa74..daac958d4f 100644 --- a/guix/build/graft.scm +++ b/guix/build/graft.scm @@ -44,10 +44,7 @@ ;;; ;;; Code: -(define-syntax-rule (define-inline name val) - (define-syntax name (identifier-syntax val))) - -(define-inline hash-length 32) +(define-constant hash-length 32) (define nix-base32-char? (cute char-set-contains? diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 419c10195b..f3d913aa70 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -73,6 +73,8 @@ list->search-path-as-string which + define-constant + every* alist-cons-before alist-cons-after @@ -112,6 +114,16 @@ locale-category->string)) + +;;; +;;; Syntax +;;; + +;; Note that in its current form VAL doesn't get evaluated, just simply +;; inlined. TODO? +(define-syntax-rule (define-constant name val) + (define-syntax name (identifier-syntax val))) + ;;; ;;; Guile 2.0 compatibility later. From patchwork Sun Oct 3 12:43:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33587 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1F30927BBE3; Sun, 3 Oct 2021 13:44:26 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D91CA27BBE1 for ; Sun, 3 Oct 2021 13:44:25 +0100 (BST) Received: from localhost ([::1]:36666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX0qu-0006ig-1l for patchwork@mira.cbaines.net; Sun, 03 Oct 2021 08:44:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41894) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX0qY-0006iE-Kp for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX0qY-0000v3-DV for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mX0qY-0006Iz-Ba for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH 2/4] guix: build: Avoid using magic literals in the code for hash length. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 03 Oct 2021 12: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: 50878@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.163326502124180 (code B ref 50878); Sun, 03 Oct 2021 12:44:02 +0000 Received: (at 50878) by debbugs.gnu.org; 3 Oct 2021 12:43:41 +0000 Received: from localhost ([127.0.0.1]:33099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0qD-0006Hw-Jp for submit@debbugs.gnu.org; Sun, 03 Oct 2021 08:43:41 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:42705) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0qB-0006HX-P2 for 50878@debbugs.gnu.org; Sun, 03 Oct 2021 08:43:40 -0400 Received: by mail-wr1-f49.google.com with SMTP id v17so24963354wrv.9 for <50878@debbugs.gnu.org>; Sun, 03 Oct 2021 05:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uqZpcjgK26RLLT/WLa+olTb/Q4pV96js45ePYWQnTfI=; b=bg+EurDb+8CLS73wQ4Fk1O94z2VCyl03Nhwc1wXSK+gNRIXo2jJy2FUZxxrI1AqTJm kT2KgHV8GRSNcH0q6PMKAyKrpP62b7ZL4EZFgk90m9ccVC5RAoK9syne9RRyhYlz0B3l AGtkAqsvW6cLLjdwhqOgqqrlDusWMiHCTv+X0/JRGJm5orlJUSCwhJZgFLRNtx0VCZPx cVxFWCWFc0O/1qhV4K98w1la/N2L1jn1cHdAPqEWQD0iC2TPUCq9Cldb9duGZypeP5Jj nDicRe5ZCWmCrksrwjaDkz8FHVT9EVRO+57xj+gN44hmI1yPPG0uKVnPdaqdNq2MV11b Go0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=uqZpcjgK26RLLT/WLa+olTb/Q4pV96js45ePYWQnTfI=; b=0wIU1o+20TekbNVaH37vqCkVAHawY290lugRgImd/gtJfzQ8CIRjNMLSdYnpM3+y4T bRoCjrRR1Dt4mB9+5AVXVc0kAbXzQD3zL4o+7jNRgJ4sPOQj95F1YsdLkqIZW6T2vjy6 e2G6+BS6Mxueold3MXS3hYvxo1ACy6mXlG0dhmNgD4xO2Cmkdp/IMcnsutiL+d6CP5mC fzgZZ6WWxdzmxRlC3oO3PnGJYacl0gYd1H5aqZElacUITii6vsruZSINS8jagrKYvUDt 42QjA7TNl+BHK7Nu+fbRpMVal8baCG9bNwDl4AxgUJq51D4cr+2s6X6Rrd/z92t1/FAX 8Mnw== X-Gm-Message-State: AOAM531pgBVCrjJKfVrOZYavgQius/bIzJ1Jxs5f5HRW7aVph5E957AU zU0carup4d/dBcQ268sCS+blehtEhCk= X-Google-Smtp-Source: ABdhPJwyD56BtOvKHklNLHykixhFxgNsdsIgCPWYcqy0aLJ3NAP7jv0OPYXkBgRHmBSszPOV5mnElw== X-Received: by 2002:a5d:49c5:: with SMTP id t5mr8561843wrs.295.1633265014109; Sun, 03 Oct 2021 05:43:34 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id v10sm11800474wri.29.2021.10.03.05.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:43:33 -0700 (PDT) From: Attila Lendvai Date: Sun, 3 Oct 2021 14:43:01 +0200 Message-Id: <20211003124303.8277-2-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211003124303.8277-1-attila@lendvai.name> References: <20211003124303.8277-1-attila@lendvai.name> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/build/utils.scm (%store-hash-string-length): New constant. (store-path-prefix-length): Factor out the calculation of the total store prefix length. * guix/build/graft.scm (hash-length): Use it. --- guix/build/graft.scm | 2 +- guix/build/utils.scm | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/guix/build/graft.scm b/guix/build/graft.scm index daac958d4f..281dbaba6f 100644 --- a/guix/build/graft.scm +++ b/guix/build/graft.scm @@ -44,7 +44,7 @@ ;;; ;;; Code: -(define-constant hash-length 32) +(define-constant hash-length %store-hash-string-length) (define nix-base32-char? (cute char-set-contains? diff --git a/guix/build/utils.scm b/guix/build/utils.scm index f3d913aa70..4009c137b8 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -44,6 +44,7 @@ ;; . delete) #:export (%store-directory + %store-hash-string-length store-file-name? strip-store-file-name package-name->name+version @@ -154,15 +155,21 @@ (or (getenv "NIX_STORE") "/gnu/store")) +(define-constant %store-hash-string-length 32) + (define (store-file-name? file) "Return true if FILE is in the store." (string-prefix? (%store-directory) file)) +(define (store-path-prefix-length) + (+ 2 ; the slash after %store-directory, and the dash after the hash + (string-length (%store-directory)) + %store-hash-string-length)) + (define (strip-store-file-name file) "Strip the '/gnu/store' and hash from FILE, a store file name. The result is typically a \"PACKAGE-VERSION\" string." - (string-drop file - (+ 34 (string-length (%store-directory))))) + (string-drop file (store-path-prefix-length))) (define (package-name->name+version name) "Given NAME, a package name like \"foo-0.9.1b\", return two values: From patchwork Sun Oct 3 12:43:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33588 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 67C6B27BBE3; Sun, 3 Oct 2021 13:44:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 034FD27BBE1 for ; Sun, 3 Oct 2021 13:44:28 +0100 (BST) Received: from localhost ([::1]:36672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX0qx-0006jO-4A for patchwork@mira.cbaines.net; Sun, 03 Oct 2021 08:44:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX0qZ-0006iF-1M for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49791) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX0qY-0000v9-QW for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mX0qY-0006J6-OL for guix-patches@gnu.org; Sun, 03 Oct 2021 08:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH 3/4] guix: build: Factor out and export default-collision-resolver. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 03 Oct 2021 12: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: 50878@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.163326502824202 (code B ref 50878); Sun, 03 Oct 2021 12:44:02 +0000 Received: (at 50878) by debbugs.gnu.org; 3 Oct 2021 12:43:48 +0000 Received: from localhost ([127.0.0.1]:33102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0qJ-0006II-Sb for submit@debbugs.gnu.org; Sun, 03 Oct 2021 08:43:48 -0400 Received: from mail-wr1-f45.google.com ([209.85.221.45]:34628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0qI-0006Hv-B0 for 50878@debbugs.gnu.org; Sun, 03 Oct 2021 08:43:46 -0400 Received: by mail-wr1-f45.google.com with SMTP id t8so25060566wri.1 for <50878@debbugs.gnu.org>; Sun, 03 Oct 2021 05:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cocJj1Sw5JY/LTYomCQ01cjJM+cMkLPQpUHzTmM6/lM=; b=orergwOWwXIfFEXiJS+Dc1q4HcO1hwW77wvoVh3750UnU51QU/ArdIEEqHFnSI5c1K ZloCRq4j1av1gmZp3UlexjXjUewQ/wFTDyF6MkMXIb8BKwJ5TexPD0tiztOWDxJ4uXax X2CeuIUV36LWIi81hRUevB7GlgCf+wnnAEKuODOQxfTOLkxMZDnpxHnetHaFYbqqCLkB ddbCGpcn/g+JG+2BEx1mALYmxKc2V6AhdfmWV9QWJs1DuCTUlI/vYjBksM4K4T7tB9LR FyKyoFzFDzSPC8hF4dMTR5tVFTNgeb/fLFZPrabstaYQakU8dOIGWxWJySgxLbxFwANh 9bxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cocJj1Sw5JY/LTYomCQ01cjJM+cMkLPQpUHzTmM6/lM=; b=tffNXr1z6lQvdgsglzCmH08o3aqrsYHlrVuEI56v5PedMtdVCItg9vCy5hPayTkXJa PeDHne9a4MrmrkEsd9r+BsJ2YM9LY/HGVZWZsv5ybCkIBACQ/W5niVqdxnMrjNbAvlcV aYLTblQFINwfrGrxVNDjTax6ARUiNpVEeJwPqUhwFA27g6a1acCAJpRXMwCxZhMrEz1P vn7VZUytYEpBBvR9dME23/94GPeXppZfm1zwdoK5+aAu0U6r14DafBFMvNVodALQab28 ibS0hoM7evbOndWK8+ubzaJMFxhf1drehLahWwChU5bZGGMjnyOy7lDgV3BqedNxJaep zy+w== X-Gm-Message-State: AOAM533OQet2xcz3tnfXxoLiehwjNvsoLJ/jARh6O1D+bMS5GC7oK1gj CXhTVrRKZvdeWCSfn0XaRAI0T4odZhY= X-Google-Smtp-Source: ABdhPJy9tZZe+A/b1PximlwVCnvyKvvJz9+P+o2owihwdYFbY1A8GZ44t2O13UBVRX6gTUEYd9OwEA== X-Received: by 2002:adf:9bd3:: with SMTP id e19mr8569555wrc.167.1633265020705; Sun, 03 Oct 2021 05:43:40 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id v10sm11800474wri.29.2021.10.03.05.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:43:40 -0700 (PDT) From: Attila Lendvai Date: Sun, 3 Oct 2021 14:43:02 +0200 Message-Id: <20211003124303.8277-3-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211003124303.8277-1-attila@lendvai.name> References: <20211003124303.8277-1-attila@lendvai.name> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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: From patchwork Sun Oct 3 12:43:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Attila Lendvai X-Patchwork-Id: 33590 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5DF7727BBE3; Sun, 3 Oct 2021 13:48:14 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E035127BBE1 for ; Sun, 3 Oct 2021 13:48:13 +0100 (BST) Received: from localhost ([::1]:37868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mX0ub-0007qP-2C for patchwork@mira.cbaines.net; Sun, 03 Oct 2021 08:48:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mX0uQ-0007pf-KX for guix-patches@gnu.org; Sun, 03 Oct 2021 08:48:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mX0uQ-0002ra-Ca for guix-patches@gnu.org; Sun, 03 Oct 2021 08:48:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mX0uQ-0006RB-54 for guix-patches@gnu.org; Sun, 03 Oct 2021 08:48:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50878] [PATCH 4/4] WIP guix: build: Add resolve-collision/alphanumeric-last for union. Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 03 Oct 2021 12:48: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: 50878@debbugs.gnu.org Cc: Attila Lendvai Received: via spool by 50878-submit@debbugs.gnu.org id=B50878.163326524824647 (code B ref 50878); Sun, 03 Oct 2021 12:48:02 +0000 Received: (at 50878) by debbugs.gnu.org; 3 Oct 2021 12:47:28 +0000 Received: from localhost ([127.0.0.1]:33108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0ts-0006PS-EC for submit@debbugs.gnu.org; Sun, 03 Oct 2021 08:47:28 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]:46691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mX0tq-0006OW-0m for 50878@debbugs.gnu.org; Sun, 03 Oct 2021 08:47:26 -0400 Received: by mail-wm1-f47.google.com with SMTP id o4-20020a05600c510400b0030d55d6449fso3932974wms.5 for <50878@debbugs.gnu.org>; Sun, 03 Oct 2021 05:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GULd65ZGeXU31ROJ5+3A5vd+eTGKJ4KXxxwFe/EnGGg=; b=j0hX+CrdGUn20LCb+BYmBEGATyHKLo5kHfU66/u4SBt1qlMSsU3I65mLssIMCAfjxi +1294+RUivegwps6G5xURObn5AUpHsvWPJltL2o/87JKSuBtf6zJwMRCp5NGguO1UNsc UgQ+UNZmTMiFM7ewCPbSmjYJGu38EfTMGsJLtShnC+C+ZtB4fAs3awVyPngDsQlOJjVm /clidIip+WAFsyrxnolotOfnlVTl/8NACasmikEjq4F/a+2Fhy5o3j93Y0b9mhf4LXKl 9mnqi7wJYxwQ8d15OZEcKgcjpeO7Xwrdz4hB2X4jPVIYMjZZAT0oGwvyUsABKRe0GTfP TFMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=GULd65ZGeXU31ROJ5+3A5vd+eTGKJ4KXxxwFe/EnGGg=; b=DV/A8JErtgQw3Bo3GSRa6l78Mwy2TCTmeSh9oyCkTwiZINMRUxYu7qiT6tqP3zyAWu 3MatYpnSxAWyJ7Esv0GrpYnMDZgt7WRtQ0qQwh2btkbg/BiMFUyNknpB3g7wVDhZuCVN 71Yj5L8wd/cRmpF/y/wg1kkgbTamzCC7vPMtNrj5r/5ycVv1eRoWS3uBQsQxnLrvqtod tKCOb2pJut0aa9z2OahIV9btqZistl625KEv0YrgI2mtxUisbt/2rGzD8cgQX7cFMvSM tlKxHA9Fge0VvtyUyQWD+O/2JMPqY9fbcfpQo/msDTe24rzM4t9YNpcYdrYOHVmNvanP hFvw== X-Gm-Message-State: AOAM531226kEqNSqfSwAdla2lFciGWJVcFsFqrqKzJcztuS37xd7oxtd PHJsJSn8mZfZjRIf64rdYh2m/PN4y/4= X-Google-Smtp-Source: ABdhPJw1u9Ld71yE/z01fLWezRth9tOpqDXWQZZB/MogblmXFv/4qkgaJdTp3M8yRuL0hOOXFaYx0w== X-Received: by 2002:a7b:c048:: with SMTP id u8mr13514436wmc.113.1633265240097; Sun, 03 Oct 2021 05:47:20 -0700 (PDT) Received: from lelap.lan (catv-213-222-131-28.catv.broadband.hu. [213.222.131.28]) by smtp.gmail.com with ESMTPSA id v10sm11800474wri.29.2021.10.03.05.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 05:47:19 -0700 (PDT) From: Attila Lendvai Date: Sun, 3 Oct 2021 14:43:04 +0200 Message-Id: <20211003124303.8277-4-attila@lendvai.name> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211003124303.8277-1-attila@lendvai.name> References: <20211003124303.8277-1-attila@lendvai.name> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches It is currently not used anywhere, only exported. The tests are boken, because guile is too old in the test environment, at least on 'x86_64-linux' (guile 2.0.9 doesn't have srfi-43, aka vectors). Probably it's also broken because testing errors with `no code for module (guix build utils)`. * guix/build/union.scm (resolve-collision/alphanumeric-last): New function. * guix/build/utils.scm (compare-strings-ignoring-store-path-prefix): New function. --- I think the previous 3 patches in this patchset are worthy of inclusion, but this one is more of a good idea than a worked out change, to be picked up later, if at all. The primary issue is that the test framework uses a guile that is too old, but it's also not used anywhere. It would be nice if this was used for resolving conflicts for profiles, i.e. for the user's bin/ directory. guix/build/union.scm | 12 ++++++++++++ guix/build/utils.scm | 27 +++++++++++++++++++++++++++ tests/union.scm | 9 +++++++++ 3 files changed, 48 insertions(+) diff --git a/guix/build/union.scm b/guix/build/union.scm index 9e8c2af4f5..339af7576c 100644 --- a/guix/build/union.scm +++ b/guix/build/union.scm @@ -19,15 +19,18 @@ ;;; along with GNU Guix. If not, see . (define-module (guix build union) + #:use-module (guix build utils) #:use-module (ice-9 match) #: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 default-collision-resolver + resolve-collision/alphanumeric-last relative-file-name symlink-relative)) @@ -102,6 +105,15 @@ identical, #f otherwise." ;; applications via 'glib-or-gtk-build-system'. '("icon-theme.cache" "gschemas.compiled")) +(define (resolve-collision/alphanumeric-last files) + ;; Let's do a stable-sort, so that multiple foo-1.2.3/bin/foo variants will + ;; predictably resolve to the highest versioned one. + (let ((files-vector (list->vector files))) + (stable-sort! files-vector + (lambda (a b) + (> 0 (compare-strings-ignoring-store-path-prefix a b)))) + (vector-ref files-vector 0))) + (define (resolve-collision/pick-first files) (first files)) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index 4009c137b8..1ae0244b04 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -47,6 +47,7 @@ %store-hash-string-length store-file-name? strip-store-file-name + compare-strings-ignoring-store-path-prefix package-name->name+version parallel-job-count @@ -171,6 +172,32 @@ is typically a \"PACKAGE-VERSION\" string." (string-drop file (store-path-prefix-length))) +(define (compare-strings-ignoring-store-path-prefix a b) + (let ((a-length (string-length a)) + (b-length (string-length b))) + (do ((i (store-path-prefix-length) (+ i 1))) + ((not (and (< i a-length) + (< i b-length) + (char=? (string-ref a i) + (string-ref b i)))) + (cond + ((= a-length b-length) + (if (= i a-length) ; we reached the end without any difference + 0 + (- (char->integer (string-ref a i)) + (char->integer (string-ref b i))))) + ((> a-length b-length) + (if (= i b-length) ; we reached the end of B without a difference + 1 + (- (char->integer (string-ref a i)) + (char->integer (string-ref b i))))) + (else ; i.e. (< a-length b-length) + (if (= i a-length) ; we reached the end of A without a difference + -1 + (- (char->integer (string-ref a i)) + (char->integer (string-ref b i))))))) + '()))) + (define (package-name->name+version name) "Given NAME, a package name like \"foo-0.9.1b\", return two values: \"foo\" and \"0.9.1b\". When the version part is unavailable, NAME and diff --git a/tests/union.scm b/tests/union.scm index a8387edf42..cbf8840793 100644 --- a/tests/union.scm +++ b/tests/union.scm @@ -204,4 +204,13 @@ ("/a/b" "/a/b/c/d" => "c/d") ("/a/b/c" "/a/d/e/f" => "../../d/e/f"))) +(test-assert "resolve-collision/alphanumeric-last sorts alphanumerically" + (string= + ((@@ (guix build union) resolve-collision/alphanumeric-last) + (list "/gnu/store/c0000000000000000000000000000000-idris-0.0.0/bin/idris" + "/gnu/store/60000000000000000000000000000000-idris-2.0.0/bin/idris" + "/gnu/store/z0000000000000000000000000000000-idris-1.3.5/bin/idris" + "/gnu/store/00000000000000000000000000000000-idris-1.3.3/bin/idris")) + "/gnu/store/60000000000000000000000000000000-idris-2.0.0/bin/idris")) + (test-end)