GNU logs - #70829, boring messages


Message sent to guix@HIDDEN, pelzflorian@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#70829] [PATCH] guix: gexp: Add assume-source-relative-file-name
Resent-From: Richard Sent <richard@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, pelzflorian@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Wed, 08 May 2024 12:19:01 +0000
Resent-Message-ID: <handler.70829.B.171517072310793 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 70829
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 70829 <at> debbugs.gnu.org
Cc: Richard Sent <richard@HIDDEN>, Christopher Baines <guix@HIDDEN>, Florian Pelz <pelzflorian@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Florian Pelz <pelzflorian@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.171517072310793
          (code B ref -1); Wed, 08 May 2024 12:19:01 +0000
Received: (at submit) by debbugs.gnu.org; 8 May 2024 12:18:43 +0000
Received: from localhost ([127.0.0.1]:48579 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1s4gFu-0002o1-JJ
	for submit <at> debbugs.gnu.org; Wed, 08 May 2024 08:18:43 -0400
Received: from lists.gnu.org ([2001:470:142::17]:46438)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <richard@HIDDEN>) id 1s4gFr-0002nj-SC
 for submit <at> debbugs.gnu.org; Wed, 08 May 2024 08:18:41 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <richard@HIDDEN>)
 id 1s4gFJ-00023P-R5
 for guix-patches@HIDDEN; Wed, 08 May 2024 08:18:06 -0400
Received: from mail-108-mta241.mxroute.com ([136.175.108.241])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <richard@HIDDEN>)
 id 1s4gF0-0006Tz-Hz
 for guix-patches@HIDDEN; Wed, 08 May 2024 08:18:05 -0400
Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com)
 (Authenticated sender: mN4UYu2MZsgR)
 by mail-108-mta241.mxroute.com (ZoneMTA) with ESMTPSA id
 18f58234b090008ca2.001 for <guix-patches@HIDDEN>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Wed, 08 May 2024 12:17:39 +0000
X-Zone-Loop: f24c586c5477e6a6c9d25b18f3c773576a89945ed7f4
X-Originating-IP: [136.175.111.2]
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version:
 Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=A/b04iMHYk5hzXF3qnMQmQb2OAak6jwSM9cnhQ7+6hw=; b=Ci0kNQcollpJkw4wy+BuURBmhq
 9GhEargLzWZ+VHpd25Yv6KThtmU+zwDiMe/RdjLGF8QTMFK6+b7bY5tEm5retS7XV8Af4hTJCjl+A
 CD0HGgFXWy7nJxoCxvuZzetbkSQiSMBdF88J4hj/S3FF1VL6vZXqScUeB7p+F58MjWKFeZMxXVYdV
 PfziwgI2T3P/o9bGGgTiZg90kLoWd5++Br5o1Sbl3GgCR9NoV0j4MRSrjIK+pcLQXtuBYWKvQOLm4
 zs9HRDVgDvt8bmOWAhbDukwD5HgiWSsrSzlXsNcOmHX04LyOOBbexlDGGtUjNNnP6GtpFBQ+KVtGX
 Mlqb5XUA==;
From: Richard Sent <richard@HIDDEN>
Date: Wed,  8 May 2024 08:15:17 -0400
Message-ID: <c4afb74adfc96591f9723c91eecf6a4c6330da28.1715170517.git.richard@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Authenticated-Id: richard@HIDDEN
Received-SPF: pass client-ip=136.175.108.241;
 envelope-from=richard@HIDDEN; helo=mail-108-mta241.mxroute.com
X-Spam_score_int: -16
X-Spam_score: -1.7
X-Spam_bar: -
X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1,
 DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
(local-file): Use assume-source-relative-file-name to look up a non-literal
file relative to the current source directory.
doc/guix.texi (G-expressions): Document it.
tests: gexp.scm: Test it.
---
Hi Guix!

