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 OBE0LZv32WDsdAAAgWs5BA (envelope-from ) for ; Mon, 28 Jun 2021 18:23:55 +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 GE8LKZv32WCKGgAAbx9fmQ (envelope-from ) for ; Mon, 28 Jun 2021 16:23:55 +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 CBDB119C86 for ; Mon, 28 Jun 2021 18:23:54 +0200 (CEST) Received: from localhost ([::1]:54684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxu37-0002QM-Gv for larch@yhetil.org; Mon, 28 Jun 2021 12:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lxu0O-0004nU-Ua for guix-patches@gnu.org; Mon, 28 Jun 2021 12:21:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lxu0N-0000UO-Me for guix-patches@gnu.org; Mon, 28 Jun 2021 12:21:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lxu0N-0005Ws-JT for guix-patches@gnu.org; Mon, 28 Jun 2021 12:21:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49196] [PATCH v4 3/3] import: go: Improve error handling. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 28 Jun 2021 16:21: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.162489724821186 (code B ref 49196); Mon, 28 Jun 2021 16:21:03 +0000 Received: (at 49196) by debbugs.gnu.org; 28 Jun 2021 16:20:48 +0000 Received: from localhost ([127.0.0.1]:52333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lxu06-0005Va-5Q for submit@debbugs.gnu.org; Mon, 28 Jun 2021 12:20:47 -0400 Received: from mail-wr1-f49.google.com ([209.85.221.49]:41861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lxtzq-0005UW-1l for 49196@debbugs.gnu.org; Mon, 28 Jun 2021 12:20:45 -0400 Received: by mail-wr1-f49.google.com with SMTP id u8so8683847wrq.8 for <49196@debbugs.gnu.org>; Mon, 28 Jun 2021 09:20:30 -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=l/x0W3/XbvXoKmOKYcgxtiOksxk+Xm5/lB61rm36/pI=; b=LmRo6e6t2eSJVDdktPPfz16VcqydcYm8g4+IRRALgZRkKAPjRkMgte7zvBo8t9cDzN TWhHgMGC3zyErmmkPLFybwzfCwVQzIYlVoU3sFrtR4paqGMZisWP7mv/l0/ylPWZneBW cQo8YrRv0QOkDrnQzKBPIfm6p2M3mz1QNsuCpQpsrcX6SoADqC5b1wkBpP8txrYJzHVW M5FpC+XDrSQ35ne6n3/EIID6B0kvz21u+v9DUsWhcj/en3gpAgNLB/EcrVCHeVpC4KTR YOtxJRfIM1npKM75ZEJgvyQoFiUbBXR6Kp9IVn8rGjynsaSwcd0cqzrInngE9B7HQYvC Wg1A== 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=l/x0W3/XbvXoKmOKYcgxtiOksxk+Xm5/lB61rm36/pI=; b=knUtJtT6U+xnr8BpDaQWgsxj0Se/uBkoHj0kmnoRZGaDQX7jA1C9BAXPCRrxmsD4Ur bUB2+1oZB2r1hJ9vjCedEDu9xjKqtdHEUXSctOkPznqqJFmXfLK8kspJkdturx0VOZDN 0Eyb8Jrlf064SFJuawXnPToz3Cl+j7m5gWnLSWz1RN6XsW3ApcCLfeJNITJNfh/qJQJ0 ZDxDIBbX1P797HHUY+z/cOBsdO5BAQbSOVm+Tx4pDTAkVNktYY5KyTpnt03Dhs23uxOd H7zwC81AGFNJpAdNKWfbiRtPBor/zoacUdT4JT/yvHG1z5oh4k7oLl2xEuSq+QWrCWpw Ox2w== X-Gm-Message-State: AOAM530lJLEbv0D1jUA/bcLy/uCLtgXkjXH/04MTqli0Us7xckMiuvPx /E3wrtYNN+wT0z0AYqSeJCgLYIz8NpM= X-Google-Smtp-Source: ABdhPJz6cI9aA9S/z303Uq1vln1W+FEsOWPkm0u/WW6MjDBZTuTSbmg2Bm3tWdYQKrZJCvFMRNZVKg== X-Received: by 2002:a05:6000:1251:: with SMTP id j17mr28543979wrx.122.1624897224606; Mon, 28 Jun 2021 09:20:24 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.110]) by smtp.gmail.com with ESMTPSA id v18sm17050567wrv.24.2021.06.28.09.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 09:20:24 -0700 (PDT) From: zimoun Date: Mon, 28 Jun 2021 18:20:14 +0200 Message-Id: <20210628162014.15319-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210628162014.15319-1-zimon.toutoune@gmail.com> References: <20210628162014.15319-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=1624897435; 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=l/x0W3/XbvXoKmOKYcgxtiOksxk+Xm5/lB61rm36/pI=; b=hpvpBVzQAobbYDVMAQjdcN2j8Lv3pwFU53FvShKYnuNUO/1Lv3dNCUbkC+gyyFQFvOTfdP jqyV38DB+bkgqiZMFHu5VInH1H+OAfYKAE5G4xev5XMcHs8v4VVvPNLMYHEAgcRDEISbVF KewwUVG0AYU5MCU7liIphbcJ10uRzb6x8TtP1iW/PSAIYisQ+WxCeRN30zRJDP2Aii91K+ kbmpkFzyDh770K4xs3GWXpDN0pIQcOlbV24UYzMHfghdLIAwDyqeYXHbsZDSBCcpg6fgt/ tQjl6Jb6RD4Ywcgy/aAVeeP16wRPkNaiTLEwxMwsdx8ZKFY6TCeOmy+/vV4njg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624897435; a=rsa-sha256; cv=none; b=CnSEnMIUkg0LbnSLzhzXST53Slii3nzbTkCkj0U5cpITAdcmx1btO89TDJLdbnG7NyFLZq 29V+210+LqI3VXgHTd8UfUNge8HEp78x0fmreejAPOsyJZNyuY+n1OTyDZTM1ZV9V+yVNq XGEAxq6fKmHAcd55/Y35vnD37NNShyDNwd4t5e+YKwYm5DZQXVKYKPtydq6rwvq/T4bZSe vcc9I5Nqk5C6Yo0JOo17Zkc1pVw4CG18+Ub5+U/33TWUOmIXEqL++JS1G9tfGf+MTMuzqk /EhcMjdlKkHEhrt58Nb2ttA7ulDARAi7utAQvmdGEgMCgkyBmA7v4Ac8Ve7gXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=LmRo6e6t; 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: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=LmRo6e6t; 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: CBDB119C86 X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: uyVT8x37XZqL * guix/import/go.scm (go-module->guix-package*): Handle errors. (go-module-recursive-import): Remove 'guard'. * guix/scripts/import/go.scm (guix-import-go): Adjust. * tests/go.scm: Adjust. --- guix/import/go.scm | 49 +++++++++++++++++++++++--------------- guix/scripts/import/go.scm | 6 ++--- tests/go.scm | 2 +- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index a2863c79ad..e7d8bc3959 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") @@ -642,22 +665,10 @@ hint: use one of the following available versions ~a\n" 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)))) + (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