GNU logs - #76143, boring messages


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


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.
Resent-From: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Sat, 08 Feb 2025 13:37:01 +0000
Resent-Message-ID: <handler.76143.B.173902182117695 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 76143
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 76143 <at> debbugs.gnu.org
Cc: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@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>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by submit <at> debbugs.gnu.org id=B.173902182117695
          (code B ref -1); Sat, 08 Feb 2025 13:37:01 +0000
Received: (at submit) by debbugs.gnu.org; 8 Feb 2025 13:37:01 +0000
Received: from localhost ([127.0.0.1]:39200 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tgl12-0004bL-HM
	for submit <at> debbugs.gnu.org; Sat, 08 Feb 2025 08:37:00 -0500
Received: from lists.gnu.org ([2001:470:142::17]:50022)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <noe@HIDDEN>) id 1tgl0z-0004b0-Kn
 for submit <at> debbugs.gnu.org; Sat, 08 Feb 2025 08:36:58 -0500
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 <noe@HIDDEN>) id 1tgl0o-0002rD-EN
 for guix-patches@HIDDEN; Sat, 08 Feb 2025 08:36:47 -0500
Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <noe@HIDDEN>) id 1tgl0l-0000jj-6N
 for guix-patches@HIDDEN; Sat, 08 Feb 2025 08:36:46 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=xn--no-cja.eu; s=ds202402; h=Content-Transfer-Encoding:Content-Type:
 MIME-Version:Message-ID:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:
 Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:
 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=OkJ+FgaPRPheagtdb1xNPFnkXkRdJMBXLJo0BYioqFU=; b=EBwMsMWoT0QojYBMnby5ZmqLux
 GyoyqDelKXTZwhHFbkdbaTVYOLsLzDf0i2gacB0Ag5bqaJXVmz1n0xB7UHLEQ/OxFvQ5ORFX/v6Nc
 CDCXZsfk9ZCUgU+D8X7s+b1xpLEc9jP5rFAiMvFMioH3wFaMMBBTiiRpLKd9cogmd1Con6zybSC8n
 w11bJo+2j134ALHVHatqUYToXtQxCZWNH1CEYrNeQbBcMHd53KjOM0nQs0/elsTUZsjeU+76DNbtl
 O5uzVMgqhjG0FHqxlsMhxGNNULn7cc1HVtTsQ/aw+itVU7vuD6NICRI/reEKQXGvlAesxSwxBSmfd
 e5nrq+mA==;
Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
 id 1tgl0d-006oq5-Df; Sat, 08 Feb 2025 14:36:35 +0100
From: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Date: Sat,  8 Feb 2025 14:36:08 +0100
Message-ID: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2a01:5b40:0:3006::1;
 envelope-from=noe@HIDDEN; helo=smtp.domeneshop.no
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.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: -0.0 (/)

From: Noé Lopez <noelopez@HIDDEN>

The comparison would fail if the load path for guix was not already
canonicalized, since it is doing a string comparison.

* gnu/packages.scm (%patch-path): Canonicalize paths before
comparing.
* guix/ui.scm (try-canonicalize-path): Move to (guix utils).
* guix/utils.scm (try-canonicalize-path): New function.

Change-Id: Id5d51ce483af74ac4e122563d84cc3e8d78c3246
---
 gnu/packages.scm | 11 ++++++-----
 guix/ui.scm      | 14 --------------
 guix/utils.scm   | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/gnu/packages.scm b/gnu/packages.scm
index bdd5d21940..d043d0616d 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -167,11 +167,12 @@ (define %patch-path
   ;; Define it after '%package-module-path' so that '%load-path' contains user
   ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found.
   (make-parameter
-   (map (lambda (directory)
-          (if (string=? directory %distro-root-directory)
-              (string-append directory "/gnu/packages/patches")
-              directory))
-        %load-path)))
+   (let ((root (try-canonicalize-path %distro-root-directory)))
+     (map (lambda (directory)
+            (if (string=? (try-canonicalize-path directory) root)
+                (string-append directory "/gnu/packages/patches")
+                directory))
+          %load-path))))
 
 ;; This procedure is used by Emacs-Guix up to 0.5.1.1, so keep it for now.
 ;; See <https://github.com/alezost/guix.el/issues/30>.
