GNU bug report logs - #76143
[PATCH] gnu: Canonicalize paths before comparing.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Noé Lopez <noe@HIDDEN>; Keywords: patch; dated Sat, 8 Feb 2025 13:37:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 76143 <at> debbugs.gnu.org:


Received: (at 76143) by debbugs.gnu.org; 16 Feb 2025 14:15:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 16 09:15:29 2025
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>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.
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-Debbugs-Envelope-To: 76143
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>
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.




Information forwarded to guix-patches@HIDDEN:
bug#76143; Package guix-patches. Full text available.

Message received at 76143 <at> debbugs.gnu.org:


Received: (at 76143) by debbugs.gnu.org; 16 Feb 2025 14:09:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 16 09:09:49 2025
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=20Lopez?= <noe@HIDDEN>
To: 76143 <at> debbugs.gnu.org
Subject: [PATCH v2] gnu: Find patches directory through symlinks.
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
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 76143
Cc: =?UTF-8?q?No=C3=A9=20Lopez?= <noe@HIDDEN>
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





Information forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#76143; Package guix-patches. Full text available.

Message received at 76143 <at> debbugs.gnu.org:


Received: (at 76143) by debbugs.gnu.org; 9 Feb 2025 11:29:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 09 06:29:09 2025
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: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: =?utf-8?Q?No=C3=A9?= Lopez <noe@HIDDEN>
Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing.
In-Reply-To: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@HIDDEN>
 (=?utf-8?Q?=22No=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=2C?= 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-Debbugs-Envelope-To: 76143
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>
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.




Information forwarded to guix-patches@HIDDEN:
bug#76143; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Feb 2025 13:37:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 08 08:37:01 2025
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=20Lopez?= <noe@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] gnu: Canonicalize paths before comparing.
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
X-Debbugs-Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic Courtès <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
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-Debbugs-Envelope-To: submit
Cc: =?UTF-8?q?No=C3=A9=20Lopez?= <noe@HIDDEN>
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





Acknowledgement sent to Noé Lopez <noe@HIDDEN>:
New bug report received and forwarded. Copy sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN. Full text available.
Report forwarded to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:
bug#76143; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
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.