From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0O9+KrkG1mAS+gAAgWs5BA (envelope-from ) for ; Fri, 25 Jun 2021 18:39:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id qOI/JrkG1mBUUwAAB5/wlQ (envelope-from ) for ; Fri, 25 Jun 2021 16:39:21 +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 EB0B52B30B for ; Fri, 25 Jun 2021 18:39:20 +0200 (CEST) Received: from localhost ([::1]:43698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lworP-00067q-UQ for larch@yhetil.org; Fri, 25 Jun 2021 12:39:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lworA-00066j-6z for guix-patches@gnu.org; Fri, 25 Jun 2021 12:39:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35153) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwor8-0007UM-Ny for guix-patches@gnu.org; Fri, 25 Jun 2021 12:39:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lwor8-0001Kj-K8 for guix-patches@gnu.org; Fri, 25 Jun 2021 12:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49196] [PATCH v3 3/3] import: go: Improve error handling. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Jun 2021 16:39:02 +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.16246390935035 (code B ref 49196); Fri, 25 Jun 2021 16:39:02 +0000 Received: (at 49196) by debbugs.gnu.org; 25 Jun 2021 16:38:13 +0000 Received: from localhost ([127.0.0.1]:46696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lwoqK-0001J6-E9 for submit@debbugs.gnu.org; Fri, 25 Jun 2021 12:38:12 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:34577) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lwoqF-0001I9-46 for 49196@debbugs.gnu.org; Fri, 25 Jun 2021 12:38:08 -0400 Received: by mail-wr1-f47.google.com with SMTP id e22so11269317wrc.1 for <49196@debbugs.gnu.org>; Fri, 25 Jun 2021 09:38:07 -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=i1UQbryFVBMTxsNb3xibfTlsptO7S3Oy039jdx7j4nw=; b=IuaLey39yLNp04yAI132qRrUdOfzXpdHNfBKgpNcgYm5iqGLIVDxr9eUEXMi8IbIo+ 2ofzLXWpW+MaTx0dtfWdD01lf4dG0MZIWxlH8TFcVzXuJQVkAsN9i6Yf1ZoiNNsehLDt R+9FUE2iUsnOESw58iyX8caV3lms/LH1FOrNWdPmAG0eb+QZWfpzcbSRG1Fpnwkwgv0S TZnDZsX+M3UnGoBbwLpIJvhl5Yn/5/MSk3HAB6diSBGAW+LwTUul4lEfSO80g2wNpLGq PLR3jHqQ+ovMvEeWBhEb+0rN0/U/J9ZSSv/cKwbJQxUV2/Wm8Cgz1xYCBl1Ws3f7aa9V 0YlA== 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=i1UQbryFVBMTxsNb3xibfTlsptO7S3Oy039jdx7j4nw=; b=pcA1mkZycVNu2vV8I4vRGqt2ViP2Pp8+YWeSukTbZt8fzxrF69dhk6cf2/tY+A39Mt WqkzhcQqqNj+qvMxP008oE40DzfzkjLOLPEnAHduN9Os8cs50KXLOAMHK+t03+b+/BlW 8+EZRWKpRjGsuq1B5wLvpx9U8TKYxSKLPSI9nt27MrSQua73ysNAcMoHxf/fsFRK0386 /YYJFXtxeKb8u+exskzzgtn9HS960Eb+f6oOTCGN8rI7C3FiIWkqODK9Nmf3Bk/hNcq6 deJCEUZQpPSBX5iLd6p0RHI5dCLeXL542A9c10qnNIKf2oa/U2eCPbEeA7auKuhEgeo9 b7ew== X-Gm-Message-State: AOAM5328SEqsPq4oETIphdluW+n0czacVBVd6KEEVOvZ4tGafQzTGLJm xe2GzJqObTQ+mWXzDCQ2CcpEJWSpPSM= X-Google-Smtp-Source: ABdhPJw/qWKGdnl/NqK/r2AIwCfZ1Tl+sSUvmA+UKwZhirrhIVtRfsid4s8XTs8gRhu406aYDUwsiQ== X-Received: by 2002:adf:9bd0:: with SMTP id e16mr12101162wrc.392.1624639081291; Fri, 25 Jun 2021 09:38:01 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.110]) by smtp.gmail.com with ESMTPSA id 2sm11642170wmk.24.2021.06.25.09.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 09:38:01 -0700 (PDT) From: zimoun Date: Fri, 25 Jun 2021 18:37:49 +0200 Message-Id: <20210625163749.65196-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210625163749.65196-1-zimon.toutoune@gmail.com> References: <20210625163749.65196-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=1624639161; 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=i1UQbryFVBMTxsNb3xibfTlsptO7S3Oy039jdx7j4nw=; b=Pi12hESH1iQFFAqUuNeN+9G2iTMfLgfBaMPjPEvDPilqji6przKgR5/GgiwV+jpjj5Ilid 6mQ+v73vkDpEhVJ5G9sVe4gW5sgaPYNvfone+KijnjYsHe4mDz3K+lJ66g/SNtFkKFEFxV a4INMiyHBYLRIjHTB7WeBjPEEsIAtGLc7aR1FWv1IfuJpLcxvIkzPCE42exWaKexKDjkMf HtzB+uGpolDg451pli1z9K1AxvP7qQ61IO8696unhGbn4v9LlIBgFQrYgkiWKJ/oOPWQqj sKylmcuijKBjkAwDs0Rh+GyWZk5NIkqBKYsUBH/a5LvZqHQ8DXdAVkoc8kJFYw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624639161; a=rsa-sha256; cv=none; b=fvya/wgGAXfCsAGeCDfiEeZAdVJXbCi9l/5Nb8HQ4zNr/KZh/z4SMs/3aLQ4ZMHf89p1Oz cyPeuBp0tVFsQdk2romkzh4yNH1r+NlEMUuTz9wbKS9I3CLAwT7TvvFszvDeq2cINqkuhb VAM8VgILfMJ1pisDDRmsZtjPtI/8lxoFS0u1YHSeok+gdW/3wg6iGoPJGRmer5Qv/G+e49 bDIMSlNKASp5HyMGOQAUYS0HF8gQQ6CpRsuJuBXMKWE4ZMNEZ1mvDaWAwBPrCBTbsfAgmi th1vXFnyil1QCNInuH2qwdQxpuXZF//rPOzpyvaCwJUdUPORhUS+JeYZaP4+Tg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=IuaLey39; 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.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=IuaLey39; 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: EB0B52B30B X-Spam-Score: -1.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: GgLLTpGK0BZF * 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 | 43 ++++++++++++++++++++++---------------- guix/scripts/import/go.scm | 6 +++--- tests/go.scm | 2 +- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index c859098492..c559f02e5b 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2021 Ludovic Courtès ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Sarah Morgensen +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -61,7 +62,7 @@ #:use-module (web response) #:use-module (web uri) - #:export (go-module->guix-package + #:export (go-module->guix-package* go-module-recursive-import)) ;;; Commentary: @@ -630,17 +631,9 @@ 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-recursive-import package-name - #:key (goproxy "https://proxy.golang.org") - version - pin-versions?) - - (recursive-import - package-name - #:repo->guix-package - (lambda* (name #:key version repo) +(define go-module->guix-package* + (memoize + (lambda args ;; Disable output buffering so that the following warning gets printed ;; consistently. (setvbuf (current-error-port) 'none) @@ -648,15 +641,29 @@ hint: use one of the following available versions ~a\n" (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 + (match args ((name _ ...) name)) (uri->string (http-get-error-uri c)) (http-get-error-code c) (http-get-error-reason c)) + (values #f '())) + (else + (warning (G_ "Something went wrong with ~s.~%") args) (values #f '()))) - (receive (package-sexp dependencies) - (go-module->guix-package* name #:goproxy goproxy - #:version version - #:pin-versions? pin-versions?) - (values package-sexp dependencies)))) + (apply go-module->guix-package args))))) + +(define* (go-module-recursive-import package-name + #:key (goproxy "https://proxy.golang.org") + version + pin-versions?) + + (recursive-import + package-name + #:repo->guix-package + (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