From patchwork Sun Feb 16 14:08:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?No=C3=A9_Lopez?= X-Patchwork-Id: 38740 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 64E9E27BBE2; Sun, 16 Feb 2025 14:10:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C6CE527BBE9 for ; Sun, 16 Feb 2025 14:10:15 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tjfLV-0001Dv-O5; Sun, 16 Feb 2025 09:10:10 -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 1tjfLS-0001DJ-Ah for guix-patches@gnu.org; Sun, 16 Feb 2025 09:10:07 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tjfLQ-0002Pu-C5; Sun, 16 Feb 2025 09:10:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:In-Reply-To:References:Subject; bh=Ys7TtJVhP88J5uPfs9DtlOiDFaN9EpVZiqptixZwS3U=; b=VJx8gROmM4b0H4OEnmdIulYmggdHVB4z+q7ZGjANLT10zUGL+fLdVPnTlhXq5184JE4Iaz0PgnF2RLNWyVyYbBsh9Koyj6/ycpuJhDG5breQn0J7Fu/KLvr7I4UL18pyNPsILpiSMgdMmHSFeH9V2wxU6XAkHNsjoTJWZGpTlRPx+NLFsIxHzROTtI8EljI9CkYcKw5pWSfYWDi8xnAlpoaLU5Zwo+NbuIwU+aDxoWnAWov37alX6asopQOK1TsUFwI6UoPL1iorkV0V5bAB0JpF5dTX15V99sAn4qRw36IMl/beV7MolN3rmpwif1zxxjpQXz1NxoG2qfDcfsWIFQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tjfLO-0005Z8-3j; Sun, 16 Feb 2025 09:10:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76143] [PATCH v2] gnu: Find patches directory through symlinks. References: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> In-Reply-To: <9d65464d2049c6162c6ed4f022490eb59a38488a.1739021650.git.noelopez@free.fr> Resent-From: =?utf-8?q?No=C3=A9?= Lopez Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 16 Feb 2025 14:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76143 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76143@debbugs.gnu.org Cc: =?utf-8?q?No=C3=A9?= Lopez , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 76143-submit@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 ) 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 Date: Sun, 16 Feb 2025 15:08:56 +0100 Message-ID: <19bb17d762c3cddbd57c9f500f17e0b1ce957d36.1739714805.git.noelopez@free.fr> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: =?utf-8?q?No=C3=A9?= Lopez X-ACL-Warn: , =?utf-8?q?No=C3=A9_Lopez_via_Guix-patches?= X-Patchwork-Original-From: =?utf-8?q?No=C3=A9_Lopez_via_Guix-patches?= via From: =?utf-8?q?No=C3=A9_Lopez?= Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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(-) base-commit: 73d74032d580212e7b59644d3324677926e4339b 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))