diff --git a/guix/ui.scm b/guix/ui.scm
index 87a448bf72..a3a9bf4e42 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -206,20 +206,6 @@ (define-syntax-rule (without-compiler-optimizations exp)
   (parameterize (((@ (system base compile) default-optimization-level) 1))
     exp))
 
-(define (try-canonicalize-path file)
-  "Like 'canonicalize-path', but return FILE as-is if 'canonicalize-path'
-throws.
-
-This is necessary for corner cases where 'canonicalize-path' fails.  One
-example is on Linux when a /dev/fd/N file denotes a pipe, represented as a
-symlink to a non-existent file like 'pipe:[1234]', as in this example:
-
-  sh -c 'stat $(readlink -f /dev/fd/1)' | cat"
-  (catch 'system-error
-    (lambda ()
-      (canonicalize-path file))
-    (const file)))
-
 (define* (load* file user-module
                 #:key (on-error 'nothing-special))
   "Load the user provided Scheme source code FILE."
diff --git a/guix/utils.scm b/guix/utils.scm
index b6cf5aea4f..6e5b6b6caf 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -162,6 +162,7 @@ (define-module (guix utils)
             compressed-output-port
             call-with-compressed-output-port
             canonical-newline-port
+            try-canonicalize-path
 
             string-distance
             string-closest
@@ -1150,6 +1151,20 @@ (define (canonical-newline-port port)
                                  get-position
                                  set-position!
                                  close))
+
+(define (try-canonicalize-path file)
+  "Like 'canonicalize-path', but return FILE as-is if 'canonicalize-path'
+throws.
+
+This is necessary for corner cases where 'canonicalize-path' fails.  One
+example is on Linux when a /dev/fd/N file denotes a pipe, represented as a
+symlink to a non-existent file like 'pipe:[1234]', as in this example:
+
+  sh -c 'stat $(readlink -f /dev/fd/1)' | cat"
+  (catch 'system-error
+    (lambda ()
+      (canonicalize-path file))
+    (const file)))
 
 ;;;
 ;;; Source location.

base-commit: 9c36d38614079611aebe4721b9e087f98e57b1b3
-- 
2.48.1





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: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Subject: bug#76143: Acknowledgement ([PATCH] gnu: Canonicalize paths
 before comparing.)
Message-ID: <handler.76143.B.173902182117695.ack <at> debbugs.gnu.org>
References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
X-Gnu-PR-Message: ack 76143
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 76143 <at> debbugs.gnu.org
Date: Sat, 08 Feb 2025 13:37: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>, Josselin Poiret <dev@HIDDEN>,=
 Ludovic Court=C3=A8s <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, =
Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@tobias=
.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 76143 <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
76143: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D76143
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 09 Feb 2025 11:30:03 +0000
Resent-Message-ID: <handler.76143.B76143.173910054918479 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 76143
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 76143 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
Received: via spool by 76143-submit <at> debbugs.gnu.org id=B76143.173910054918479
          (code B ref 76143); Sun, 09 Feb 2025 11:30:03 +0000
Received: (at 76143) by debbugs.gnu.org; 9 Feb 2025 11:29:09 +0000
Received: from localhost ([127.0.0.1]:43358 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1th5Uq-0004ny-Rf
	for submit <at> debbugs.gnu.org; Sun, 09 Feb 2025 06:29:09 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:38534)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1th5Up-0004nZ-4x
 for 76143 <at> debbugs.gnu.org; Sun, 09 Feb 2025 06:29:07 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1th5Uh-0006wh-6K; Sun, 09 Feb 2025 06:28:59 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=L1dRCVv4TKEgwMBte8cKLJBnJLS5onIDIEqhfKV8N6M=; b=XF37JkvgT+J7VbY1ttPU
 bkEaXhagxNO2k2k2WiaimUJea9GTZAXSnCrqH76zzJplLZYmBvrqFad0n5pK03GLlvJGhtzMaT+v5
 ORKH+cFRbcXu3HXUxqbl9K1PXL3QoN90+jP8vrk9CGhKMMTdKtW9X883ZqjVeyxF0dne05Md5l+Vj
 daDXOQaMg8rc4teePvxYrEEakUhJ3h4yjclvvH6S4llXTvaZ1pn3Kw8K36FyXNMx499K0Y8b2lhRc
 oyDTwAp/6pk+hpxiggAeBxXmA7GUt7EPPokbMLcaAvgTTenOPY6bDeiG1jZj9YUR2DDWDxgW9VrJI
 4Cz4F+6Pg8Ycrg==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
 ("=?UTF-8?Q?No=C3=A9?= Lopez"'s message of "Sat, 8 Feb 2025 14:36:08
 +0100")
References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: Primidi 21 =?UTF-8?Q?Pluvi=C3=B4se?= an 233 de la
 =?UTF-8?Q?R=C3=A9volution,?= jour du Thlaspi
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Sun, 09 Feb 2025 12:28:55 +0100
Message-ID: <87pljrs6fc.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
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: -3.3 (---)

Hi,

No=C3=A9 Lopez <noe@no=C3=A9.eu> skribis:

> --- a/gnu/packages.scm
> +++ b/gnu/packages.scm
> @@ -167,11 +167,12 @@ (define %patch-path
>    ;; Define it after '%package-module-path' so that '%load-path' contain=
s user
>    ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found.
>    (make-parameter
> -   (map (lambda (directory)
> -          (if (string=3D? directory %distro-root-directory)
> -              (string-append directory "/gnu/packages/patches")
> -              directory))
> -        %load-path)))
> +   (let ((root (try-canonicalize-path %distro-root-directory)))
> +     (map (lambda (directory)
> +            (if (string=3D? (try-canonicalize-path directory) root)
> +                (string-append directory "/gnu/packages/patches")
> +                directory))
> +          %load-path))))

