From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 15 22:02:08 2021 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= From: Sarah Morgensen To: guix-patches@gnu.org Subject: [PATCH] import: go: Handle multiple go-import meta tags. 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-Flow: FLOW_OUT 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-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) * 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 17 23:31:37 2021 Received: (at submit) by debbugs.gnu.org; 18 Jul 2021 03:31:37 +0000 Received: from localhost ([127.0.0.1]:54971 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4xWj-0002BT-In for submit@debbugs.gnu.org; Sat, 17 Jul 2021 23:31:37 -0400 Received: from lists.gnu.org ([209.51.188.17]:42416) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m4xWh-0002BL-8h for submit@debbugs.gnu.org; Sat, 17 Jul 2021 23:31:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4xWh-0004mk-0Q for guix-patches@gnu.org; Sat, 17 Jul 2021 23:31:35 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:45655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4xWf-0007qX-CM for guix-patches@gnu.org; Sat, 17 Jul 2021 23:31:34 -0400 Received: by mail-qt1-x832.google.com with SMTP id z25so10372180qto.12 for ; Sat, 17 Jul 2021 20:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=ywwCgwHV1bT28mdC7xL0tRAFNtUapu5pm031QYsRje8=; b=CBWFuscnHWx/WukIzGy7rpCP0F7mNHr7mjhnOdlVxXL3P2tYcs5kQnjAOKig103dym obsyBo+b2ZSITfYnje+K6XgjQdPgRgYhjr9o/WyFnmU+f2WJ0UickmAA4DeXZfF11cvu oG08uEwUAg9F4R8vYVRcmgDR1F6ofMuBqnoOMoCVUmCax9bpuOj+o3FaLJ/lY4R6uxXw F8rd2tmJZhGCkVycW1iKsbHCtRA6XbKEXqLwpdYhDl4EiT2jAcd3AdZUTVHHRP0ovNB+ VnU5Nlu7U/nFc3Xf3kisCyYn9tCc34dFsKtBSwXo5BCQgG1ou1zQlKr+8P0B2NEu0RdB TrXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=ywwCgwHV1bT28mdC7xL0tRAFNtUapu5pm031QYsRje8=; b=VxmYdPFdi5sLItLrHFAICdEBnCy8oI7OJDizEb8Q+8xvsKLcDU/uQB4Qa+H75fbxTY lfCNeQtvkoo++cHJx4LzY7G5VSUhmEys0kEHTeR7N9MxpHmqZ0ML5sQ3k5EBlc4kFGG2 P78SJorrfi9XermJSRgF3Az66GVKF83vNqa7ntGBp4pzyklSJxmxAFa7dWPHNpnOP/Jn ZTX4lq/MjCeWeRWAOyxDzEHB6wCE5vP26pA5m5FJWUzoGyD5skU7hjwQJMMVDeRJm49X CQUfQ5KSzRBGQrFJgqxghX9uIDG5UE602bxmpktv+/PjxpHDxze/nDVp85Cvjkh/4jgL Au6A== X-Gm-Message-State: AOAM530WXygtTUMXiyWyLlbHuaNgqYCcULmTXZlOIFz6eoEYNEzVJo3A ZmpT15GuUCu2IQzl9QKhsD4= X-Google-Smtp-Source: ABdhPJyE5jdpN4QaXdP4HozUk594hvoMz9bU2M5/Ofcqu0W5NxW4VFFQGSwcaoX8ZlZWhet8uTeIMg== X-Received: by 2002:ac8:6994:: with SMTP id o20mr16728281qtq.21.1626579092233; Sat, 17 Jul 2021 20:31:32 -0700 (PDT) Received: from hurd (dsl-148-66.b2b2c.ca. [66.158.148.66]) by smtp.gmail.com with ESMTPSA id s81sm6002975qka.82.2021.07.17.20.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 20:31:31 -0700 (PDT) From: Maxim Cournoyer To: Sarah Morgensen via Guix-patches via Subject: Re: [bug#49591] [PATCH] import: go: Handle multiple go-import meta tags. References: Date: Sat, 17 Jul 2021 23:31:31 -0400 In-Reply-To: (Sarah Morgensen via Guix-patches via's message of "Thu, 15 Jul 2021 19:01:52 -0700") Message-ID: <87zgukjo18.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x832.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Sarah Morgensen , 49591-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hello again, Sarah Morgensen via Guix-patches via writes: > * 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 wh= en > attempting to import such a module: > > $ guix import go bazil.org/fuse > following redirection to `https://bazil.org/fuse/?go-get=3D1'... > Backtrace: > 5 (primitive-load "/home/sarah/.config/guix/current/bin/g=E2= =80=A6") > 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" ((co= ntent "bazil.org/bazil git https://github.com/bazil/bazil") (content "bazil= .org/fuse git https://github.com/bazil/fuse") (content "bazil.org/bolt-moun= t git https://github.com/bazil/bolt-mount") (content "bazil.org/zipfs git h= ttps://github.com/bazil/zipfs") (content "bazil.org/plop git https://github= .com/bazil/plop")))'. > > > 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. Good catch, LGTM! > (I attempted to add a unit test but could not figure out how to make the > record type accessible to the test script.) I started adding a new fixture for fixtures-go-bazil-org-fuse-test, but but I'm rusty as to where all these bits are pulled from. Perhaps it could be nice to add it, but otherwise it seems better in the mean time to fix apply this fix as-is. Committed with 5eba9c0960. Thank you! Closing. Maxim From unknown Fri Aug 15 19:29:27 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 15 Aug 2021 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator