From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gA7XHNr72mDo2gAAgWs5BA (envelope-from ) for ; Tue, 29 Jun 2021 12:54:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CMiAGNr72mA2DAAAbx9fmQ (envelope-from ) for ; Tue, 29 Jun 2021 10:54:18 +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 EAFE22855C for ; Tue, 29 Jun 2021 12:54:17 +0200 (CEST) Received: from localhost ([::1]:56444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyBNg-0003fd-Vs for larch@yhetil.org; Tue, 29 Jun 2021 06:54:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyBNU-0003e6-0S for guix-patches@gnu.org; Tue, 29 Jun 2021 06:54:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyBNT-0000Dt-B7 for guix-patches@gnu.org; Tue, 29 Jun 2021 06:54:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyBNT-0007qR-AW for guix-patches@gnu.org; Tue, 29 Jun 2021 06:54:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49196] [PATCH v5 3/3] import: go: Improve error handling. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 29 Jun 2021 10:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49196 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49196@debbugs.gnu.org Cc: iskarian@mgsn.dev, zimoun Received: via spool by 49196-submit@debbugs.gnu.org id=B49196.162496398830080 (code B ref 49196); Tue, 29 Jun 2021 10:54:03 +0000 Received: (at 49196) by debbugs.gnu.org; 29 Jun 2021 10:53:08 +0000 Received: from localhost ([127.0.0.1]:53688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyBMZ-0007p6-TA for submit@debbugs.gnu.org; Tue, 29 Jun 2021 06:53:08 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:44920) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyBMS-0007o5-69 for 49196@debbugs.gnu.org; Tue, 29 Jun 2021 06:53:02 -0400 Received: by mail-wm1-f44.google.com with SMTP id m9-20020a05600c3b09b02901f246b43bbeso62521wms.3 for <49196@debbugs.gnu.org>; Tue, 29 Jun 2021 03:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6GnBx654lagXlXKu1Fv1bgbXFV7lglLDoD95AU3q25o=; b=Jxk7jmw7Ttio7H3lfp7HCYx4Ie+kmScR8UWwt+VX7N7PGmWed9/s7fb9gW0IcyyRcz Ah0NFFbxWnZNZWtgr+loBBROW0nRmIsGoQ+qlB5xz9oloaNzex0fGS/Jsc2wKcG0rlzM r2cMza1Ij2OM1+DP5vAVC1csaraDOrTly1hw6oK8G/dP+lhg5yV+VDGKd71u7NhFbNOn XIxD/CZEYQkxdWjsfoHvvRT0l7jRCYhs3AwNr+pIOEgGDEiVmZQREd7K1HKbuCiD2H6x 4Th+qXX4NmmPOqQ1e0/fIxqWjf6oTLdShSvewGzFWwkJ23w+20Vp4Rtht2WPIh6TebLA /IDQ== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6GnBx654lagXlXKu1Fv1bgbXFV7lglLDoD95AU3q25o=; b=Z0bkbc93v0REoHHKKkxU455TJTwvJuTWRFsCCJbt0kxljF6GExsFS8dd5iBklom/ao 2hC9wJC8H4h7mYfDPxaN0TFj9ZRkSicJao10lz19Bjb4dGWs7PQwo5l90jSADABrIm8f uEwBloLB1FnaNTfQXMZcikrI3KCyqwBd4dB4O/3LUBvQ12tZ7i8rnzF7m+UQeiXACiEd laqCTKTGt2H4uzZffxXjDrYh8iqPNsalpauccHeLe3Ukbs7B+G+HSIxlDIEBeRjdGxbj iHovlww5HeH5C6MayUHyGGELM0iDoQabELMYAZTOktCfFQpjrX0A/fdUNYs8EUZ1oFxA biGQ== X-Gm-Message-State: AOAM532UeCM+bSPMu3unYIEhovaDnQ71hRDwMlLVZTXiTHyh0dW/AwWx sgVI7xdyjgrteN31FiQx9aWaERs2BdY= X-Google-Smtp-Source: ABdhPJyrxx5G4F+mj5EcSTZJ/fOoMOzIn6eTl02c8MdXQ9obfTtaj5cH1CC1gEfdlANwXORC8cicrQ== X-Received: by 2002:a05:600c:4ecd:: with SMTP id g13mr32295835wmq.174.1624963974492; Tue, 29 Jun 2021 03:52:54 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.110]) by smtp.gmail.com with ESMTPSA id c7sm17784794wrs.23.2021.06.29.03.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 03:52:54 -0700 (PDT) From: zimoun Date: Tue, 29 Jun 2021 12:52:37 +0200 Message-Id: <20210629105237.45517-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210629105237.45517-1-zimon.toutoune@gmail.com> References: <20210629105237.45517-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624964058; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: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:dkim-signature; bh=6GnBx654lagXlXKu1Fv1bgbXFV7lglLDoD95AU3q25o=; b=kZTii/9ElWZDwearwTh+4TYvZnXWa7xLSom7PaSBRPDE8qqY6dbUKXolqNsPq4PRS7hdRC 1Ngg2i65IFyzlYAMb/L7v21nVemX+T6yhm0rhialzxH9qgbYuo3AI2eQm3K/+elVdmYr1b 8nWc9IwA1VdYaubgqiBe5gDnVEFTJdte7u+PTWEHuNSGqk/B1Ewp/U/wO+vzTWMZonc3ma rbTKkhPfnZZtOMNT1hBWfHX4PkMgDH7N2/VZzAD1EmNOxWiYRJ2PrSo6PNPoSL+mNfNYY2 W9ZOTn5zdPVJ92HI9ZASFj8NJp4J64FjsWXY0tquqILSu02xwN4A5G0vhZRvAg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624964058; a=rsa-sha256; cv=none; b=n0+1NWBRzX5kK1P1lrUT7CshiOiKlRO8IRn0YoPNnZaHsrx7ZORj1Xblnn4PJpKE0xGfez mKAWh8QUsFTPNpH08wPKcuzXz+Z+XTBu9PHre9IaSZjO0NvwdVlZiVdf1uZmKhhWJJ2Iw9 5ynSFLlI+9iixcKSmChzKlXWbnWvV8TIyb38xWRSdNB6mPOuJYfF7Jquv1zi9PHCNlQLYP OnX0cn/OlAeTi1DhlSTd+rROTqWKoCAXLYv9UwHju0GNGWtEN/7LH8PlHHUKNHMMYHigtB 8JxpzehxlTgCqLrB9ddx6UopjI/ev0Ruy87eiYuF70A1QpahYC7OJOmbA2YkNQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=Jxk7jmw7; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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-Migadu-Spam-Score: 0.18 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=Jxk7jmw7; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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-Migadu-Queue-Id: EAFE22855C X-Spam-Score: 0.18 X-Migadu-Scanner: scn0.migadu.com X-TUID: D9wavKKzTiHl * guix/import/go.scm (go-module->guix-package*): Handle errors, remove memoize. (go-module-recursive-import): Remove 'guard', add memoize. * guix/scripts/import/go.scm (guix-import-go): Adjust. * tests/go.scm: Adjust. --- guix/import/go.scm | 52 +++++++++++++++++++++++--------------- guix/scripts/import/go.scm | 6 ++--- tests/go.scm | 2 +- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index a2863c79ad..5bec31201d 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -5,7 +5,8 @@ ;;; Copyright © 2021 Maxim Cournoyer ;;; Copyright © 2021 Ludovic Courtès ;;; Copyright © 2021 Xinglu Chen -;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -62,6 +63,7 @@ #:use-module (web uri) #:export (go-module->guix-package + go-module->guix-package* go-module-recursive-import)) ;;; Commentary: @@ -631,7 +633,28 @@ hint: use one of the following available versions ~a\n" dependencies+versions dependencies)))) -(define go-module->guix-package* (memoize go-module->guix-package)) +(define go-module->guix-package* + (lambda args + ;; Disable output buffering so that the following warning gets printed + ;; consistently. + (setvbuf (current-error-port) 'none) + (let ((package-name (match args ((name _ ...) name)))) + (guard (c ((http-get-error? c) + (warning (G_ "Failed to import package ~s. +reason: ~s could not be fetched: HTTP error ~a (~s). +This package and its dependencies won't be imported.~%") + package-name + (uri->string (http-get-error-uri c)) + (http-get-error-code c) + (http-get-error-reason c)) + (values #f '())) + (else + (warning (G_ "Failed to import package ~s. +reason: ~s.~%") + package-name + (exception-args c)) + (values #f '()))) + (apply go-module->guix-package args))))) (define* (go-module-recursive-import package-name #:key (goproxy "https://proxy.golang.org") @@ -641,23 +664,12 @@ hint: use one of the following available versions ~a\n" (recursive-import package-name #:repo->guix-package - (lambda* (name #:key version repo) - ;; Disable output buffering so that the following warning gets printed - ;; consistently. - (setvbuf (current-error-port) 'none) - (guard (c ((http-get-error? c) - (warning (G_ "Failed to import package ~s. -reason: ~s could not be fetched: HTTP error ~a (~s). -This package and its dependencies won't be imported.~%") - name - (uri->string (http-get-error-uri c)) - (http-get-error-code c) - (http-get-error-reason c)) - (values #f '()))) - (receive (package-sexp dependencies) - (go-module->guix-package* name #:goproxy goproxy - #:version version - #:pin-versions? pin-versions?) - (values package-sexp dependencies)))) + (memoize + (lambda* (name #:key version repo) + (receive (package-sexp dependencies) + (go-module->guix-package* name #:goproxy goproxy + #:version version + #:pin-versions? pin-versions?) + (values package-sexp dependencies)))) #:guix-name go-module->guix-package-name #:version version)) diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm index 74e8e60cce..071ecdb2ef 100644 --- a/guix/scripts/import/go.scm +++ b/guix/scripts/import/go.scm @@ -115,10 +115,10 @@ that are not yet in Guix")) (map package->definition* (apply go-module-recursive-import arguments)) ;; Single import. - (let ((sexp (apply go-module->guix-package arguments))) + (let ((sexp (apply go-module->guix-package* arguments))) (unless sexp - (leave (G_ "failed to download meta-data for module '~a'~%") - module-name)) + (leave (G_ "failed to download meta-data for module '~a'.~%") + name)) (package->definition* sexp)))))) (() (leave (G_ "too few arguments~%"))) diff --git a/tests/go.scm b/tests/go.scm index b088ab50d2..929a8b39d1 100644 --- a/tests/go.scm +++ b/tests/go.scm @@ -286,6 +286,6 @@ package.") (nix-base32-string->bytevector "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5") #f))) - (go-module->guix-package "github.com/go-check/check"))))))) + (go-module->guix-package* "github.com/go-check/check"))))))) (test-end "go") -- 2.32.0