From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id mCmqNLCyU2Xu2wAAG6o9tA:P1 (envelope-from ) for ; Tue, 14 Nov 2023 18:47:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id mCmqNLCyU2Xu2wAAG6o9tA (envelope-from ) for ; Tue, 14 Nov 2023 18:47:28 +0100 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 85A38418A3 for ; Tue, 14 Nov 2023 18:47:28 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=g6wXltbb; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1699984048; h=from:from:sender:sender: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=f6jo43ftX85XHXAzDQ5ks6xrMqB0NN14DsVo9mAWIN4=; b=efjHtEpb4sbJUgnMt/3Z02G3V8WbtjEtI6rCoZeXrODaCuJtdc5JvgyVODpwq9XkNJFOMj tJU0mK+pT+XytVbLnsji55CCVi9uC6jrKF+9tY/ohIJOmM4rnHlJE/4OYx87SQzmmR5e/u yxD7MkukxSKc/IkFqmVUn/M4/F5LiCTjA+PGh3h07mka6xpj12miSM2i9jwJ+bJ1qjlKet KRBEiuIpi6gpvsZoGAyVmNUruMccU/YPDjhBqMKwQbt2RoHrQkKRvSwSArOlNeSvGu23UC PLKs6gnf2yriWk8UcAlgtXPn3ae1eC/E+u42bya7eIdgNKddQdpW8MNYz+LWvw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=g6wXltbb; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1699984048; a=rsa-sha256; cv=none; b=LKQH8dD5UbYmpyliE3AxcHIzW5OWoAqvVIp1NBFH8zsUPtd1IRyL06SvxjD+CyfjUCHp/O eTYIcl4fGPLeViH675OJpqglxTv2+pjlmd/sl+iuoaE2YDPj1YdClGn4gYa6SUPwZhF5T7 rYCE7Ws6pnOieN+5JK1iYY0QOaS43W1St9m1nST9Ya+GyhIn8z28emxHcmcv1WjMBRW2Tg r/5nMRMpPI+wHr9YMM0+z4d5GC4saOYGJYiMCBZqtFa9ubri8IizMWE00qkpJInDxXABqQ TO/pJvHgdUL1AlXKeDEI4XS/U79ZtQSMv2BJ234NNWmgoKpEfVWGrHwMvMj4BA== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2xE7-00019U-3n; Tue, 14 Nov 2023 12:29:27 -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 1r2xE5-00014A-6W for bug-guix@gnu.org; Tue, 14 Nov 2023 12:29:25 -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 1r2xE4-0002QN-4L; Tue, 14 Nov 2023 12:29:24 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r2xEg-0002b9-Vc; Tue, 14 Nov 2023 12:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#67048: [PATCH] DRAFT guix: upstream: Allow relative file name. References: In-Reply-To: Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, bug-guix@gnu.org Resent-Date: Tue, 14 Nov 2023 17:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67048 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 67048@debbugs.gnu.org Cc: Simon Tournier , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 67048-submit@debbugs.gnu.org id=B67048.16999829689907 (code B ref 67048); Tue, 14 Nov 2023 17:30:02 +0000 Received: (at 67048) by debbugs.gnu.org; 14 Nov 2023 17:29:28 +0000 Received: from localhost ([127.0.0.1]:34113 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2xE7-0002Zi-QR for submit@debbugs.gnu.org; Tue, 14 Nov 2023 12:29:28 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:39320) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r2xE4-0002ZT-Uk for 67048@debbugs.gnu.org; Tue, 14 Nov 2023 12:29:26 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40837396b1eso2998015e9.1 for <67048@debbugs.gnu.org>; Tue, 14 Nov 2023 09:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699982917; x=1700587717; 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=f6jo43ftX85XHXAzDQ5ks6xrMqB0NN14DsVo9mAWIN4=; b=g6wXltbbHliO7WYZ3X16bYoPkrZZF5hLn3lLgiTKUzYcmXV/lez4ytwHTy5c9AeNlR 77fWOSaYcOMp0qsNjSdU3ZacCXCsrdWVIuBa9yoDq+otsSAlg3tNAUwsGJXOkHZrDSRD viuW+T75O+IqW8SdTHmqCo4lVRsn0N5Xa7tcfFhEkK9BW28keOU8FsFtdrs/TZH/dAQM Rn/14jT6wl9uNNwBnnjFQwozMIXdIaSKYEVBRJ9+PNVOixUDuqUoKjQGPaiLSAyC0d96 bQllL8itI0Ox98+LU9Wv5D0N7Oa+pEdSFRuNqk5XbQUr0fi6ubuAqNrFqmdZWKGw8+nC VDkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699982917; x=1700587717; 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=f6jo43ftX85XHXAzDQ5ks6xrMqB0NN14DsVo9mAWIN4=; b=RpMvV+BK5b8NqiTEz0KevwbgXtc6PwD90UToIGbWKT8VWkb7rFYAxYz246VrtkgVnU sTOAE8WQVmIsPc4dv/34yJNHae0wmdiWIX9UtO6a2sVveR0uj8Fl9VZKlg3iRuEzXt8L qdneHcm2RupfdZjtKXFiHbb2oR+2Lki48Wm4J/lNAumLPki7uloQkvfiBwcAcWRcGEvx +0bPHgmJlOFaqNGSKIn33vbGFLCs4qJmYT69Tqk8eAdkRdYz0NN81QNVIkY91JqVfgzB cs17rY8cZuCNsLKFCaCHCXDpNmjV9JYtbUZ68yPeAoG6HMec10KCcc0gvPPSoEqnMqty 8NgQ== X-Gm-Message-State: AOJu0YykiWdNdS8vf1Ynwq6AcwOGCxR7RvZcptsTuYzDV/SrZKJDwqEo Z5iUS+Z/2gc8e2Tb71ISlMwnaYVJV98= X-Google-Smtp-Source: AGHT+IHL58P9VqIu9OLXKTr8WmpZjh2Tv+PknYlzdzTHJ5p5kQDbJUx7fjRAa9W+rvSHHrBwjCaExw== X-Received: by 2002:a05:600c:1f13:b0:405:4280:341d with SMTP id bd19-20020a05600c1f1300b004054280341dmr2002918wmb.4.1699982916471; Tue, 14 Nov 2023 09:28:36 -0800 (PST) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id d3-20020adfa403000000b00331424a1266sm8158920wra.84.2023.11.14.09.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 09:28:35 -0800 (PST) From: Simon Tournier Date: Tue, 14 Nov 2023 18:28:28 +0100 Message-ID: X-Mailer: git-send-email 2.41.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: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 4.91 X-Spam-Score: 4.91 X-Migadu-Queue-Id: 85A38418A3 X-Migadu-Scanner: mx13.migadu.com X-TUID: akU6gEn59PJT Fixes . Reported by Andreas Enge . * guix/diagnostics.scm (absolute-location): Return FILE from 'canonicalize-path' when 'search-path' fails. * guix/packages.scm (package-field-location): New procedure 'file-name' and use it. When 'search-path' does not find FILE in %LOAD-PATH, try 'canonicalize-path'. * guix/upstream.scm (update-package-source): When 'search-path' fails, test if FILE exists. Change-Id: I9337041b43e17ace82416db5840f04113f9544fc --- guix/diagnostics.scm | 13 +++++----- guix/packages.scm | 57 +++++++++++++++++++++++++------------------- guix/upstream.scm | 6 +++-- 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/guix/diagnostics.scm b/guix/diagnostics.scm index 3f1f527b43..f79df1ca2d 100644 --- a/guix/diagnostics.scm +++ b/guix/diagnostics.scm @@ -349,12 +349,13 @@ (define (absolute-location loc) ;; 'search-path' might return #f in obscure cases, such as ;; when %LOAD-PATH includes "." or ".." and LOC comes from a ;; file in a subdirectory thereof. - (match (search-path %load-path (location-file loc)) - (#f - (raise (formatted-message - (G_ "file '~a' not found on load path") - (location-file loc)))) - (str str))) + (let ((file (location-file loc))) + (or (search-path %load-path file) + (and (file-exists? file) + (canonicalize-path file)) + (raise (formatted-message + (G_ "file '~a' not found on load path") + file))))) (location-line loc) (location-column loc))) diff --git a/guix/packages.scm b/guix/packages.scm index e2e82692ad..ea05b739a8 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -750,37 +750,44 @@ (define (deprecated-package old-name p) (define (package-field-location package field) "Return the source code location of the definition of FIELD for PACKAGE, or #f if it could not be determined." + (define (file-name relative-file file-found line column) + (catch 'system-error + (lambda () + ;; In general we want to keep relative file names for modules. + (call-with-input-file file-found + (lambda (port) + (go-to-location port line column) + (match (read port) + ((or ('package inits ...) + ('package/inherit _ inits ...)) + (let ((field (assoc field inits))) + (match field + ((_ value) + (let ((loc (and=> (source-properties value) + source-properties->location))) + (and loc + ;; Preserve the original file name, which may be a + ;; relative file name. + (set-field loc (location-file) relative-file)))) + (_ + #f)))) + (_ + #f))))) + (lambda _ + #f))) + (match (package-location package) (($ file line column) (match (search-path %load-path file) ((? string? file-found) - (catch 'system-error - (lambda () - ;; In general we want to keep relative file names for modules. - (call-with-input-file file-found - (lambda (port) - (go-to-location port line column) - (match (read port) - ((or ('package inits ...) - ('package/inherit _ inits ...)) - (let ((field (assoc field inits))) - (match field - ((_ value) - (let ((loc (and=> (source-properties value) - source-properties->location))) - (and loc - ;; Preserve the original file name, which may be a - ;; relative file name. - (set-field loc (location-file) file)))) - (_ - #f)))) - (_ - #f))))) - (lambda _ - #f))) + (file-name file file-found line column)) (#f ;; FILE could not be found in %LOAD-PATH. - #f))) + (let ((file-found (and (file-exists? file) + (canonicalize-path file)))) + (if file-found + (file-name file file-found line column) + #f))))) (_ #f))) (define-syntax-rule (this-package-input name) diff --git a/guix/upstream.scm b/guix/upstream.scm index e28ae12f3f..5403aa833d 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -645,8 +645,10 @@ (define* (update-package-source package source hash) ((? git-reference? ref) (git-reference-commit ref)) (_ #f))) - (file (and=> (location-file loc) - (cut search-path %load-path <>)))) + (file (or (and=> (location-file loc) + (cut search-path %load-path <>)) + (and=> (location-file loc) + file-exists?)))) (if file ;; Be sure to use absolute filename. Replace the URL directory ;; when OLD-URL is available; this is useful notably for base-commit: 3d15e9e5bcd7cdad33f9832e4956f494c47e1937 -- 2.41.0