From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MOu7I9zo8GA2ZwEAgWs5BA (envelope-from ) for ; Fri, 16 Jul 2021 04:03:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mJJbH9zo8GBJcwAAbx9fmQ (envelope-from ) for ; Fri, 16 Jul 2021 02:03:08 +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 AF3C71B05B for ; Fri, 16 Jul 2021 04:03:07 +0200 (CEST) Received: from localhost ([::1]:49974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4DBy-0008Vu-QP for larch@yhetil.org; Thu, 15 Jul 2021 22:03:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4DBu-0008VX-S1 for guix-patches@gnu.org; Thu, 15 Jul 2021 22:03:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4DBu-00041m-K6 for guix-patches@gnu.org; Thu, 15 Jul 2021 22:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m4DBu-0004Rq-Bh for guix-patches@gnu.org; Thu, 15 Jul 2021 22:03:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49591] [PATCH] import: go: Handle multiple go-import meta tags. Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 16 Jul 2021 02:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49591@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162640092817037 (code B ref -1); Fri, 16 Jul 2021 02:03:02 +0000 Received: (at submit) by debbugs.gnu.org; 16 Jul 2021 02:02:08 +0000 Received: from localhost ([127.0.0.1]:50150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4DB1-0004Qi-P0 for submit@debbugs.gnu.org; Thu, 15 Jul 2021 22:02:08 -0400 Received: from lists.gnu.org ([209.51.188.17]:37464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4DAw-0004QX-B0 for submit@debbugs.gnu.org; Thu, 15 Jul 2021 22:02:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4DAv-0008TF-Gk for guix-patches@gnu.org; Thu, 15 Jul 2021 22:02:02 -0400 Received: from out2.migadu.com ([188.165.223.204]:15108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4DAs-0003LU-9p for guix-patches@gnu.org; Thu, 15 Jul 2021 22:02:01 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1626400914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SBT4aoI78vTgSKZbhKECAICLpG5On2ffzjoXGlh/3z4=; b=bhZ5HU/wFXpCXDhkjuH+ydpYpLqFYiZcDEiac/HJniL56+MafqphNcpgbu+GS1yr5ojzdW 8qpbx3mi/cms76RVV2alu85txxpoQDTchbVNUsqhqKD0ool0IMTLylscd58hVj28Z6xm1i uU7/VnS8nTVMdiCZkSHbSWVk2I+V8f4= Date: Thu, 15 Jul 2021 19:01:52 -0700 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Auth-User: iskarian@mgsn.dev Received-SPF: pass client-ip=188.165.223.204; envelope-from=iskarian@mgsn.dev; helo=out2.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Sarah Morgensen X-ACL-Warn: , Sarah Morgensen via Guix-patches From: Sarah Morgensen via Guix-patches via X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1626400987; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=SBT4aoI78vTgSKZbhKECAICLpG5On2ffzjoXGlh/3z4=; b=B9VQREuAWv5JHNVm8EuSPLY7YhsjIlFjX/XOh47T0d3HXpxESPv1kRwky+5YcCdZRgUt1e X/KfRnNuNz5kFa34GHSlqYbONbNBpADtYRAfDOuvv5jbyccHYLCNIwsJ2VQ9WFaAIFCm26 mj9R3Kbis3VDlc970wQ3x4+oYdYrW0FTrlnPs48dEWGjWmJfqnuWYBisWRy9KbMgdqSOLE DfBpfsfR7tVaLjJDpmQnZFKcwqZrBbGtPh2dzBlAXRkwUgUA2PpLrJXmZ9BsePPwCO5kBS Nj8R7AjPQn6R3rTAZ90tnQUfaXZtn1uJl7z2UuMFT9J2E9nkxw5P7rttdNXf9Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1626400987; a=rsa-sha256; cv=none; b=smTRY8ehPpYP0IWQCQAl1SvY50QkQNH6+wCcjC1JBipHiiEa9w2K6KZ1vyYFkiIEdqU/Po 3IGqMkJ0EbzpwBufohTeXaxFgn82emhlQ0iF4Wu1phHKAJbozUHvhnKxwnAHhiUesm6bej KhBzl/eQg3oSIbCKRmFKQNKthNmsQUySvOx93Iucp91COrG4e0XnLMDfbx087YMxjM4Ns8 oy09U92xHzsrwbuaTIFhi2jIx0++lb+XQGorIV7oRV3AseJHWNGWZNr+D7d4G0qgCTYvam mJDj00Lua57W7Z6X7bj35a0Mse9v60TlE/kFxiwuV7xFHAE3nZfWJsx0qXhRKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b="bhZ5HU/w"; dmarc=pass (policy=none) header.from=gnu.org; 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-Migadu-Spam-Score: -2.90 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b="bhZ5HU/w"; dmarc=pass (policy=none) header.from=gnu.org; 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-Migadu-Queue-Id: AF3C71B05B X-Spam-Score: -2.90 X-Migadu-Scanner: scn0.migadu.com X-TUID: D9nAS6vZBgX5 * guix/import/go.scm (fetch-module-meta-data): Parse all go-import meta tags and return the first 'module-meta' with a matching import prefix. [go-import->module-meta]: Extract parsing into new procedure. --- Hello Guix, It seems sometimes a module's go-get page contains multiple tags, for example the 'bazil.org/fuse' module. This causes a backtrace when attempting to import such a module: -----8<---------------cut here---------------start------------->8--- $ guix import go bazil.org/fuse following redirection to `https://bazil.org/fuse/?go-get=1'... Backtrace: 5 (primitive-load "/home/sarah/.config/guix/current/bin/g…") In guix/ui.scm: 2182:7 4 (run-guix . _) 2145:10 3 (run-guix-command _ . _) In guix/scripts/import.scm: 120:11 2 (guix-import . _) In guix/scripts/import/go.scm: 118:27 1 (guix-import-go . _) In guix/import/go.scm: 467:4 0 (go-module->guix-package _ #:goproxy _ #:version _ # _) guix/import/go.scm:467:4: In procedure go-module->guix-package: Throw to key `match-error' with args `("match" "no matching pattern" ((content "bazil.org/bazil git https://github.com/bazil/bazil") (content "bazil.org/fuse git https://github.com/bazil/fuse") (content "bazil.org/bolt-mount git https://github.com/bazil/bolt-mount") (content "bazil.org/zipfs git https://github.com/bazil/zipfs") (content "bazil.org/plop git https://github.com/bazil/plop")))'. --8<---------------cut here---------------end--------------->8--- This patch makes the importer parse all such tags and search for one with an import prefix that is a prefix of the module-path we are looking for. (I attempted to add a unit test but could not figure out how to make the record type accessible to the test script.) -- Sarah guix/import/go.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index d8f838f635..182db0ecfb 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -460,17 +460,21 @@ Optionally include a VERSION string to append to the name." "Retrieve the module meta-data from its landing page. This is necessary because goproxy servers don't currently provide all the information needed to build a package." + (define (go-import->module-meta content-text) + (match (string-split content-text #\space) + ((root-path vcs repo-url) + (make-module-meta root-path (string->symbol vcs) + (strip-.git-suffix/maybe repo-url))))) ;; (let* ((meta-data (http-fetch* (format #f "https://~a?go-get=1" module-path))) (select (sxpath `(// head (meta (@ (equal? (name "go-import")))) // content)))) (match (select (html->sxml meta-data #:strict? #t)) (() #f) ;nothing selected - (((content content-text)) - (match (string-split content-text #\space) - ((root-path vcs repo-url) - (make-module-meta root-path (string->symbol vcs) - (strip-.git-suffix/maybe repo-url)))))))) + ((('content content-text) ..1) + (find (lambda (meta) + (string-prefix? (module-meta-import-prefix meta) module-path)) + (map go-import->module-meta content-text)))))) (define (module-meta-data-repo-url meta-data goproxy) "Return the URL where the fetcher which will be used can download the base-commit: 01d7e8c2782f61e741f8beff7888adfbdb61779d -- 2.31.1