From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id CMfFELwT9WaEgQEA62LTzQ:P1 (envelope-from ) for ; Thu, 26 Sep 2024 07:56:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id CMfFELwT9WaEgQEA62LTzQ (envelope-from ) for ; Thu, 26 Sep 2024 09:56:44 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=FOixNIsi; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=FaeOfyrL; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1727337404; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=sbYU6LGXkTuXePzvS5sp4/6XDPX7Jr04MLxw04ki7A8=; b=mIReZfLw8VExfSN8R6cz6X1ETLVBalJRSXiFpvW1n/E5LCmUz5nEOulTc9fdG2Gg61D9Vp NTC88EZCsPz+COv5yZqqsooRUNo/6YvsIlaWqBFq1zBcYXKuYx2sev8cI2kodMxUXroQfQ Q3tnjiTvwIOvY7ieRsQ/+S2EP3dfbXAs9qC71RG4zKGBNmovdMNbyZqBvpHhOMZsY7WZ2a wjIU8WoCE5huCrWYUJP4nsR1GbG03dkVVpDL+BHqhTmUq+SQKjWdWh+RUYInFtEi8HOfcB rqFCVxM7mzaGeigMoyXS1hLSi/a+oNWygfMUCe/MpMfmTad3TG3g91A/NfDfzQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=FOixNIsi; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=FaeOfyrL; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1727337404; a=rsa-sha256; cv=none; b=X09fF/2oGJZ29aYq+rtKJ6W5ZL9gytb9uD/zmCkHEQ+9CN4wV0j/wa3llTXxKT4ti7iD1G i8MgVygeuLEEfs8469KhhUs86XLEjSKhFvQtTEzHGxLjGMzs4KTwv7qX/KxCOn1k6MJstG L09914vA5RKzR9ZX8InidlFdauwO7osA8cYSVTMfoWSykmsE/SKSPcGKQvZXS3ymiSuooS cxlEgMtfoPYCC9d4SC2eS6dPyzmigWhA1H5Nvp+db3D3BEqR7EhBANAnQlRiKsRi0eOL+G 9muuYTuX0ZgSAiFDxzHBlxE/Sm39ASelzgt7cwPiQvdlJVN2YYnk4SnuC0g9hw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 143BD24D1 for ; Thu, 26 Sep 2024 09:56:44 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stjM3-00077k-FZ; Thu, 26 Sep 2024 03:56:04 -0400 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 1stjLf-0005pF-0L for guix-patches@gnu.org; Thu, 26 Sep 2024 03:55:43 -0400 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 1stjLd-0007Wj-Sg; Thu, 26 Sep 2024 03:55:38 -0400 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=sbYU6LGXkTuXePzvS5sp4/6XDPX7Jr04MLxw04ki7A8=; b=FOixNIsi6uiJ5fqmrFVdQaV83nL2stOgqibMbRb8SAxASA8X77XjpybqMbQjQHJH07g29/bXX3TxkpU0VtgUAFojsno2Rm0oevF1McMcLlZE97lvLYAWaq1BfeccjcG0H2JPgfcb7hx4GYj6J2W3f6EZiYUFvH6y7Nf5CBmkFON5BI5bFp3uw4avY5pKgUysUUH4ZrH6o/Oog78wSefVgUn6slOVMC2G+oN6xeiq1MY1aGCDBY6RufytntEFryR7Ynm1O0QA+CLo4KaXVENQUeKYbsTGj8WF37MBTdI0Z3WZGLZeGJHVnVrz6W+7EV4Rzcn9xUNuEgBYbt5xMesT4A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stjM1-0003CG-NO; Thu, 26 Sep 2024 03:56:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#72867] [PATCH v6] gexp: Make 'local-file' follow symlinks. References: In-Reply-To: Resent-From: Nigko Yerden 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: Thu, 26 Sep 2024 07:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72867 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 72867@debbugs.gnu.org Cc: Attila Lendvai , pelzflorian , Nigko Yerden , 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 72867-submit@debbugs.gnu.org id=B72867.172733732011622 (code B ref 72867); Thu, 26 Sep 2024 07:56:01 +0000 Received: (at 72867) by debbugs.gnu.org; 26 Sep 2024 07:55:20 +0000 Received: from localhost ([127.0.0.1]:51761 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stjLL-00031M-Df for submit@debbugs.gnu.org; Thu, 26 Sep 2024 03:55:20 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:57632) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stijO-0008V9-L7 for 72867@debbugs.gnu.org; Thu, 26 Sep 2024 03:16:07 -0400 Received: by mail-lf1-f65.google.com with SMTP id 2adb3069b0e04-536a2759f0eso1065933e87.3 for <72867@debbugs.gnu.org>; Thu, 26 Sep 2024 00:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727334873; x=1727939673; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sbYU6LGXkTuXePzvS5sp4/6XDPX7Jr04MLxw04ki7A8=; b=FaeOfyrL/G1JFh+iJUxi6Qwnqoy+DSS9AHYeH2vO3A01E3cZkFZAL34F57WAV3Rc8n dyy7zoMrqOlBC7iJ8uMz5icbxml6/F5lPdXdHi1C/Sa+fbdk9xM1Mm1kh+Kq/POv7yvp 3OUPckLNx9CI0eqgzY1ER1ONd2zj6HvAJds42d/iq7PA1SOPDX9FBEdiWlUP9bbx2ReW vmEPQiqrzem1usjkcULLQUWMQp/T1qgigXG5G7+QIa8TXFSjUJW9z5eF2cldReu/VC8A OsN7KVj50BKH1VZMhj0UuoDp6UDhMNIjFft28rp9Uch41dHln7WTG7udKWqwOqw3w84U qlHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727334873; x=1727939673; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sbYU6LGXkTuXePzvS5sp4/6XDPX7Jr04MLxw04ki7A8=; b=MDFYPND6M9dRVUzHC8pulmGHrR8j2NBUao8vZFYb7izUNOxZZc+Fy/qDc97LH8st9f tRCqCV+i3z3EWy5EUoFCIjsazcPyWd8qZuT0GfJPeaf3hbDY+n4kjWvoMor0G2qv/SbE 8eGCkyflQ+oTWUs+6KMnYg6I412D7djng6iH9dT+/bfeGetqw8R4boSpE3JL6NvboOeq v4HtlFLR+tD0RE989oGsVWdbDjigiNqPIgEx4X0mqlhNc8J1Zg3l1S/lBraLiKxp3RXT pPpU80ZRJ+4nIplL9Dqn+jmq3vEkw/ruozDJ4uSdPi5YE98tPcg1WpLYho8AtGQ74Kx7 a15Q== X-Gm-Message-State: AOJu0YzjpAol6vwaETJe/i9qtawgDI/3j0+b5TO2YSTC6Rbf7wKEAfCV ui/mufIpTGzdBik3lYhzdSayNJqB9uskZncWdH1syxgRcs3kZAOjfwwa6afn X-Google-Smtp-Source: AGHT+IFLPRwXqGASaPb3P7OPqw9PY7aUUMBxeTW1alJRW4Y09N8/UwcWQUK7jkRMFPRKZgX4bSKuNA== X-Received: by 2002:a05:6512:39c7:b0:533:42ae:c985 with SMTP id 2adb3069b0e04-5387753181dmr3597624e87.25.1727334872527; Thu, 26 Sep 2024 00:14:32 -0700 (PDT) Received: from localhost.localdomain ([188.168.141.132]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-537a864d558sm718652e87.248.2024.09.26.00.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 00:14:31 -0700 (PDT) Date: Thu, 26 Sep 2024 12:07:56 +0500 Message-ID: <3079fb8aa8eedc06db4c9faae9cd08774636b94d.1727334475.git.nigko.yerden@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Nigko Yerden via Guix-patches Reply-To: Nigko Yerden Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 143BD24D1 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -5.02 X-Migadu-Spam-Score: -5.02 X-TUID: TdrqcuRdNBVP Fix via making 'current-source-directory' always follow symlinks. * guix/utils.scm (absolute-dirname, current-source-directory): Make them follow symlinks. * tests/gexp.scm ("local-file, load through symlink"): New test. Change-Id: Ieb30101275deb56b7436df444f9bc21d240fba59 --- Hello all, This version of patch advocated by Florian changes 'current-source-directory' to always follow symlinks. Regards, Nigko guix/utils.scm | 8 ++------ tests/gexp.scm | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index f161cb4ef3..d4591caced 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -1121,11 +1121,7 @@ (define absolute-dirname (match (search-path %load-path file) (#f #f) ((? string? file) - ;; If there are relative names in %LOAD-PATH, FILE can be relative and - ;; needs to be canonicalized. - (if (string-prefix? "/" file) - (dirname file) - (canonicalize-path (dirname file))))))) + (dirname (canonicalize-path file)))))) (define-syntax current-source-directory (lambda (s) @@ -1141,7 +1137,7 @@ (define-syntax current-source-directory ;; run time rather than expansion time is necessary to allow files ;; to be moved on the file system. (if (string-prefix? "/" file-name) - (dirname file-name) + (dirname (canonicalize-path file-name)) #`(absolute-dirname #,file-name))) ((or ('filename . #f) #f) ;; raising an error would upset Geiser users diff --git a/tests/gexp.scm b/tests/gexp.scm index e066076c5c..cd502a1fb2 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -298,6 +298,39 @@ (define %extension-package (equal? (scandir (string-append dir "/tests")) '("." ".." "gexp.scm")))))) +(test-assert "local-file, load through symlink" + ;; See . + (call-with-temporary-directory + (lambda (tmp-dir) + (chdir tmp-dir) + ;; create content file + (call-with-output-file "content" + (lambda (port) (display "Hi!" port))) + ;; Create module that call 'local-file' + ;; with the content file and returns its + ;; absolute file-name. An error is raised + ;; if the content file can't be found. + (call-with-output-file "test-local-file.scm" + (lambda (port) (display "\ +(define-module (test-local-file) + #:use-module (guix gexp)) +(define file (local-file \"content\" \"test-file\")) +(local-file-absolute-file-name file)" port))) + (mkdir "dir") + (chdir "dir") + (symlink "../test-local-file.scm" "test-local-file.scm") + ;; 'local-file' in turn calls 'current-source-directory' + ;; which has an 'if' branching condition depending on whether + ;; 'file-name' is absolute or relative path. To test both + ;; of these branches we execute 'test-local-file.scm' symlink + ;; first as a module (corresponds to relative path): + (dynamic-wind + (lambda () (set! %load-path (cons "." %load-path))) + (lambda () (use-modules (test-local-file))) + (lambda () (set! %load-path (cdr %load-path)))) + ;; and then as a regular code (corresponds to absolute path): + (load (string-append tmp-dir "/dir/test-local-file.scm"))))) + (test-assert "one plain file" (let* ((file (plain-file "hi" "Hello, world!")) (exp (gexp (display (ungexp file)))) base-commit: 404dbd894c69c94b483c6139d2a39b1c1eaddf36 -- 2.46.0