From patchwork Wed Jun 23 20:49:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sarah Morgensen X-Patchwork-Id: 30653 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3828727BC81; Wed, 23 Jun 2021 21:50:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8325927BC78 for ; Wed, 23 Jun 2021 21:50:27 +0100 (BST) Received: from localhost ([::1]:50876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lw9pK-0001EV-G9 for patchwork@mira.cbaines.net; Wed, 23 Jun 2021 16:50:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw9ow-0001EF-KG for guix-patches@gnu.org; Wed, 23 Jun 2021 16:50:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lw9ow-0002zB-Cj for guix-patches@gnu.org; Wed, 23 Jun 2021 16:50:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lw9ow-0005HS-CU for guix-patches@gnu.org; Wed, 23 Jun 2021 16:50:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49196] [PATCH] import: utils: 'recursive-import' skips unfound packages Resent-From: Sarah Morgensen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 23 Jun 2021 20:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49196 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49196@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162448136920254 (code B ref -1); Wed, 23 Jun 2021 20:50:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Jun 2021 20:49:29 +0000 Received: from localhost ([127.0.0.1]:41920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lw9oI-0005GV-JF for submit@debbugs.gnu.org; Wed, 23 Jun 2021 16:49:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:38158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lw9oF-0005GM-Pz for submit@debbugs.gnu.org; Wed, 23 Jun 2021 16:49:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw9oE-00012h-2n for guix-patches@gnu.org; Wed, 23 Jun 2021 16:49:18 -0400 Received: from out0.migadu.com ([94.23.1.103]:41681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw9o9-0002S5-8I for guix-patches@gnu.org; Wed, 23 Jun 2021 16:49:17 -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=1624481348; 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=GIqMS4yx7U+W6hvM9xbuYm1hHoQwWWIqtyxX/iDNpsA=; b=eojOVO7SEM39PfXQZC0DWvOKwBhvhqlo+Mwz44Hq/AySf9/71AMvlVdLsRahuoo75XDN6d YZThzBqwePkOTbpmkTjWj45b4+j589tHUNx4jGCunA+a9a5fMTijUJuTEmOiD/nz0VMPwL DnBU2L1fLxQha7pyhgU4023rPYNq1hA= Date: Wed, 23 Jun 2021 13:49:05 -0700 Message-Id: <07d7149fc0f89f7f2d11fba47e1b0b2db5ceb809.1624479231.git.iskarian@mgsn.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: iskarian@mgsn.dev Received-SPF: pass client-ip=94.23.1.103; envelope-from=iskarian@mgsn.dev; helo=out0.migadu.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_DNSWL_LOW=-0.7, 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: Sarah Morgensen X-ACL-Warn: , Sarah Morgensen via Guix-patches X-Patchwork-Original-From: Sarah Morgensen via Guix-patches via From: Sarah Morgensen X-getmail-retrieved-from-mailbox: Patches * guix/import/utils.scm (recursive-import): Skip packages when the package returned by repo->guix-package is false. * guix/import/go.scm (go-module-recursive-import): Explicitly return false in 'repo->guix-package' when packages are not found. * tests/import-utils.scm ("recursive-import: skip false packages"): New test. --- Hello Guix, While trying to recursively import a go package I encountered the following error when it was unable to find one of the dependencies: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix import go -r git.sr.ht/~sircmpwn/aerc guix import: warning: Failed to import package "github.com/brunnre8/go.notmuch". reason: "https://pkg.go.dev/github.com/brunnre8/go.notmuch" could not be fetched: HTTP error 404 ("Not Found"). This package and its dependencies won't be imported. following redirection to `https://github.com/ProtonMail/go-crypto?go-get=1'... following redirection to `https://github.com/jtolio/gls?go-get=1'... Backtrace: In srfi/srfi-1.scm: 586:29 19 (map1 ((package (name "go-github-com-rivo-uniseg") …) …)) 586:29 18 (map1 ((package (name "go-github-com-mattn-go-r…") …) …)) 586:29 17 (map1 ((package (name "go-github-com-miolini-da…") …) …)) 586:29 16 (map1 ((package (name "go-github-com-riywo-logi…") …) …)) 586:29 15 (map1 ((package (name "go-github-com-neelance-a…") …) …)) 586:29 14 (map1 ((package (name "go-github-com-neelance-s…") …) …)) 586:29 13 (map1 ((package (name "go-github-com-shurcool-go") …) …)) 586:29 12 (map1 ((package (name "go-github-com-shurcool-h…") …) …)) 586:29 11 (map1 ((package (name "go-github-com-shurcool-v…") …) …)) 586:29 10 (map1 ((package (name "go-github-com-gopherjs-g…") …) …)) 586:29 9 (map1 ((package (name "go-github-com-jtolds-gls") # …) …)) 586:29 8 (map1 ((package (name "go-github-com-smartystre…") …) …)) 586:29 7 (map1 ((package (name "go-github-com-smartystre…") …) …)) 586:29 6 (map1 ((package (name "go-github-com-google-go-…") …) …)) 586:29 5 (map1 ((package (name "go-google-golang-org-pro…") …) …)) 586:29 4 (map1 ((package (name "go-github-com-golang-pro…") …) …)) 586:29 3 (map1 ((package (name "go-google-golang-org-app…") …) …)) 586:29 2 (map1 ((package (name "go-github-com-protonmail…") …) …)) 586:17 1 (map1 (() (package (name "go-git-sr-ht-~sircmpwn…") …))) In guix/import/utils.scm: 280:2 0 (package->definition _ _) guix/import/utils.scm:280:2: In procedure package->definition: Throw to key `match-error' with args `("match" "no matching pattern" ())'. --8<---------------cut here---------------end--------------->8--- It seems like several importers (gem, egg, go) expect to be able to return #f or '() in #:repo->guix-package when a package is not found (while printing a warning to the user) but recursive-import doesn't look like it handles it. I suppose this worked before but was silently broken at some point. This patch (re-)enables this behavior. I added a test for this as well. Hope this helps, Sarah guix/import/go.scm | 3 ++- guix/import/utils.scm | 14 ++++++++------ tests/import-utils.scm | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) base-commit: acfa55a581ca4e688ee4b8f860fe365b1f153ef9 diff --git a/guix/import/go.scm b/guix/import/go.scm index d110954664..c859098492 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Ludovic Courtès ;;; Copyright © 2021 Xinglu Chen +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -651,7 +652,7 @@ This package and its dependencies won't be imported.~%") (uri->string (http-get-error-uri c)) (http-get-error-code c) (http-get-error-reason c)) - (values '() '()))) + (values #f '()))) (receive (package-sexp dependencies) (go-module->guix-package* name #:goproxy goproxy #:version version diff --git a/guix/import/utils.scm b/guix/import/utils.scm index d817318a91..49f38cfa2a 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> ;;; Copyright © 2020 Martin Becze ;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -469,16 +470,17 @@ to obtain the Guix package name corresponding to the upstream name." (normalized-deps (map (match-lambda ((name version) (list name version)) (name (list name #f))) dependencies))) - (make-node name version package normalized-deps))) + (and package + (make-node name version package normalized-deps)))) (map node-package (topological-sort (list (lookup-node package-name version)) (lambda (node) - (map (lambda (name-version) - (apply lookup-node name-version)) - (remove (lambda (name-version) - (apply exists? name-version)) - (node-dependencies node)))) + (filter-map (lambda (name-version) + (apply lookup-node name-version)) + (remove (lambda (name-version) + (apply exists? name-version)) + (node-dependencies node)))) (lambda (node) (string-append (node-name node) diff --git a/tests/import-utils.scm b/tests/import-utils.scm index 874816442e..1b728104e0 100644 --- a/tests/import-utils.scm +++ b/tests/import-utils.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015, 2017 Ricardo Wurmus ;;; Copyright © 2016 Ben Woodcroft ;;; Copyright © 2020 Martin Becze +;;; Copyright © 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. ;;; @@ -64,6 +65,23 @@ '()))) #:guix-name identity)) +(test-equal "recursive-import: skip false packages" + '((package + (name "foo") + (inputs `(("bar" ,bar))))) + (recursive-import "foo" + #:repo 'repo + #:repo->guix-package + (match-lambda* + (("foo" #:version #f #:repo 'repo) + (values '(package + (name "foo") + (inputs `(("bar" ,bar)))) + '("bar"))) + (("bar" #:version #f #:repo 'repo) + (values #f '()))) + #:guix-name identity)) + (test-assert "alist->package with simple source" (let* ((meta '(("name" . "hello") ("version" . "2.10")