From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id gNs8A/GqOWOF/wAAbAwnHQ (envelope-from ) for ; Sun, 02 Oct 2022 17:14:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id kNxyAvGqOWMDmAAAG6o9tA (envelope-from ) for ; Sun, 02 Oct 2022 17:14:57 +0200 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 976CB47F6D for ; Sun, 2 Oct 2022 17:14:56 +0200 (CEST) Received: from localhost ([::1]:58756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1of0gB-0002a4-G1 for larch@yhetil.org; Sun, 02 Oct 2022 11:14:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1of04Y-00063p-PS for bug-guix@gnu.org; Sun, 02 Oct 2022 10:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1of04Y-0007b7-GX for bug-guix@gnu.org; Sun, 02 Oct 2022 10:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1of04Y-00025G-7Y for bug-guix@gnu.org; Sun, 02 Oct 2022 10:36:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#58250: [PATCH 1/2] modules: Remove load path prefix from module name. Resent-From: itd Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sun, 02 Oct 2022 14:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58250 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 58250@debbugs.gnu.org Received: via spool by 58250-submit@debbugs.gnu.org id=B58250.16647213477987 (code B ref 58250); Sun, 02 Oct 2022 14:36:02 +0000 Received: (at 58250) by debbugs.gnu.org; 2 Oct 2022 14:35:47 +0000 Received: from localhost ([127.0.0.1]:47787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1of04J-00024k-HT for submit@debbugs.gnu.org; Sun, 02 Oct 2022 10:35:47 -0400 Received: from mailout3.rbg.tum.de ([131.159.0.8]:50963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1of04G-00024T-82 for 58250@debbugs.gnu.org; Sun, 02 Oct 2022 10:35:45 -0400 Received: from mailrelay1.rbg.tum.de (mailrelay1.in.tum.de [131.159.254.14]) by mailout3.rbg.tum.de (Postfix) with ESMTPS id 9ACF6100129 for <58250@debbugs.gnu.org>; Sun, 2 Oct 2022 16:35:37 +0200 (CEST) Received: by mailrelay1.rbg.tum.de (Postfix, from userid 112) id 978E11A8; Sun, 2 Oct 2022 16:35:37 +0200 (CEST) Received: from mailrelay1.rbg.tum.de (localhost [127.0.0.1]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id 0F92F1A1 for <58250@debbugs.gnu.org>; Sun, 2 Oct 2022 16:35:35 +0200 (CEST) Received: from mail.net.in.tum.de (mail.net.in.tum.de [IPv6:2001:4ca0:2001:14:216:3eff:fe52:ed14]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id 0E332CD for <58250@debbugs.gnu.org>; Sun, 2 Oct 2022 16:35:35 +0200 (CEST) Received: from amnesix.net.in.tum.de (amnesix.net.in.tum.de [IPv6:2001:4ca0:2001:11:e2d5:5eff:fea9:55ca]) by mail.net.in.tum.de (Postfix) with ESMTP id E30A328D0804; Sun, 2 Oct 2022 16:35:34 +0200 (CEST) From: itd In-Reply-To: References: <871qrqfgiq.fsf@localhost> Date: Sun, 02 Oct 2022 16:35:33 +0200 Message-ID: <87y1tye1je.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Sun, 02 Oct 2022 11:14:47 -0400 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1664723696; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: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; bh=pm1u0bGq0Z1tuzNYrO5xxmQNXK2JiJj4fTCMYeGxS3Q=; b=Ae42wDl09JQgSNaiJNmug3q/gJ6Lpo9zfzWlSDXNXT2Gxfkge6SzX3k6hMr0zWManfW2xI 3lT30Connzt1RvB7+I431B9y56cAfHXfFQjgWUb+z3Eqz9u6NyhF5gUkMBu0OHr1xMboX8 xPUYqkooXKceBfXWEN21VsomhDXGSEP58MWtCc24vVFd1lFE4Kt1H9UGsiJQcQ85RAy0TB J/0xB9A10E8WB/KFt5HQzhrvwMeA9aZMRnw9rO1CmCFlqsZGXXaMnFfmXtM4zF/Ymkhb6B r1lKGC/Etn6xWU4TwFNFQxlH9UGETwftDR/Qhye57zUp1NIGzvefIOUKvYn5zw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1664723696; a=rsa-sha256; cv=none; b=RsoKi7mNiQ7uZn8VtB6jSI+NJ23Nv3QqekbLBjGWMzSBPQMf8AymVFDwzUmsjNBFwVQyq8 0tPY9ockz/XF4Ow5Rq7YX351WCto2SD2gSDCMsEJ6HaFkMRoCevoFXX6wAS6c2Eq6owfzl xeg0kn/12wN3hld20CmgpKVNX1Br795Jng8dGmxZftehsdm1OmsWA+9saMUt9jeh8dliP9 p7vVXkzDOr6zEfF81YXoKPzaI3aXp8H6DgzZRC6snPNKRfmdI6twurJA8w8Jf4pi0tU9BL B7/Z0AUGeVKKzctHuqqsju4AEjeFaWTtmaIsz9VdQu9DaQhvp729mDCgzyybRw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=tum.de (policy=none); 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" X-Migadu-Spam-Score: 2.96 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=tum.de (policy=none); 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" X-Migadu-Queue-Id: 976CB47F6D X-Spam-Score: 2.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: hUcjSty8Q07c * guix/modules.scm (file-name->module-name): Ignore load path prefix when building module name. --- It was mentioned on IRC, that (guix modules)'s file-name->module-name might be function to be used by the JSON importer (and fixed if needed). This patch attempts to implement the idea from the bug report. guix/modules.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/guix/modules.scm b/guix/modules.scm index 61bc8e1978..269d52ae1e 100644 --- a/guix/modules.scm +++ b/guix/modules.scm @@ -100,11 +100,23 @@ (define module-file-dependencies '())))))) (define file-name->module-name - (let ((not-slash (char-set-complement (char-set #\/)))) + (let ((not-slash (char-set-complement (char-set #\/))) + (load-path-prefix-length + (lambda (file) + ;; Length of the longest prefix among all given load paths. + (apply max (map + (lambda (path) (if (string-prefix? path file) + (string-length path) + 0)) + %load-path))))) (lambda (file) "Return the module name (a list of symbols) corresponding to FILE." (map string->symbol - (string-tokenize (string-drop-right file 4) not-slash))))) + (string-tokenize + (string-drop + (string-drop-right file 4) + (load-path-prefix-length file)) + not-slash))))) (define (module-name->file-name module) "Return the file name for MODULE." base-commit: ae221813745783ef1b7eee47561a2208cd5ad512 -- 2.37.3