From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id SHyIK4G4nl/qVAAA0tVLHw (envelope-from ) for ; Sun, 01 Nov 2020 13:30:41 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iEVbJ4G4nl8jHQAAB5/wlQ (envelope-from ) for ; Sun, 01 Nov 2020 13:30:41 +0000 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 E20E89403E6 for ; Sun, 1 Nov 2020 13:30:40 +0000 (UTC) Received: from localhost ([::1]:36996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZDRP-0008IU-MR for larch@yhetil.org; Sun, 01 Nov 2020 08:30:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZDQp-0008H2-NI for guix-patches@gnu.org; Sun, 01 Nov 2020 08:30:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZDQp-0000Y3-C1 for guix-patches@gnu.org; Sun, 01 Nov 2020 08:30:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kZDQp-0000Oc-7V for guix-patches@gnu.org; Sun, 01 Nov 2020 08:30:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#44344] [PATCH] guix: describe: Improve package provenance tracking. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 01 Nov 2020 13:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44344 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 44344@debbugs.gnu.org Received: via spool by 44344-submit@debbugs.gnu.org id=B44344.16042373741431 (code B ref 44344); Sun, 01 Nov 2020 13:30:03 +0000 Received: (at 44344) by debbugs.gnu.org; 1 Nov 2020 13:29:34 +0000 Received: from localhost ([127.0.0.1]:35993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZDQL-0000N0-UO for submit@debbugs.gnu.org; Sun, 01 Nov 2020 08:29:34 -0500 Received: from lepiller.eu ([89.234.186.109]:51360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZDQI-0000Mo-8c for 44344@debbugs.gnu.org; Sun, 01 Nov 2020 08:29:31 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 5f20f55d; Sun, 1 Nov 2020 13:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from :to:cc:subject:message-id:in-reply-to:references:mime-version :content-type; s=dkim; bh=jddwppnbAxZE8DI3A23yDYPwfVjnigHAnhf5LZ X9mRE=; b=H/mPcakPM/77NF8u7HPOv+IsntdTw3l71aHoJUigMdi70Ku4Wo5N0e 8DZJ0Q9Dc7mX4QG/l3PLkOkpHcrQnUg94V0BUnDocgOp6p7xytHIxG+duc88cc4s o9MFttfB90rzwjUTE60olsG+eQMn/spJ/PrGgMeqK6N1AC/8tV6INaMJhKEp9BCi bLJAYAERodFEPkeWdqpJCUhUwU13OmKkV76UzZisGlgUYnxBzn9o6BnI6C5lHLbe 0np6VH4INWmV3K1AK8MD8QadYEYMWXOU8qDVEHMz309nHAaJR//JrElf/weY1e8k OHiCCBlhD1b6Zt80AK7ZEYl9N9zLSh2Q== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 6e074603 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Sun, 1 Nov 2020 13:29:27 +0000 (UTC) Date: Sun, 1 Nov 2020 14:29:19 +0100 From: Julien Lepiller Message-ID: <20201101142919.5bcafefb@tachikoma.lepiller.eu> In-Reply-To: <87pn4ytiao.fsf@gnu.org> References: <20201031144007.25531-1-julien@lepiller.eu> <87pn4ytiao.fsf@gnu.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/TcIL1pT5X+v31114IfKhJ_w" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (headers rsa verify failed) header.d=lepiller.eu header.s=dkim header.b=H/mPcakP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=lepiller.eu (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: dW+JsW0Go48Z --MP_/TcIL1pT5X+v31114IfKhJ_w Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Le Sat, 31 Oct 2020 18:30:07 +0100, Ludovic Court=C3=A8s a =C3=A9crit : > Hi Julien, >=20 > Julien Lepiller skribis: >=20 > > %load-path lists ~/.config/guix/current before individual channels. > > We use canonicalize-path to get the store path for channel > > packages. > > > > * guix/describe.scm (package-provenance): Use canonicalize-path. >=20 > [...] >=20 > > (let ((file (if (string-prefix? "/" file) > > file > > - (search-path %load-path file)))) > > + (canonicalize-path (search-path %load-path > > file))))) >=20 > Could you explain what problem it solves, perhaps with a simple > reproducer? Thanks for the answer! Maybe this is only an issue in guix repl, but when looking for the provenance of a package that's defined in a channel, I always get `#f`: guix repl ,use (guix describe) ,use (gnu packages gettext) ,use (my channel packages) (package-provenance po4a) -> I get the guix channel (package-provenance my-package) -> I get #f To me, this is caused by the search-path returning a path in ~/.config/guix/current instead of /gnu/store as it does for po4a: (search-path %load-path "gnu/packages/gettext.scm") -> /gnu/store... (search-path %load-path "my/channel/packages.scm") -> /home/... The reason why I use canonicalize-path here is because doing so, I get a path in the store, that is the content of the channel, so the procedure can return that channel as the provenance for the package. Unfortunately, %load-path seems to be weirdly set when using pre-inst-env, so I'm not sure how to test (channel modules are not even found). >=20 > =E2=80=98search-path=E2=80=99 can return #f (there=E2=80=99s a test right= below), so this > should probably be: (and=3D> (search-path =E2=80=A6) canonicalize-path). >=20 > As a rule of thumb, I think twice before calling =E2=80=98canonicalize-pa= th=E2=80=99 > because (1) it=E2=80=99s expensive (lots of stat(2) calls), and (2) it can > have undesirable effects on the UI (messages mention a file name > other than the one the user typed) and elsewhere (on logic that looks > at what the file name looks like). I think the result of canonicalize-path is only used internally in that function to find the channel a package comes from, but is never used outside of this function (it's not returned). >=20 > Maybe it=E2=80=99s OK here, but I mention this for completeness. >=20 > Thanks, > Ludo=E2=80=99. Attached is an updated patch. --MP_/TcIL1pT5X+v31114IfKhJ_w Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-guix-describe-Improve-package-provenance-tracking.patch >From 5998d636ea17a192fa1cf1720c38c9b4676d0189 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Sat, 31 Oct 2020 15:35:54 +0100 Subject: [PATCH] guix: describe: Improve package provenance tracking. %load-path lists ~/.config/guix/current before individual channels. We use canonicalize-path to get the store path for channel packages. * guix/describe.scm (package-provenance): Use canonicalize-path. --- guix/describe.scm | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/guix/describe.scm b/guix/describe.scm index 05bf99eb58..ecda90897a 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -132,25 +132,25 @@ property of manifest entries, or #f if it could not be determined." (file (let ((file (if (string-prefix? "/" file) file - (search-path %load-path file)))) + (and=> (search-path %load-path file) canonicalize-path)))) (and file (string-prefix? (%store-prefix) file) ;; Always store information about the 'guix' channel and ;; optionally about the specific channel FILE comes from. - (or (let ((main (and=> (find (lambda (entry) - (string=? "guix" - (manifest-entry-name entry))) - (current-profile-entries)) - entry-source)) - (extra (any (lambda (entry) - (let ((item (manifest-entry-item entry))) - (and (string-prefix? item file) - (entry-source entry)))) - (current-profile-entries)))) - (and main - `(,main - ,@(if extra (list extra) '())))))))))) + (let ((main (and=> (find (lambda (entry) + (string=? "guix" + (manifest-entry-name entry))) + (current-profile-entries)) + entry-source)) + (extra (any (lambda (entry) + (let ((item (manifest-entry-item entry))) + (and (string-prefix? item file) + (entry-source entry)))) + (current-profile-entries)))) + (and main + `(,main + ,@(if extra (list extra) '()))))))))) (define (manifest-entry-with-provenance entry) "Return ENTRY with an additional 'provenance' property if it's not already -- 2.28.0 --MP_/TcIL1pT5X+v31114IfKhJ_w--