From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id QASgLzPcbl8nQAAA0tVLHw (envelope-from ) for ; Sat, 26 Sep 2020 06:14:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sLl0KzPcbl9GGQAAbx9fmQ (envelope-from ) for ; Sat, 26 Sep 2020 06:14:11 +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 247A3940291 for ; Sat, 26 Sep 2020 06:14:11 +0000 (UTC) Received: from localhost ([::1]:35282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kM3TG-0006xu-3U for larch@yhetil.org; Sat, 26 Sep 2020 02:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kM3T8-0006xN-LK for guix-patches@gnu.org; Sat, 26 Sep 2020 02:14:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kM3T8-0005p2-C7 for guix-patches@gnu.org; Sat, 26 Sep 2020 02:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kM3T8-0005iX-7S for guix-patches@gnu.org; Sat, 26 Sep 2020 02:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43627] [PATCH core-updates 1/3] guix: Add an append-separator? field to the record. References: <87blhtt6d6.fsf@gmail.com> In-Reply-To: <87blhtt6d6.fsf@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 26 Sep 2020 06:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43627 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43627@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 43627-submit@debbugs.gnu.org id=B43627.160110081521907 (code B ref 43627); Sat, 26 Sep 2020 06:14:02 +0000 Received: (at 43627) by debbugs.gnu.org; 26 Sep 2020 06:13:35 +0000 Received: from localhost ([127.0.0.1]:45650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kM3Sb-0005h7-ES for submit@debbugs.gnu.org; Sat, 26 Sep 2020 02:13:35 -0400 Received: from mail-qv1-f53.google.com ([209.85.219.53]:41563) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kM3SZ-0005gs-7T for 43627@debbugs.gnu.org; Sat, 26 Sep 2020 02:13:28 -0400 Received: by mail-qv1-f53.google.com with SMTP id ef16so2617730qvb.8 for <43627@debbugs.gnu.org>; Fri, 25 Sep 2020 23:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aZQ2N0dTfya4HXmthoOA5nd0tM1fA7pJOTbDNee/wHg=; b=Xw1o+2yV6cIdgk0/rJmUIa5Vf4NMXDOpJi7L7Ad/KiUtliiNtRu/Ewa2a1CTbyCP3J VMstDyvU68fb3DJfWDOJJ/dQ728c1XQDAE5oltT50x/AgRuEdpI28A1/XaSBqSvXyMcr C5ACrlUHOc7dbJRSMlHCvcE610ueXFswH3YsirZmWN9I1Vo4oUjPAZtcpswr5A1uOiue q9SaZt+po9cMInFDLZjDGWXsrtihbNav5TaZjM4sCJ0srUfogFjhoJaSzmrTFgfRFwLv ut2XtfqFWWdkiULEHItR5rS4HkcXxw46+CoRIjGW+Meo7nDnRjBJxp64CBmd56rrcsw9 1SJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aZQ2N0dTfya4HXmthoOA5nd0tM1fA7pJOTbDNee/wHg=; b=QiBA0dAXldzex8K7F0bN+ScFN6Kf2qqolbN5oaejR5Vaex9CzohQ35dlEM4QynrfLu ji0iQ5jQz7KbwP7KpebdnvqzdaMMYZ5q2UdgqfgmQlxEHMxCK71mm4H3mjBXk/nD/daW CZ7rB0K7nl3I3gaWz7ZDBCUd//apmU0mY7BdNDMkp2Nvz/xzl0ypzpxKwJNVzux87asH D9mFyJkf9GFQ3+lLz9ILDphcS+XqwvR+1S+mfadbvqr+Zs1ellyvl51QjaHGKHA5oD2J RMEFxs4K6BKfZql9+MkAa97p2aAWklXmo3qO5V57KWcMfa6A/n850T4g49os+pqZn/rk kcHQ== X-Gm-Message-State: AOAM5311UJ1c/lBMM9KrzMB8R6XPRZBMDiAUyQUeKYBeyMLLh300v1Xg Q6omlFOnIwRp9SjoGqjoNE2k0+hLwKk= X-Google-Smtp-Source: ABdhPJxW49E8IiQaQPm0gQD2SOFopbNstLff4m0qAb0s1xYtFXd0fvXShbU9GHvjQHl1GpATNAXE+Q== X-Received: by 2002:a0c:bd02:: with SMTP id m2mr2310239qvg.0.1601100801304; Fri, 25 Sep 2020 23:13:21 -0700 (PDT) Received: from localhost.localdomain (dsl-10-132-92.b2b2c.ca. [72.10.132.92]) by smtp.gmail.com with ESMTPSA id k20sm3724091qtm.44.2020.09.25.23.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 23:13:20 -0700 (PDT) From: Maxim Cournoyer Date: Sat, 26 Sep 2020 02:14:12 -0400 Message-Id: <20200926061414.7898-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset=yes Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=Xw1o+2yV; 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-Spam-Score: 0.09 X-TUID: 76ve4bLSRlmW This new field allows to specify in a search-path-specification that a trailing separator should be added to the computed value of the environment variable. A trailing separator sometimes has the meaning that the usual builtin locations should be looked up as well as the ones explicitly specified. One use case is to specify the Emacs library paths using EMACSLOADPATH. This allows to not embed the Emacs version in its search path specification, which has been shown to cause issues when upgrading a profile or when defining variant Emacs packages of different versions. * guix/search-paths.scm (searh-path-specification): Add an APPEND-SEPARATOR? field. (search-path-specification->sexp): Adjust accordingly. (sexp->search-path-specification): Likewise. (evaluate-search-paths): Append a separator to the search path value when both `separator' and `append-separator?' are #t. Document the new behavior. * guix/scripts/environment.scm (create-environment): Adjust the logic used to merge search-path values when creating an environment profile. * guix/build/gnu-build-system.scm (set-paths): Adjust accordingly. --- guix/build/gnu-build-system.scm | 11 +++++--- guix/build/profiles.scm | 13 ++++++--- guix/build/utils.scm | 13 +++++++-- guix/scripts/environment.scm | 11 ++++++-- guix/search-paths.scm | 49 +++++++++++++++++++++++---------- 5 files changed, 70 insertions(+), 27 deletions(-) diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index d3347c9518..7039910c79 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2020 Brendan Tildesley +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -96,23 +97,25 @@ See https://reproducible-builds.org/specs/source-date-epoch/." input-directories))) (for-each (match-lambda - ((env-var (files ...) separator type pattern) + ((env-var (files ...) separator type pattern append-sep) (set-path-environment-variable env-var files input-directories #:separator separator #:type type - #:pattern pattern))) + #:pattern pattern + #:append-separator? append-sep))) search-paths) (when native-search-paths ;; Search paths for native inputs, when cross building. (for-each (match-lambda - ((env-var (files ...) separator type pattern) + ((env-var (files ...) separator type pattern append-sep) (set-path-environment-variable env-var files native-input-directories #:separator separator #:type type - #:pattern pattern))) + #:pattern pattern + #:append-separator? append-sep))) native-search-paths)) #t) diff --git a/guix/build/profiles.scm b/guix/build/profiles.scm index 67ee9b665a..035c6558ba 100644 --- a/guix/build/profiles.scm +++ b/guix/build/profiles.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,6 +21,7 @@ #:use-module (guix build union) #:use-module (guix build utils) #:use-module (guix search-paths) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 ftw) #:use-module (ice-9 match) @@ -51,10 +53,13 @@ user-friendly name of the profile is, for instance ~/.guix-profile rather than ((? string? separator) (let ((items (string-tokenize* value separator))) (cons search-path - (string-join (map (lambda (str) - (string-append replacement (crop str))) - items) - separator))))))))) + (string-join + (map (lambda (str) + (string-append replacement (crop str))) + ;; When APPEND-SEPARATOR? is #t, the trailing + ;; separator causes an empty string item. Remove it. + (remove string-null? items)) + separator))))))))) (define (write-environment-variable-definition port) "Write the given environment variable definition to PORT." diff --git a/guix/build/utils.scm b/guix/build/utils.scm index afcb71fae3..0a3f38fc69 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Arun Isaac ;;; Copyright © 2018, 2019 Ricardo Wurmus ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -524,7 +525,8 @@ for under the directories designated by FILES. For example: #:key (separator ":") (type 'directory) - pattern) + pattern + (append-separator? #f)) "Look for each of FILES of the given TYPE (a symbol as returned by 'stat:type') in INPUT-DIRS. Set ENV-VAR to a SEPARATOR-separated path accordingly. Example: @@ -541,11 +543,16 @@ denoting file names to look for under the directories designated by FILES: (list docbook-xml docbook-xsl) #:type 'regular #:pattern \"^catalog\\\\.xml$\") -" + +When both SEPARATOR and APPEND-SEPARATOR? are true, a separator is appended to +the value of the environment variable." (let* ((path (search-path-as-list files input-dirs #:type type #:pattern pattern)) - (value (list->search-path-as-string path separator))) + (value (list->search-path-as-string path separator)) + (value (if append-separator? + (string-append value separator) + value))) (if (string-null? value) (begin ;; Never set ENV-VAR to an empty string because often, the empty diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index ad50281eb2..f3d53c7ae5 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014, 2015, 2018 David Thompson ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2018 Mike Gerwitz +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -80,12 +81,18 @@ variables with additional search paths." (when pure? (purify-environment white-list)) (for-each (match-lambda - ((($ variable _ separator) . value) + ((($ variable _ separator _ + append-separator?) . value) (let ((current (getenv variable))) (setenv variable (if (and current (not pure?)) (if separator - (string-append value separator current) + (if append-separator? + ;; There is already a trailing separator + ;; at the end of value. + ;; (see: `evaluate-search-paths'). + (string-append value current separator) + (string-append value separator current)) value) value))))) (profile-search-paths profile manifest)) diff --git a/guix/search-paths.scm b/guix/search-paths.scm index 002e6342bb..d783a2815f 100644 --- a/guix/search-paths.scm +++ b/guix/search-paths.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2017, 2018 Ludovic Courtès +;;; Copyright © 2020 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -30,6 +31,7 @@ search-path-specification-separator search-path-specification-file-type search-path-specification-file-pattern + search-path-specification-append-separator? $PATH @@ -54,14 +56,16 @@ (define-record-type* search-path-specification make-search-path-specification search-path-specification? - (variable search-path-specification-variable) ;string - (files search-path-specification-files) ;list of strings - (separator search-path-specification-separator ;string | #f - (default ":")) - (file-type search-path-specification-file-type ;symbol - (default 'directory)) - (file-pattern search-path-specification-file-pattern ;#f | string - (default #f))) + (variable search-path-specification-variable) ;string + (files search-path-specification-files) ;list of strings + (separator search-path-specification-separator ;string | #f + (default ":")) + (file-type search-path-specification-file-type ;symbol + (default 'directory)) + (file-pattern search-path-specification-file-pattern ;#f | string + (default #f)) + (append-separator? search-path-specification-append-separator? ;#f | #t + (default #f))) (define $PATH ;; The 'PATH' variable. This variable is a bit special: it is not attached @@ -76,20 +80,32 @@ corresponds to the arguments expected by `set-path-environment-variable'." ;; Note that this sexp format is used both by build systems and in ;; (guix profiles), so think twice before you change it. (match spec - (($ variable files separator type pattern) - `(,variable ,files ,separator ,type ,pattern)))) + (($ variable files separator type pattern + append-separator?) + `(,variable ,files ,separator ,type ,pattern ,append-separator?)))) (define (sexp->search-path-specification sexp) "Convert SEXP, which is as returned by 'search-path-specification->sexp', to a object." (match sexp + ((variable files separator type pattern append-separator?) + (search-path-specification + (variable variable) + (files files) + (separator separator) + (file-type type) + (file-pattern pattern) + (append-separator? append-separator?))) + ;; Previous search-path-specification form (without append-separator? + ;; might still be found in manifest files. ((variable files separator type pattern) (search-path-specification (variable variable) (files files) (separator separator) (file-type type) - (file-pattern pattern))))) + (file-pattern pattern) + (append-separator? #f))))) (define-syntax-rule (with-null-error-port exp) "Evaluate EXP with the error port pointing to the bit bucket." @@ -131,7 +147,9 @@ like `string-tokenize', but SEPARATOR is a string." "Evaluate SEARCH-PATHS, a list of search-path specifications, for DIRECTORIES, a list of directory names, and return a list of specification/value pairs. Use GETENV to determine the current settings and -report only settings not already effective." +report only settings not already effective. When the search path +specification APPEND-SEPARATOR? and SEPARATOR fields are both set to true, a +separator is appended to its computed value." (define (search-path-definition spec) (match spec (($ variable files #f type pattern) @@ -148,7 +166,7 @@ report only settings not already effective." #f ;VARIABLE already set appropriately (cons spec head)))))) (($ variable files separator - type pattern) + type pattern append-separator?) (let* ((values (or (and=> (getenv variable) (cut string-tokenize* <> separator)) '())) @@ -161,7 +179,10 @@ report only settings not already effective." #:pattern pattern)))) (if (every (cut member <> values) path) #f ;VARIABLE is already set appropriately - (cons spec (string-join path separator))))))) + (let ((value (string-join path separator))) + (cons spec (if append-separator? + (string-append value separator) + value)))))))) (filter-map search-path-definition search-paths)) -- 2.28.0