In the current local file setup is it is impossible to use
(local-file) with a non-literal source-relative file name. With this
patch, it is possible.

 doc/guix.texi  |  5 +++++
 guix/gexp.scm  | 15 ++++++++++++++-
 tests/gexp.scm |  6 ++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 221db5c022..1fc7be7cd8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12166,6 +12166,11 @@ G-Expressions
 (local-file (assume-valid-file-name alice-key-file-path))
 @end lisp
 
+@var{file} can be wrapped in the @code{assume-source-relative-file-name}
+syntactic keyword.  When this is done, the file name will be looked up
+relative to the source file where it appears even when it is not a
+string literal.
+
 This is the declarative counterpart of the @code{interned-file} monadic
 procedure (@pxref{The Store Monad, @code{interned-file}}).
 @end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 74b4c49f90..871e59cfdc 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -52,6 +52,7 @@ (define-module (guix gexp)
             gexp-input-native?
 
             assume-valid-file-name
+            assume-source-relative-file-name
             local-file
             local-file?
             local-file-file
@@ -485,6 +486,12 @@ (define-syntax-rule (assume-valid-file-name file)
 warn about it."
   file)
 
+(define-syntax-rule (assume-source-relative-file-name file)
+  "This is a syntactic keyword to tell 'local-file' that it can assume that
+the given file is relative to the source directory, even if it's not a string
+literal."
+  file)
+
 (define-syntax local-file
   (lambda (s)
     "Return an object representing local file FILE to add to the store; this
@@ -503,13 +510,19 @@ (define-syntax local-file
 This is the declarative counterpart of the 'interned-file' monadic procedure.
 It is implemented as a macro to capture the current source directory where it
 appears."
-    (syntax-case s (assume-valid-file-name)
+    (syntax-case s (assume-valid-file-name assume-source-relative-file-name)
       ((_ file rest ...)
        (string? (syntax->datum #'file))
        ;; FILE is a literal, so resolve it relative to the source directory.
        #'(%local-file file
                       (delay (absolute-file-name file (current-source-directory)))
                       rest ...))
+      ((_ (assume-source-relative-file-name file) rest ...)
+       ;; FILE is not a literal, but the user requested we look it up
+       ;; relative to the current source directory.
+       #'(%local-file file
+                      (delay (absolute-file-name file (current-source-directory)))
+                      rest ...))
       ((_ (assume-valid-file-name file) rest ...)
        ;; FILE is not a literal, so resolve it relative to the current
        ;; directory.  Since the user declared FILE is valid, do not pass
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 905009caee..8774097bd0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -244,6 +244,12 @@ (define %extension-package
       (let ((file (local-file (string-copy "../base32.scm"))))
         (local-file-absolute-file-name file)))))
 
+(test-equal "local-file, non-literal source relative file name"
+  (current-filename)
+  (let ((file (local-file (assume-source-relative-file-name
+                           (string-append "gexp" ".scm")))))
+    (local-file-absolute-file-name file)))
+
 (test-assert "local-file, relative file name, within gexp"
   (let* ((file     (search-path %load-path "guix/base32.scm"))
          (interned (add-to-store %store "base32.scm" #f "sha256" file)))

base-commit: da41a8f5e85774e2a507d821b5d52e600fb9d1d7
prerequisite-patch-id: 5c8bedc278ab541b86ee4af63042a5893109639e
-- 
2.41.0





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Richard Sent <richard@HIDDEN>
Subject: bug#70829: Acknowledgement ([PATCH] guix: gexp: Add
 assume-source-relative-file-name)
Message-ID: <handler.70829.B.171517072310793.ack <at> debbugs.gnu.org>
References: <c4afb74adfc96591f9723c91eecf6a4c6330da28.1715170517.git.richard@HIDDEN>
X-Gnu-PR-Message: ack 70829
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 70829 <at> debbugs.gnu.org
Date: Wed, 08 May 2024 12:19:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

As you requested using X-Debbugs-CC, your message was also forwarded to
  Christopher Baines <guix@HIDDEN>, Florian Pelz <pelzflorian@pelzflor=
ian.de>, Josselin Poiret <dev@HIDDEN>, Ludovic Court=C3=A8s <ludo@gnu.=
org>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN=
et>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@t=
obias.gr>
(after having been given a bug report number, if it did not have one).

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 70829 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
70829: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D70829
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to pelzflorian@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#70829] [PATCH v2 1/2] doc: Document assume-valid-file-name in local-file
References: <c4afb74adfc96591f9723c91eecf6a4c6330da28.1715170517.git.richard@HIDDEN>
In-Reply-To: <c4afb74adfc96591f9723c91eecf6a4c6330da28.1715170517.git.richard@HIDDEN>
Resent-From: Richard Sent <richard@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: pelzflorian@HIDDEN, ludo@HIDDEN, guix-patches@HIDDEN
Resent-Date: Wed, 08 May 2024 18:35:01 +0000
Resent-Message-ID: <handler.70829.B70829.171519329327717 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 70829
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 70829 <at> debbugs.gnu.org
Cc: Richard Sent <richard@HIDDEN>, Florian Pelz <pelzflorian@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
X-Debbugs-Original-Xcc: Florian Pelz <pelzflorian@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Received: via spool by 70829-submit <at> debbugs.gnu.org id=B70829.171519329327717
          (code B ref 70829); Wed, 08 May 2024 18:35:01 +0000
Received: (at 70829) by debbugs.gnu.org; 8 May 2024 18:34:53 +0000
Received: from localhost ([127.0.0.1]:50200 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1s4m7w-0007Cz-Jg
	for submit <at> debbugs.gnu.org; Wed, 08 May 2024 14:34:52 -0400
Received: from mail-108-mta133.mxroute.com ([136.175.108.133]:44309)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <richard@HIDDEN>) id 1s4m7u-0007Ct-7y
 for 70829 <at> debbugs.gnu.org; Wed, 08 May 2024 14:34:51 -0400
Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com)
 (Authenticated sender: mN4UYu2MZsgR)
 by mail-108-mta133.mxroute.com (ZoneMTA) with ESMTPSA id
 18f597c2efd0008ca2.001 for <70829 <at> debbugs.gnu.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Wed, 08 May 2024 18:34:21 +0000
X-Zone-Loop: 2f01149c2e27682e8851b09fc15998b3fa99407a80c4
X-Originating-IP: [136.175.111.2]
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version:
 Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=5EpOFjh9Kf5sg43uVarK9Xk/XGf8vhABgrttwJpMsW0=; b=T/7slP/5obo2b9l1zK3p6qzyPp
 L+b7l1cG7kSm8o9M6xTlINCEpddp726zwTF2ZUqXTtWTA22E7YMf35zT9pYlZsZAiWdve2U7MtM64
 gOfWbWaEkwBzzJWl7vz5x9jIfqjQgJs6plffru2ozx6mzn58VSCPBA+LhMRT0hK4K8cQMPkggU19D
 IEFIRvVYZemEPFaHSRcw5RvzApEE+Ho2PD+TV7/yg+/8k3vwYvEsmBYQ5l6RErLFZYDxuA7lO4JBL
 5TQQ0oKPJgN3U7t6256PvmHv3rTpcC0whUj02wVlfB8UmwBVxV66bHgHPODKOag8HDl5O4vCug2yG
 2/MS0Now==;
From: Richard Sent <richard@HIDDEN>
Date: Wed,  8 May 2024 14:32:46 -0400
Message-ID: <23ca145e6087ea18559fdd71d0c92db572abc8a3.1715193167.git.richard@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Authenticated-Id: richard@HIDDEN
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

doc/guix.texi (G-Expressions): Document the use of assume-valid-file-name with
local-file.
---

Missed a commit that my original revision depended on. I initially
submitted that previous commit to https://qa.guix.gnu.org/issue/70830,
but since both commits change the same guix.texi section on similar
subject matter, I'm resubmitting as a series.

 doc/guix.texi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1c1e0164e7..221db5c022 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12154,6 +12154,18 @@ G-Expressions
 absolute file name and @var{stat} is the result of @code{lstat}; exclude
 entries for which @var{select?} does not return true.
 
+@var{file} can be wrapped in the @code{assume-valid-file-name} syntactic
+keyword. When this is done, there will not be a warning when
+@code{local-file} is used with a non-literal path.  The path is still
+looked up relative to the current working directory at run time.
+Wrapping is done like this:
+
+@lisp
+(define alice-key-file-path "alice.pub")
+;; ...
+(local-file (assume-valid-file-name alice-key-file-path))
+@end lisp
+
 This is the declarative counterpart of the @code{interned-file} monadic
 procedure (@pxref{The Store Monad, @code{interned-file}}).
 @end deffn

base-commit: 7b7f299bb493e485c5534b8c554e51d4f3a8c026
-- 
2.41.0





Message sent to guix@HIDDEN, pelzflorian@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#70829] [PATCH v2 2/2] guix: gexp: Add assume-source-relative-file-name
Resent-From: Richard Sent <richard@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, pelzflorian@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Wed, 08 May 2024 18:35:02 +0000
Resent-Message-ID: <handler.70829.B70829.171519329827730 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 70829
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 70829 <at> debbugs.gnu.org
Cc: Richard Sent <richard@HIDDEN>, Christopher Baines <guix@HIDDEN>, Florian Pelz <pelzflorian@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Florian Pelz <pelzflorian@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 70829-submit <at> debbugs.gnu.org id=B70829.171519329827730
          (code B ref 70829); Wed, 08 May 2024 18:35:02 +0000
Received: (at 70829) by debbugs.gnu.org; 8 May 2024 18:34:58 +0000
Received: from localhost ([127.0.0.1]:50203 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1s4m82-0007DC-02
	for submit <at> debbugs.gnu.org; Wed, 08 May 2024 14:34:58 -0400
Received: from mail-108-mta163.mxroute.com ([136.175.108.163]:36859)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <richard@HIDDEN>) id 1s4m7z-0007D6-Bm
 for 70829 <at> debbugs.gnu.org; Wed, 08 May 2024 14:34:56 -0400
Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com)
 (Authenticated sender: mN4UYu2MZsgR)
 by mail-108-mta163.mxroute.com (ZoneMTA) with ESMTPSA id
 18f597c3b120008ca2.001 for <70829 <at> debbugs.gnu.org>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Wed, 08 May 2024 18:34:24 +0000
X-Zone-Loop: f171d798167e38549921c283ece4aeda0178129c29ff
X-Originating-IP: [136.175.111.2]
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version:
 References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:
 Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From:
 Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:
 List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=7k94FEsj0CXh+Ie+kUgRyejF/HnqZnGu1HS2+wB8DFs=; b=Z/CWiVUaFrMr0zzZqQPEoqS94O
 d6auQWNle6/uhAdjIfZgn2QJUCj7Y2lRzLp3l4iOqGc+3A86BdFRBxJgTyQPcClgAyYE+xnjPCU1p
 BwDxQPdTxogBba/q9pc+2Jp2tKqw8NEoUlAPPndGPub40cVT7ZSjmjvzq4hwqhhb86gDKV7cHsl0W
 FUP6vteR5BAXLzyyN0u9P/WkgyPhKaii5Zwa8CSy8ZgCOh8L7v6TudZ8zQ0ZJ53ImBLgIl5udZMnd
 cUYPTFsEgbGXprLJRwQK0Pj8CpjeVcIFLF+EXgsTvAqfFl/eR/Q2l/0ntO6oBkGC7hFkRfXtnOKcP
 tixJB63A==;
From: Richard Sent <richard@HIDDEN>
Date: Wed,  8 May 2024 14:32:47 -0400
Message-ID: <822a1c5009d33b5e994fac9e21f087cbb3255972.1715193167.git.richard@HIDDEN>
In-Reply-To: <23ca145e6087ea18559fdd71d0c92db572abc8a3.1715193167.git.richard@HIDDEN>
References: <23ca145e6087ea18559fdd71d0c92db572abc8a3.1715193167.git.richard@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Authenticated-Id: richard@HIDDEN
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

guix/gexp.scm (assume-source-relative-file-name): Create syntax rule
(local-file): Use assume-source-relative-file-name to look up a non-literal
file relative to the current source directory.
doc/guix.texi (G-expressions): Document it.
tests: gexp.scm: Test it.
---
 doc/guix.texi  |  5 +++++
 guix/gexp.scm  | 15 ++++++++++++++-
 tests/gexp.scm |  6 ++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 221db5c022..1fc7be7cd8 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12166,6 +12166,11 @@ G-Expressions
 (local-file (assume-valid-file-name alice-key-file-path))
 @end lisp
 
+@var{file} can be wrapped in the @code{assume-source-relative-file-name}
+syntactic keyword.  When this is done, the file name will be looked up
+relative to the source file where it appears even when it is not a
+string literal.
+
 This is the declarative counterpart of the @code{interned-file} monadic
 procedure (@pxref{The Store Monad, @code{interned-file}}).
 @end deffn
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 74b4c49f90..871e59cfdc 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -52,6 +52,7 @@ (define-module (guix gexp)
             gexp-input-native?
 
             assume-valid-file-name
+            assume-source-relative-file-name
             local-file
             local-file?
             local-file-file
@@ -485,6 +486,12 @@ (define-syntax-rule (assume-valid-file-name file)
 warn about it."
   file)
 
+(define-syntax-rule (assume-source-relative-file-name file)
+  "This is a syntactic keyword to tell 'local-file' that it can assume that
+the given file is relative to the source directory, even if it's not a string
+literal."
+  file)
+
 (define-syntax local-file
   (lambda (s)
     "Return an object representing local file FILE to add to the store; this
@@ -503,13 +510,19 @@ (define-syntax local-file
 This is the declarative counterpart of the 'interned-file' monadic procedure.
 It is implemented as a macro to capture the current source directory where it
 appears."
-    (syntax-case s (assume-valid-file-name)
+    (syntax-case s (assume-valid-file-name assume-source-relative-file-name)
       ((_ file rest ...)
        (string? (syntax->datum #'file))
        ;; FILE is a literal, so resolve it relative to the source directory.
        #'(%local-file file
                       (delay (absolute-file-name file (current-source-directory)))
                       rest ...))
+      ((_ (assume-source-relative-file-name file) rest ...)
+       ;; FILE is not a literal, but the user requested we look it up
+       ;; relative to the current source directory.
+       #'(%local-file file
+                      (delay (absolute-file-name file (current-source-directory)))
+                      rest ...))
       ((_ (assume-valid-file-name file) rest ...)
        ;; FILE is not a literal, so resolve it relative to the current
        ;; directory.  Since the user declared FILE is valid, do not pass
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 905009caee..8774097bd0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -244,6 +244,12 @@ (define %extension-package
       (let ((file (local-file (string-copy "../base32.scm"))))
         (local-file-absolute-file-name file)))))
 
+(test-equal "local-file, non-literal source relative file name"
+  (current-filename)
+  (let ((file (local-file (assume-source-relative-file-name
+                           (string-append "gexp" ".scm")))))
+    (local-file-absolute-file-name file)))
+
 (test-assert "local-file, relative file name, within gexp"
   (let* ((file     (search-path %load-path "guix/base32.scm"))
          (interned (add-to-store %store "base32.scm" #f "sha256" file)))
-- 
2.41.0






Last modified: Wed, 8 May 2024 18:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.