From patchwork Sun Feb 16 14:44:00 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: 38741 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 DFDF827BBEA; Sun, 16 Feb 2025 14:45:33 +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 633EA27BBE2 for ; Sun, 16 Feb 2025 14:45:33 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tjftT-0006xD-VB; Sun, 16 Feb 2025 09:45:16 -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 1tjftJ-0006sd-9t for guix-patches@gnu.org; Sun, 16 Feb 2025 09:45:06 -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 1tjftI-0008LX-B3; Sun, 16 Feb 2025 09:45:05 -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:References:In-Reply-To:Date:From:To:Subject; bh=q6wc2adHEmv2J522yBJdW/SQOHTJX5siPHZbH1w4fwY=; b=mdjOHZoMdvhnDu9qRgVIipzBtIEj+JBYrRjLMlhZihC9c6oQwITfuuLPtLaSp21nQsRpog4s7XD5BeMerMbQRcMGg+TMtWLe7Vsf9LteZ0WvaR4vklkKqLhjbkfNLCJtzzczQ5g0r8SxoATeWFQ/ATLGD5FkA27/+YhavmbZEZyGwWEfrKJCYWVDfeTRaE9xEXwRdB8HNw6fxI/zG8FU3COXk7ZDnRb9Cs8PPuUSxZnDROvTbJMrGRHLU6vHijInihELDMWz5BX7tzIsA0SP8hN5pfHpnc0aEReDX6OnobcNpOjmLDBrb4TrT1omLVqW6wMOYEvg6YKV7Xv18dO96Q==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tjftG-0001uw-Q7; Sun, 16 Feb 2025 09:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76143] [PATCH v3 1/1] gnu: Find patches directory through symlinks. 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:45: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.17397170847316 (code B ref 76143); Sun, 16 Feb 2025 14:45:02 +0000 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 Date: Sun, 16 Feb 2025 15:44:00 +0100 Message-ID: In-Reply-To: References: 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 | 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))