I=E2=80=99m not sure what the goal is but please keep in mind that
=E2=80=98canonicalize-path=E2=80=99 is expensive in terms of system calls (=
especially if
=E2=80=98%load-path=E2=80=99 is long, and we=E2=80=99d pay it for all progr=
am startup times),
and that the comparison here remains brittle (checking the dev/ino
fields of =E2=80=98stat=E2=80=99 would be more accurate).

Thanks,
Ludo=E2=80=99.




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


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76143] [PATCH v2] gnu: Find patches directory through symlinks.
References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
In-Reply-To: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
Resent-From: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Sun, 16 Feb 2025 14:10:02 +0000
Resent-Message-ID: <handler.76143.B76143.173971498921370 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 76143
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 76143 <at> debbugs.gnu.org
Cc: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>, Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 76143-submit <at> debbugs.gnu.org id=B76143.173971498921370
          (code B ref 76143); Sun, 16 Feb 2025 14:10:02 +0000
Received: (at 76143) by debbugs.gnu.org; 16 Feb 2025 14:09:49 +0000
Received: from localhost ([127.0.0.1]:32959 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tjfLA-0005Yc-Vh
	for submit <at> debbugs.gnu.org; Sun, 16 Feb 2025 09:09:49 -0500
Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:51694)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <noe@HIDDEN>) id 1tjfL7-0005YG-7q
 for 76143 <at> debbugs.gnu.org; Sun, 16 Feb 2025 09:09:46 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=xn--no-cja.eu; s=ds202502; h=Content-Transfer-Encoding:Content-Type:
 MIME-Version:Message-ID:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:
 Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:
 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=Ys7TtJVhP88J5uPfs9DtlOiDFaN9EpVZiqptixZwS3U=; b=agaEJQIGPcjED+INHdNVkI2YUx
 8E5JEvwEefgWdokgDr8SMVGO7c7EoIPytuYKhvQZWKLJhFuxKh7x5ivmmBPObD5u138E5pKsOCzJh
 R3Lnhg9HdamPFjsxKnVo8AhS3yMiFzMVTOdLIV69C2zYqYfL6itbYSXGoRERILSKfmA2kkseH46vm
 n+R2vDQq9Qwo9JMRZgGW4dARXgUzIphfOJjejJou1P7agu4Fg1WLdZufYWlHqp3fSCzOvC4fjCY9Z
 KA+MsbkiO6wddamCR2jRJHKpFpSTeKDsLyiHzds6KnA8ZPSuyYSbEL7lOQ6vpPQyOIl13tjQuu/b9
 jb+1DTiA==;
Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
 id 1tjfKy-00FTtG-Rn; Sun, 16 Feb 2025 15:09:36 +0100
