From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 08 08:37:01 2025 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 ) id 1tgl12-0004bL-HM for submit@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 ) id 1tgl0z-0004b0-Kn for submit@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 ) id 1tgl0o-0002rD-EN for guix-patches@gnu.org; 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 ) id 1tgl0l-0000jj-6N for guix-patches@gnu.org; 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?= To: guix-patches@gnu.org Subject: [PATCH] gnu: Canonicalize paths before comparing. Date: Sat, 8 Feb 2025 14:36:08 +0100 Message-ID: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a01:5b40:0:3006::1; envelope-from=noe@xn--no-cja.eu; 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?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) From: Noé Lopez 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 . 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 From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 06:29:09 2025 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 ) id 1th5Uq-0004ny-Rf for submit@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 ) id 1th5Up-0004nZ-4x for 76143@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 ) 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?= To: =?utf-8?Q?No=C3=A9?= Lopez Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing. In-Reply-To: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> (=?utf-8?Q?=22No=C3=A9?= Lopez"'s message of "Sat, 8 Feb 2025 14:36:08 +0100") References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> 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@gnu.org> 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 , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , 76143@debbugs.gnu.org, Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, No=C3=A9 Lopez 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 09:09:49 2025 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 ) id 1tjfLA-0005Yc-Vh for submit@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 ) id 1tjfL7-0005YG-7q for 76143@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?= To: 76143@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@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76143 Cc: =?UTF-8?q?No=C3=A9=20Lopez?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) From: Noé Lopez 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@qq.com> ;;; Copyright © 2023 Foundation Devices, Inc. ;;; Copyright © 2024 Herman Rimm +;;; Copyright © 2025 Noé Lopez ;;; ;;; 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 ;;; Copyright © 2023 Foundation Devices, Inc. ;;; Copyright © 2024 Herman Rimm +;;; Copyright © 2025 Noé Lopez ;;; ;;; 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 From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 09:15:29 2025 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 ) id 1tjfQf-0007Eq-6F for submit@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 ) id 1tjfQa-0006p6-TS for 76143@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 To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing. In-Reply-To: <87pljrs6fc.fsf@gnu.org> References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> <87pljrs6fc.fsf@gnu.org> Date: Sun, 16 Feb 2025 15:15:16 +0100 Message-ID: <871pvy6knf.fsf@xn--no-cja.eu> 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 , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , 76143@debbugs.gnu.org, Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Ludovic Court=C3=A8s writes: > Hi, > > No=C3=A9 Lopez 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 09:44:39 2025 Received: (at 76143) by debbugs.gnu.org; 16 Feb 2025 14:44:39 +0000 Received: from localhost ([127.0.0.1]:33068 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjfsq-0001tc-HQ for submit@debbugs.gnu.org; Sun, 16 Feb 2025 09:44:39 -0500 Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:37682) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjfsk-0001tH-PK for 76143@debbugs.gnu.org; Sun, 16 Feb 2025 09:44:33 -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=4nv9cDLHImXlyTR+cgyFWEWpzIMoqnDvk4uYGBaGXQE=; b=is2bcU3IDUoD+z1mDiFrfcGWKO 3S/iSdVLLliqCr5PzgA3siVgqIJrxL9q0xWJsUfseW2meAlycvK0zHuYL9nHhYu00IyeZUZJ8vXGI 08OtUJE7v1XJx0aPZpFXbH68juiy6HZIRKWhFjD0T0EFkiTLBxaQp9bAYoba1bClnOpE2WHnx5ezu r8IGQ5FL43fvvZAxWAY33kXPmsDbcgXq/oszSQdqHim+8obQhqFQA8Tga09vN20BIDRHf1NHnityg iX0hAJ6uTBFCWBjpn7kB56jHhrN07w/e4lzROXgO4RpndMRwWQ7CDfbtW+9uWwEUXG0gNcIr2R24o NE5G2W7g==; Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) id 1tjfsd-00Fb0r-74; Sun, 16 Feb 2025 15:44:23 +0100 From: =?UTF-8?q?No=C3=A9=20Lopez?= To: 76143@debbugs.gnu.org Subject: [PATCH v3 0/1] gnu: Find patches directory through symlinks. Date: Sun, 16 Feb 2025 15:43:59 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76143 Cc: =?UTF-8?q?No=C3=A9=20Lopez?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) From: Noé Lopez I sent the patch too early, sorry for the spam. If you want to test this patch, you can try the following (changing the paths to your checkout): noe@lignux ~$ export GUILE_LOAD_PATH=/home/noe/src///guix-patch-review/// noe@lignux ~$ export GUILE_LOAD_COMPILED_PATH=/home/noe/src/guix-patch-review//// noe@lignux ~$ guile [...] Enter `,help' for help. scheme@(guile-user)> ,use (gnu packages) scheme@(guile-user)> (%patch-path) $2 = ("/home/noe/src///guix-patch-review////gnu/packages/patches" "/gnu/store/ylwk2vn18dkzkj0nxq2h4vjzhz17bm7c-guile-3.0.9/share/guile/3.0" "/gnu/store/ylwk2vn18dkzkj0nxq2h4vjzhz17bm7c-guile-3.0.9/share/guile/site/3.0" "/gnu/store/ylwk2vn18dkzkj0nxq2h4vjzhz17bm7c-guile-3.0.9/share/guile/site" "/gnu/store/ylwk2vn18dkzkj0nxq2h4vjzhz17bm7c-guile-3.0.9/share/guile") Check that /gnu/packages/patches was correctly added. Noé Lopez (1): gnu: Find patches directory through symlinks. gnu/packages.scm | 2 +- guix/utils.scm | 16 ++++++++++++++++ tests/utils.scm | 13 +++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) base-commit: 73d74032d580212e7b59644d3324677926e4339b -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 16 09:44:43 2025 Received: (at 76143) by debbugs.gnu.org; 16 Feb 2025 14:44:44 +0000 Received: from localhost ([127.0.0.1]:33070 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjfsx-0001tv-Bd for submit@debbugs.gnu.org; Sun, 16 Feb 2025 09:44:43 -0500 Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:55640) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjfsp-0001tO-Q8 for 76143@debbugs.gnu.org; Sun, 16 Feb 2025 09:44:37 -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:References:In-Reply-To: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=q6wc2adHEmv2J522yBJdW/SQOHTJX5siPHZbH1w4fwY=; b=l luM0al8nkr6A5HLmWGT8At4nRbdFw7SAwI7avYM4gORBzCp2CDJB+YszDnXjvQjpLwX+BHXrS75KL KlsoSanOTcneXt7dKaFzfPZXWulCN4F9tUU+dU192CndshfOo0ui+ZwPrOsFz76pU9Ud3SoBjGeUJ Pn4cCuLX0uK+9JHdGOgwjKG78gpupW6tLrusvUoVaNWzqGU3PfClB2Il2WcCVLJPzGqJgyE4y2OfY ylcFOAo4L/xTqOFP0J2LLhbYY4oN5yIebecH4R3n042oSpT8O+euzsE/fRKM7UiRruQVSw7deLNmi XfbzlsaDyFFi2PzlWq0PCd4RwonfByj/A==; Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) id 1tjfsj-00Fb0r-OR; Sun, 16 Feb 2025 15:44:29 +0100 From: =?UTF-8?q?No=C3=A9=20Lopez?= To: 76143@debbugs.gnu.org Subject: [PATCH v3 1/1] gnu: Find patches directory through symlinks. Date: Sun, 16 Feb 2025 15:44:00 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Debbugs-Cc: Christopher Baines , Josselin Poiret , Ludovic Courtès , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76143 Cc: =?UTF-8?q?No=C3=A9=20Lopez?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) From: Noé Lopez 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 | 16 ++++++++++++++++ tests/utils.scm | 13 +++++++++++++ 3 files changed, 30 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..7979eba040 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -21,6 +21,7 @@ ;;; Copyright © 2023 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2023 Foundation Devices, Inc. ;;; Copyright © 2024 Herman Rimm +;;; Copyright © 2025 Noé Lopez ;;; ;;; This file is part of GNU Guix. ;;; @@ -41,6 +42,7 @@ (define-module (guix utils) #:use-module (guix config) #:autoload (guix read-print) (object->string*) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-2) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-71) @@ -162,6 +164,7 @@ (define-module (guix utils) compressed-output-port call-with-compressed-output-port canonical-newline-port + directory=? string-distance string-closest @@ -1150,6 +1153,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 ;;; Copyright © 2023 Foundation Devices, Inc. ;;; Copyright © 2024 Herman Rimm +;;; Copyright © 2025 Noé Lopez ;;; ;;; 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)) -- 2.48.1 From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 21 05:21:38 2025 Received: (at 76143) by debbugs.gnu.org; 21 Feb 2025 10:21:39 +0000 Received: from localhost ([127.0.0.1]:54190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tlQA5-0005Ij-W6 for submit@debbugs.gnu.org; Fri, 21 Feb 2025 05:21:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46664) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tlQA3-0005Hd-R8 for 76143@debbugs.gnu.org; Fri, 21 Feb 2025 05:21:37 -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 ) id 1tlQ9x-0006j5-1d; Fri, 21 Feb 2025 05:21:29 -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=vh6NBUPMXkLbZ+nvaoCSjZzctbhPD8XS/V4wb4Qh2gQ=; b=O2AJqtOWzHU/UV3ampQW AWuGfEycFRAYNubkBvXx7CASEQn0vy5EUeSLkWe1wHtf33N98bADuABIV2VuAKLrN62kuJX1TlJVB Iz4JXoC8Ek1xsplQhVYtIUTEGZfCEbsMMiQO99bo8n64w2i9pScxSNqNyNVPL0nPY97nKMVQUQbnH bYOblFFd3hrdZIWw72FU78SZV8wvB9zJrYSXE+Cdewf/nMzeGllM2W4Sb7G+aZ4vowssz9tO/UtAd 2qXLrMWGga6aNzXGqc1wZF0Wm0IxSDjOiXwiS9thP0qW9KMfFaoiXox+JicGLpAs5sfV3M7bDiDIC e4NkwNhDTOLk8w==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: =?utf-8?Q?No=C3=A9?= Lopez Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing. In-Reply-To: <871pvy6knf.fsf@xn--no-cja.eu> (=?utf-8?Q?=22No=C3=A9?= Lopez"'s message of "Sun, 16 Feb 2025 15:15:16 +0100") References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> <87pljrs6fc.fsf@gnu.org> <871pvy6knf.fsf@xn--no-cja.eu> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Tridi 3 =?utf-8?Q?Vent=C3=B4se?= an 233 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du Violier 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: Fri, 21 Feb 2025 11:21:25 +0100 Message-ID: <87o6yvbntm.fsf@gnu.org> 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 , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , 76143@debbugs.gnu.org, Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, No=C3=A9 Lopez skribis: > 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 pr= ogram > 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 don=E2=80=99t fully understand the situation. My suggestion (but perhaps you=E2=80=99re already doing that) would be for PackageKit to invoke =E2=80= =98guix repl=E2=80=99, not =E2=80=98guile=E2=80=99. The raison d=E2=80=99=C3=AAtre= of =E2=80=98guix repl=E2=80=99 was precisely to have the load path for Guix and all its dependencies properly set up. Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 21 10:42:25 2025 Received: (at 76143) by debbugs.gnu.org; 21 Feb 2025 15:42:25 +0000 Received: from localhost ([127.0.0.1]:33128 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tlVAW-0001uQ-1K for submit@debbugs.gnu.org; Fri, 21 Feb 2025 10:42:25 -0500 Received: from smtp.domeneshop.no ([2a01:5b40:0:3006::1]:51762) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tlVAT-0001tB-U4 for 76143@debbugs.gnu.org; Fri, 21 Feb 2025 10:42:22 -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=VlmbGkO5az2GDQ4s6npVoVOz4we8HtpfIvv5o8ldTcY=; b=F ECAjirzKn8cc0YW/JsPwDi1LFKlr0hOLCsKPAvowj4ZcXVz/5gEFXkbwxfv51/w91PvRgzZlmzzTZ W83RW3OCevLD18+rpmoCsq5KzTEvvGFFCZGyu8zx5jNUQb6BKZFaas0kijAJKd1lwiMl7/neosYoo RgOVr9igDQpKwqBPP41QQtp/tvGQ/TS8pNFsRZkMqpSvAwenVEJ3SwNzsXoXn1w5bMVjWNwLc+BiV pqDhqJBa2CsQIRCF3pYRVQjucGvPpKVg1zROWnBEPbx0ud0oeP1fOYu993swGQgDZazbP5hHhB6M2 6v14iIBOPM6gPw/+mPvjpN0P03SarrJ5Q==; Received: from smtp by smtp.domeneshop.no with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) id 1tlVAM-00DgPk-FZ; Fri, 21 Feb 2025 16:42:14 +0100 From: =?utf-8?Q?No=C3=A9?= Lopez To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#76143] [PATCH] gnu: Canonicalize paths before comparing. In-Reply-To: <87o6yvbntm.fsf@gnu.org> References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> <87pljrs6fc.fsf@gnu.org> <871pvy6knf.fsf@xn--no-cja.eu> <87o6yvbntm.fsf@gnu.org> Date: Fri, 21 Feb 2025 16:42:07 +0100 Message-ID: <87eczr2tkg.fsf@xn--no-cja.eu> 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 , Simon Tournier , Mathieu Othacehe , Tobias Geerinckx-Rice , 76143@debbugs.gnu.org, Christopher Baines X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Ludovic Court=C3=A8s writes: > Hi, > > No=C3=A9 Lopez skribis: > >> 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 p= rogram >> 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 don=E2=80=99t fully understand the situation. My suggestion (but perha= ps > you=E2=80=99re already doing that) would be for PackageKit to invoke =E2= =80=98guix > repl=E2=80=99, not =E2=80=98guile=E2=80=99. The raison d=E2=80=99=C3=AAt= re of =E2=80=98guix repl=E2=80=99 was precisely to > have the load path for Guix and all its dependencies properly set up. > Let me try to explain the situation better: The Guix channel has a special case for where it stores its patches, so guix needs to detect whether a directory is the Guix source to append "/gnu/packages/patches" to it: gnu/packages.scm(166) (define %patch-path (make-parameter (map (lambda (directory) (if (string=3D? directory %distro-root-directory) (string-append directory "/gnu/packages/patches") directory)) %load-path))) The comparison is done with string=3D?, which is a very weak way of comparing directories, as you know. But the directory list is supplied by the environment, so its up to the user to set the path exactly equal to %distro-root-directory. Obviously, this can fail in many ways if the user is not using guix through pre-inst-env or guix repl. My patch fixes that by comparing with stat, making sure all paths to the guix source work. For PackageKit specifically, I am using guix through guile=E2=80=99s C api = and needed to set the environment by hand, I fixed it by removing the trailing slash. Is that clearer? All the best, No=C3=A9