From: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Date: Sun, 16 Feb 2025 15:08:56 +0100
Message-ID: <19bb17d762c3cddbd57c9f500f17e0b1ce957d36.1739714805.git.noelopez@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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 (-)

From: Noé Lopez <noelopez@HIDDEN>

This fixes a bug where patches would not be found in %patch-path when the
Guile load path would contain a different path (via symlink or trailing slash)
to the %distro-root-directory than what was previously found.  We use stat to
make sure that two different paths to the same directory are still matched.

For example: if the Guile path was /guix/ and %distro-root-directory was
/guix, patches would not be found even though the two directories are the
same.

* gnu/packages.scm (%patch-path): Compare directories with directory=?.
* guix/utils.scm (directory=?): New procedure.
* tests/utils.scm: Add tests for directory=?.

Change-Id: I73f65b6c050cdeff85637e13ffd0319dcc1d4958
---
 gnu/packages.scm |  2 +-
 guix/utils.scm   | 15 +++++++++++++++
 tests/utils.scm  | 13 +++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gnu/packages.scm b/gnu/packages.scm
index bdd5d21940..5cad0d50ff 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -168,7 +168,7 @@ (define %patch-path
   ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found.
   (make-parameter
    (map (lambda (directory)
-          (if (string=? directory %distro-root-directory)
+          (if (directory=? directory %distro-root-directory)
               (string-append directory "/gnu/packages/patches")
               directory))
         %load-path)))
diff --git a/guix/utils.scm b/guix/utils.scm
index b6cf5aea4f..a2537b4285 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -21,6 +21,7 @@
 ;;; Copyright © 2023 Zheng Junjie <873216071@HIDDEN>
 ;;; Copyright © 2023 Foundation Devices, Inc. <hello@HIDDEN>
 ;;; Copyright © 2024 Herman Rimm <herman@HIDDEN>
+;;; Copyright © 2025 Noé Lopez <noelopez@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -162,6 +163,7 @@ (define-module (guix utils)
             compressed-output-port
             call-with-compressed-output-port
             canonical-newline-port
+            directory=?
 
             string-distance
             string-closest
@@ -1150,6 +1152,19 @@ (define (canonical-newline-port port)
                                  get-position
                                  set-position!
                                  close))
+
+(define* (directory=? directory #:rest directories)
+  (define (dev+ino directory)
+    (and-let* ((stats (stat directory #f))
+               (dev (stat:dev stats))
+               (ino (stat:ino stats)))
+      (cons dev ino)))
+  (define check (dev+ino directory))
+  (and check
+       (fold (lambda (element acc)
+               (and acc (equal? (dev+ino element) check)))
+             #t
+             directories)))
 
 ;;;
 ;;; Source location.
diff --git a/tests/utils.scm b/tests/utils.scm
index 462e43e2b1..88a88eba1d 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2021 Maxime Devos <maximedevos@HIDDEN>
 ;;; Copyright © 2023 Foundation Devices, Inc. <hello@HIDDEN>
 ;;; Copyright © 2024 Herman Rimm <herman@HIDDEN>
+;;; Copyright © 2025 Noé Lopez <noelopez@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -370,6 +371,18 @@ (define-public package-2\n  'package)\n"
          ;; way.
          "avr32" "avr32-unknown-none")))
 
+;; Try to not depend on the user’s filesystem.
+(test-equal "directory=?"
+  '(#t #t #t #t #t #f #f)
+  (list
+   (directory=? "/" "/")
+   (directory=? "/../" "//")
+   (directory=? "//../" "/")
+   (directory=? "/")
+   (directory=? "/" "/../" "//" "//..//../")
+   (directory=? "/proc/99999999" "/proc/99999999") ;nonexistent directories
+   (directory=? "/proc/99999999/../../" "/")))
+
 (test-end)
 
 (false-if-exception (delete-file temp-file))

base-commit: 73d74032d580212e7b59644d3324677926e4339b
-- 
2.48.1





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.
Resent-From: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Sun, 16 Feb 2025 14:16:01 +0000
Resent-Message-ID: <handler.76143.B76143.173971532927886 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 76143
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 76143 <at> debbugs.gnu.org, Christopher Baines <guix@HIDDEN>
Received: via spool by 76143-submit <at> debbugs.gnu.org id=B76143.173971532927886
          (code B ref 76143); Sun, 16 Feb 2025 14:16:01 +0000
Received: (at 76143) by debbugs.gnu.org; 16 Feb 2025 14:15:29 +0000
Received: from localhost ([127.0.0.1]:32977 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tjfQf-0007Eq-6F
	for submit <at> debbugs.gnu.org; Sun, 16 Feb 2025 09:15:29 -0500
Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:33784)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <noe@HIDDEN>) id 1tjfQa-0006p6-TS
 for 76143 <at> debbugs.gnu.org; Sun, 16 Feb 2025 09:15:26 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=xn--no-cja.eu; s=ds202502; h=Content-Transfer-Encoding:Content-Type:
 MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:From:
 Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:
 Content-Transfer-Encoding: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=/3YPgySSD0tFzsLnvt2ZaxTjSRlzVBwE8ZFIhLOVKeQ=; b=I
 OMz106NsJOCcTZZUOhdl9LFG/xXwXOfddhwCvGeDaB7/R2zSsN6f7qGHKmJNlR1kXhiO3jmenfa03
 MJWLU7LjVIIFFJY5ZKLQH41vBhwYy8cmaw6UHATx4j1j2bXzl0T2vEbv0K52mJ0Rc9TpW1jy4YFva
 p5sdOTgcFXeAxHn/yUUXI6EFw3CBc4oaeZ/Yxhnx7M9Bedbfwp5w7hP96ZsSjdpHzS25tC+SRwiS5
 cnXbp7w7l31EDx4SZF2RFmroe2AnxDtOzOelPxr2HaVOOSnyhSevDuzOj/x8NH0wCJ6HUWIQ92lBu
 uhDWXeh+Y6MEN7zjSng3Gabj9f1ccKPLw==;
Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
 id 1tjfQU-00FV3Z-Nn; Sun, 16 Feb 2025 15:15:18 +0100
From: =?UTF-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
In-Reply-To: <87pljrs6fc.fsf@HIDDEN>
References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
 <87pljrs6fc.fsf@HIDDEN>
Date: Sun, 16 Feb 2025 15:15:16 +0100
Message-ID: <871pvy6knf.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
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 (-)

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> Hi,
>
> No=C3=A9 Lopez <noe@no=C3=A9.eu> skribis:
>
>> --- a/gnu/packages.scm
>> +++ b/gnu/packages.scm
>> @@ -167,11 +167,12 @@ (define %patch-path
>>    ;; Define it after '%package-module-path' so that '%load-path' contai=
ns user
>>    ;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found.
>>    (make-parameter
>> -   (map (lambda (directory)
>> -          (if (string=3D? directory %distro-root-directory)
>> -              (string-append directory "/gnu/packages/patches")
>> -              directory))
>> -        %load-path)))
>> +   (let ((root (try-canonicalize-path %distro-root-directory)))
>> +     (map (lambda (directory)
>> +            (if (string=3D? (try-canonicalize-path directory) root)
>> +                (string-append directory "/gnu/packages/patches")
>> +                directory))
>> +          %load-path))))
>
> I=E2=80=99m not sure what the goal is but please keep in mind that
> =E2=80=98canonicalize-path=E2=80=99 is expensive in terms of system calls=
 (especially if
> =E2=80=98%load-path=E2=80=99 is long, and we=E2=80=99d pay it for all pro=
gram startup times),
> and that the comparison here remains brittle (checking the dev/ino
> fields of =E2=80=98stat=E2=80=99 would be more accurate).
>
> Thanks,
> Ludo=E2=80=99.

I was not aware that you could do that with stat, I=E2=80=99ve sent a v2 th=
at
uses stat for comparison which works much better.

The problem I faced was that I needed to create environment variables by
hand so that I could load guile code (including guix=E2=80=99s) in a C prog=
ram
with no external environment (the packagekit daemon).  It would fail
because of not finding patches since I had a trailing slash in my path.

I=E2=80=99ve resolved the issue by removing the slash, but I wanted to fix =
it
for everyone else trying to use Guix as a library.





Last modified: Sun, 16 Feb 2025 14:15:01 UTC

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