GNU bug report logs - #51091
[PATCH] guix: opam: Do not fail when refreshing.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Julien Lepiller <julien@HIDDEN>; Keywords: patch; dated Fri, 8 Oct 2021 03:04:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 51091 <at> debbugs.gnu.org:


Received: (at 51091) by debbugs.gnu.org; 18 Oct 2021 08:39:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 18 04:39:14 2021
Received: from localhost ([127.0.0.1]:45913 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mcOAr-0001HB-QJ
	for submit <at> debbugs.gnu.org; Mon, 18 Oct 2021 04:39:14 -0400
Received: from eggs.gnu.org ([209.51.188.92]:33732)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mcOAq-0001H0-PI
 for 51091 <at> debbugs.gnu.org; Mon, 18 Oct 2021 04:39:13 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:59946)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mcOAk-0001MT-Nb; Mon, 18 Oct 2021 04:39:06 -0400
Received: from [193.50.110.252] (port=58232 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mcOAk-0005qV-DT; Mon, 18 Oct 2021 04:39:06 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Julien Lepiller <julien@HIDDEN>
Subject: Re: bug#51091: [PATCH v2] guix: opam: Do not fail when refreshing.
References: <20211008050310.407d6b23@HIDDEN>
 <87y272lepg.fsf@HIDDEN> <871r4nrc9t.fsf_-_@HIDDEN>
 <20211016041009.5b4ddff0@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 27 =?utf-8?Q?Vend=C3=A9miaire?= an 230 de la
 =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 18 Oct 2021 10:39:04 +0200
In-Reply-To: <20211016041009.5b4ddff0@HIDDEN> (Julien
 Lepiller's message of "Sat, 16 Oct 2021 04:10:09 +0200")
Message-ID: <87sfwybuc7.fsf@HIDDEN>
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
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 51091
Cc: 51091 <at> debbugs.gnu.org, Xinglu Chen <public@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi!

Julien Lepiller <julien@HIDDEN> skribis:

> Thanks for the reviews! I've managed to use conditions, which was not
> easy because I didn't notice there was already a "condition" defined,
> and that lead to weird error messages. Attached is the updated patch.

Oh, I see.

> From 0cadac6c3dabea8b986cd59d97c84beaf7a33325 Mon Sep 17 00:00:00 2001
> Message-Id: <0cadac6c3dabea8b986cd59d97c84beaf7a33325.1634350078.git.juli=
en@HIDDEN>
> From: Julien Lepiller <julien@HIDDEN>
> Date: Fri, 8 Oct 2021 04:58:27 +0200
> Subject: [PATCH] import: opam: Do not fail when refreshing.
>
> Because we throw an error when a package is not in the opam repository,
> the updater would crash when encountering a package that is not in opam
> but uses the ocaml-build-system, such as opam itself.  This catches the
> error and continues without updating said package, and lets us update
> the rest of the packages.
>
> * guix/scripts/import/opam.scm (guix-import-opam): Catch not-found
> condition and leave.
> * guix/import/opam.scm (&opam-not-found-error): New condition type.
> (opam-fetch): Raise condition instead of leaving.
> (latest-release): Catch not-found condition and warn.
> (conditional): Rename from `condition'.
> * tests/opam.scm (parse-conditions): Change accordingly.

LGTM, thanks!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#51091; Package guix-patches. Full text available.

Message received at 51091 <at> debbugs.gnu.org:


Received: (at 51091) by debbugs.gnu.org; 16 Oct 2021 02:10:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 15 22:10:25 2021
Received: from localhost ([127.0.0.1]:40651 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mbZ9V-0004Tc-EO
	for submit <at> debbugs.gnu.org; Fri, 15 Oct 2021 22:10:25 -0400
Received: from lepiller.eu ([89.234.186.109]:35668)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <julien@HIDDEN>) id 1mbZ9R-0004TP-7M
 for 51091 <at> debbugs.gnu.org; Fri, 15 Oct 2021 22:10:24 -0400
Received: from lepiller.eu (localhost [127.0.0.1])
 by lepiller.eu (OpenSMTPD) with ESMTP id df1c9c26;
 Sat, 16 Oct 2021 02:10:18 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from
 :to:cc:subject:message-id:in-reply-to:references:mime-version
 :content-type; s=dkim; bh=IPNDWEJCEwENk7ejKtUVydY5I/Z7J9NF7fDY38
 K5Uws=; b=H/DXYNmFMH5Ny/O6z8pGEb7AHhMO2Qq0Mnl7lOfsSZSXnYH0dOV4Kr
 vRSksk9VxcKnGdgtzc1WwPD9Zm03x+u4uMJZ4M+fxtCbQte29qHqaQr9SApKWVWQ
 DMR+Em9VcNR3xnQfxbLT9apVxxuUxaGSjPdIaKX1fBmn2uL4YIk8lN2agyvBbjZC
 hPJGnuvE9sDnDapd+SEtvGnHODRmlYSoVjnQlnvp0da3707xu5d94qfpKc+/jGo6
 DQ5pR4h4XoPq1kjAX5Gs/OFTwc/e9AOlvOct/iduK68vpWgFR2gKWboqFbrMqHYV
 MhfXjX26FnXvVkiAiEC/Q0Ls77wmmHLA==
Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id ad558339
 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); 
 Sat, 16 Oct 2021 02:10:17 +0000 (UTC)
Date: Sat, 16 Oct 2021 04:10:09 +0200
From: Julien Lepiller <julien@HIDDEN>
To: Ludovic =?UTF-8?B?Q291cnTDqHM=?= <ludo@HIDDEN>
Subject: Re: bug#51091: [PATCH v2] guix: opam: Do not fail when refreshing.
Message-ID: <20211016041009.5b4ddff0@HIDDEN>
In-Reply-To: <871r4nrc9t.fsf_-_@HIDDEN>
References: <20211008050310.407d6b23@HIDDEN>
 <87y272lepg.fsf@HIDDEN> <871r4nrc9t.fsf_-_@HIDDEN>
X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MP_/kJPvXDquHX6Rc/CDmw1XNkI"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 51091
Cc: 51091 <at> debbugs.gnu.org, Xinglu Chen <public@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--MP_/kJPvXDquHX6Rc/CDmw1XNkI
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Thanks for the reviews! I've managed to use conditions, which was not
easy because I didn't notice there was already a "condition" defined,
and that lead to weird error messages. Attached is the updated patch.

--MP_/kJPvXDquHX6Rc/CDmw1XNkI
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0001-import-opam-Do-not-fail-when-refreshing.patch

From 0cadac6c3dabea8b986cd59d97c84beaf7a33325 Mon Sep 17 00:00:00 2001
Message-Id: <0cadac6c3dabea8b986cd59d97c84beaf7a33325.1634350078.git.julien@HIDDEN>
From: Julien Lepiller <julien@HIDDEN>
Date: Fri, 8 Oct 2021 04:58:27 +0200
Subject: [PATCH] import: opam: Do not fail when refreshing.

Because we throw an error when a package is not in the opam repository,
the updater would crash when encountering a package that is not in opam
but uses the ocaml-build-system, such as opam itself.  This catches the
error and continues without updating said package, and lets us update
the rest of the packages.

* guix/scripts/import/opam.scm (guix-import-opam): Catch not-found
condition and leave.
* guix/import/opam.scm (&opam-not-found-error): New condition type.
(opam-fetch): Raise condition instead of leaving.
(latest-release): Catch not-found condition and warn.
(conditional): Rename from `condition'.
* tests/opam.scm (parse-conditions): Change accordingly.
---
 guix/import/opam.scm         | 45 +++++++++++++++++++++++++-----------
 guix/scripts/import/opam.scm | 31 ++++++++++++++-----------
 tests/opam.scm               |  2 +-
 3 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index fe13d29f03..cd746f6dc6 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -30,6 +30,8 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
   #:use-module ((srfi srfi-26) #:select (cut))
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35)
   #:use-module ((web uri) #:select (string->uri uri->string))
   #:use-module ((guix build utils) #:select (dump-port find-files mkdir-p))
   #:use-module (guix build-system)
@@ -47,12 +49,16 @@
             opam-recursive-import
             %opam-updater
 
+            &opam-not-found-error
+            opam-not-found-error?
+            opam-not-found-error-package
+
             ;; The following patterns are exported for testing purposes.
             string-pat
             multiline-string
             list-pat
             dict
-            condition))
+            conditional))
 
 ;; Define a PEG parser for the opam format
 (define-peg-pattern comment none (and "#" (* COMMCHR) "\n"))
@@ -85,7 +91,7 @@
                     (and (or conditional-value ground-value) (* SP) (ignore "&") (* SP)
                          (or group-pat conditional-value ground-value)))
 (define-peg-pattern ground-value body (and (or multiline-string string-pat choice-pat list-pat var) (* SP)))
-(define-peg-pattern conditional-value all (and ground-value (* SP) condition))
+(define-peg-pattern conditional-value all (and ground-value (* SP) conditional))
 (define-peg-pattern string-pat all (and QUOTE (* STRCHR) QUOTE))
 (define-peg-pattern list-pat all (and (ignore "[") (* SP) (* (and value (* SP))) (ignore "]")))
 (define-peg-pattern var all (+ (or (range #\a #\z) "-")))
@@ -96,7 +102,7 @@
                          QUOTE QUOTE QUOTE))
 (define-peg-pattern dict all (and (ignore "{") (* SP) records (* SP) (ignore "}")))
 
-(define-peg-pattern condition body (and (ignore "{") condition-form (ignore "}")))
+(define-peg-pattern conditional body (and (ignore "{") condition-form (ignore "}")))
 
 (define-peg-pattern condition-form body
                     (and
@@ -310,6 +316,10 @@ path to the repository."
      (list dependency (list 'unquote (string->symbol dependency))))
    (ocaml-names->guix-names lst)))
 
+(define-condition-type &opam-not-found-error &error
+  opam-not-found-error?
+  (package opam-not-found-error-package))
+
 (define* (opam-fetch name #:optional (repositories-specs '("opam")))
   (or (fold (lambda (repository others)
               (match (find-latest-version name repository)
@@ -318,7 +328,7 @@ path to the repository."
                 (_ others)))
             #f
             (filter-map get-opam-repository repositories-specs))
-      (leave (G_ "package '~a' not found~%") name)))
+      (raise (condition (&opam-not-found-error (package name))))))
 
 (define* (opam->guix-package name #:key (repo '()) version)
   "Import OPAM package NAME from REPOSITORIES (a list of names, URLs or local
@@ -409,16 +419,23 @@ package in OPAM."
 
 (define (latest-release package)
   "Return an <upstream-source> for the latest release of PACKAGE."
-  (and-let* ((opam-name (guix-package->opam-name package))
-             (opam-file (opam-fetch opam-name))
-             (version (assoc-ref opam-file "version"))
-             (opam-content (assoc-ref opam-file "metadata"))
-             (url-dict (metadata-ref opam-content "url"))
-             (source-url (metadata-ref url-dict "src")))
-    (upstream-source
-      (package (package-name package))
-      (version version)
-      (urls (list source-url)))))
+  (catch #t
+    (lambda _
+      (and-let* ((opam-name (guix-package->opam-name package))
+                 (opam-file (guard* (c ((opam-not-found-error? c)
+                                        (warning (G_ "package '~a' not found~%")
+                                                 (opam-not-found-error-package c))
+                                        #f))
+                              (opam-fetch opam-name)))
+                 (version (assoc-ref opam-file "version"))
+                 (opam-content (assoc-ref opam-file "metadata"))
+                 (url-dict (metadata-ref opam-content "url"))
+                 (source-url (metadata-ref url-dict "src")))
+        (upstream-source
+          (package (package-name package))
+          (version version)
+          (urls (list source-url)))))
+    (const #f)))
 
 (define %opam-updater
   (upstream-updater
diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm
index 834ac34cb0..043d05d717 100644
--- a/guix/scripts/import/opam.scm
+++ b/guix/scripts/import/opam.scm
@@ -93,20 +93,23 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
                            (reverse opts))))
     (match args
       ((package-name)
-       (if (assoc-ref opts 'recursive)
-           ;; Recursive import
-           (map (match-lambda
-                  ((and ('package ('name name) . rest) pkg)
-                   `(define-public ,(string->symbol name)
-                      ,pkg))
-                  (_ #f))
-                (opam-recursive-import package-name #:repo repo))
-           ;; Single import
-           (let ((sexp (opam->guix-package package-name #:repo repo)))
-             (unless sexp
-               (leave (G_ "failed to download meta-data for package '~a'~%")
-                      package-name))
-             sexp)))
+       (guard* (c ((opam-not-found-error? c)
+                  (leave (G_ "package '~a' not found~%")
+                         (opam-not-found-error-package c))))
+         (if (assoc-ref opts 'recursive)
+             ;; Recursive import
+             (map (match-lambda
+                    ((and ('package ('name name) . rest) pkg)
+                     `(define-public ,(string->symbol name)
+                        ,pkg))
+                    (_ #f))
+                  (opam-recursive-import package-name #:repo repo))
+             ;; Single import
+             (let ((sexp (opam->guix-package package-name #:repo repo)))
+               (unless sexp
+                 (leave (G_ "failed to download meta-data for package '~a'~%")
+                        package-name))
+               sexp))))
       (()
        (leave (G_ "too few arguments~%")))
       ((many ...)
diff --git a/tests/opam.scm b/tests/opam.scm
index 31b4ea41ff..96b748bcd9 100644
--- a/tests/opam.scm
+++ b/tests/opam.scm
@@ -171,7 +171,7 @@ url {
     ("{a: \"b\"\nc: \"d\"}" . (dict (record "a" (string-pat "b")) (record "c" (string-pat "d"))))))
 
 (test-opam-syntax
-  "parse-conditions" condition
+  "parse-conditions" conditional
   '(("" . #f)
     ("{}" . #f)
     ("{build}" . (condition-var "build"))
-- 
2.33.0


--MP_/kJPvXDquHX6Rc/CDmw1XNkI--




Information forwarded to guix-patches@HIDDEN:
bug#51091; Package guix-patches. Full text available.

Message received at 51091 <at> debbugs.gnu.org:


Received: (at 51091) by debbugs.gnu.org; 14 Oct 2021 13:01:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 14 09:01:32 2021
Received: from localhost ([127.0.0.1]:34949 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mb0MV-0003Az-Nm
	for submit <at> debbugs.gnu.org; Thu, 14 Oct 2021 09:01:31 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56494)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mb0MT-0003An-Dm
 for 51091 <at> debbugs.gnu.org; Thu, 14 Oct 2021 09:01:30 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:46244)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mb0ML-0000Od-Gc; Thu, 14 Oct 2021 09:01:22 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=58018 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mb0MK-0007qW-IQ; Thu, 14 Oct 2021 09:01:21 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Xinglu Chen <public@HIDDEN>
Subject: Re: bug#51091: [PATCH] guix: opam: Do not fail when refreshing.
References: <20211008050310.407d6b23@HIDDEN>
 <87y272lepg.fsf@HIDDEN>
Date: Thu, 14 Oct 2021 15:01:18 +0200
In-Reply-To: <87y272lepg.fsf@HIDDEN> (Xinglu Chen's message of "Sat, 09
 Oct 2021 11:39:23 +0200")
Message-ID: <871r4nrc9t.fsf_-_@HIDDEN>
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
X-Spam-Score: -0.3 (/)
X-Debbugs-Envelope-To: 51091
Cc: Julien Lepiller <julien@HIDDEN>, 51091 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.3 (-)

Hi,

Xinglu Chen <public@HIDDEN> skribis:

> On Fri, Oct 08 2021, Julien Lepiller wrote:

[...]

>> Because we throw an error when a package is not in the opam repository,
>> the updater would crash when encountering a package that is not in opam
>> but uses the ocaml-build-system, such as opam itself.  This catches the
>> error and continues without updating said package, and lets us update
>> the rest of the packages.
>>
>> * guix/import/opam.scm (latest-release): Catch errors and do not crash.
>> ---
>>  guix/import/opam.scm | 23 +++++++++++++----------
>>  1 file changed, 13 insertions(+), 10 deletions(-)
>>
>> diff --git a/guix/import/opam.scm b/guix/import/opam.scm
>> index fe13d29f03..8ff1a3ae63 100644
>> --- a/guix/import/opam.scm
>> +++ b/guix/import/opam.scm
>> @@ -409,16 +409,19 @@ package in OPAM."
>>=20=20
>>  (define (latest-release package)
>>    "Return an <upstream-source> for the latest release of PACKAGE."
>> -  (and-let* ((opam-name (guix-package->opam-name package))
>> -             (opam-file (opam-fetch opam-name))
>> -             (version (assoc-ref opam-file "version"))
>> -             (opam-content (assoc-ref opam-file "metadata"))
>> -             (url-dict (metadata-ref opam-content "url"))
>> -             (source-url (metadata-ref url-dict "src")))
>> -    (upstream-source
>> -      (package (package-name package))
>> -      (version version)
>> -      (urls (list source-url)))))
>> +  (catch #t
>
> Using (catch #t ...) is generally not a good idea.  Maybe =E2=80=98opam-f=
etch=E2=80=99 should
> raise a =E2=80=98opam-fetch=E2=80=99 condition, and then we would only ca=
tch those
> conditions?

Agreed, it=E2=80=99s best to catch the most specific exception, around the =
most
narrow bits of code, so unexpected errors that denote bugs are properly
reported.

Nitpick: in the commit log, the subject line should start with
=E2=80=9Cimport: opam:=E2=80=9D.  :-)

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#51091; Package guix-patches. Full text available.

Message received at 51091 <at> debbugs.gnu.org:


Received: (at 51091) by debbugs.gnu.org; 9 Oct 2021 09:39:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 09 05:39:44 2021
Received: from localhost ([127.0.0.1]:52308 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mZ8pT-0003KH-U2
	for submit <at> debbugs.gnu.org; Sat, 09 Oct 2021 05:39:44 -0400
Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:59658
 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <public@HIDDEN>) id 1mZ8pR-0003Jv-3K
 for 51091 <at> debbugs.gnu.org; Sat, 09 Oct 2021 05:39:42 -0400
From: Xinglu Chen <public@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz;
 s=mail; t=1633772372;
 bh=8fnKFShsYhpF8i/4Xkd3GtR98RPZHxb6HhtLrO/4ZpM=;
 h=From:To:Subject:In-Reply-To:References:Date;
 b=Z9k2VQAt4aWeuLDMLNQgpdtdj5NhHcoi2GLr7F5wZ+y34/nAQpQboq2+5IibPgWB1
 +sq1tfhUwIhhkKVIOkxyHocUysTt3AVxCy9h32muqJCI9TC+P8GrLQ4JLrAj3Hsxuh
 JJpKuF+gxb9y/LgOP1l3V2QOT+UJpCn8ZBM9PJ5c=
To: Julien Lepiller <julien@HIDDEN>, 51091 <at> debbugs.gnu.org
Subject: Re: [bug#51091] [PATCH] guix: opam: Do not fail when refreshing.
In-Reply-To: <20211008050310.407d6b23@HIDDEN>
References: <20211008050310.407d6b23@HIDDEN>
Date: Sat, 09 Oct 2021 11:39:23 +0200
Message-ID: <87y272lepg.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha256; protocol="application/pgp-signature"
X-Spam-Score: 2.9 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  On Fri, Oct 08 2021, Julien Lepiller wrote: > Hi Guix! > >
 the attached patch prevents early failures in "guix refresh -t opam". > It
 will now simply continue when it encounters a package that is not in > the
 opam repository. > From f6260b762dd [...] 
 Content analysis details:   (2.9 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: yoctocell.xyz (xyz)]
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
 0.4 RDNS_DYNAMIC           Delivered to internal network by host with
 dynamic-looking rDNS
 0.0 PDS_RDNS_DYNAMIC_FP    RDNS_DYNAMIC with FP steps
X-Debbugs-Envelope-To: 51091
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.9 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Fri, Oct 08 2021, Julien Lepiller wrote: > Hi Guix! > >
    the attached patch prevents early failures in "guix refresh -t opam". > It
    will now simply continue when it encounters a package that is not in > the
    opam repository. > From f6260b762dd [...] 
 
 Content analysis details:   (2.9 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: yoctocell.xyz (xyz)]
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
  0.5 FROM_SUSPICIOUS_NTLD   From abused NTLD
  0.4 RDNS_DYNAMIC           Delivered to internal network by host with
                             dynamic-looking rDNS
  1.0 BULK_RE_SUSP_NTLD      Precedence bulk and RE: from a suspicious TLD
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager
  0.0 PDS_RDNS_DYNAMIC_FP    RDNS_DYNAMIC with FP steps

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On Fri, Oct 08 2021, Julien Lepiller wrote:

> Hi Guix!
>
> the attached patch prevents early failures in "guix refresh -t opam".
> It will now simply continue when it encounters a package that is not in
> the opam repository.
> From f6260b762dd78772e0d90d96dd92d22346a09007 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@HIDDEN>
> Date: Fri, 8 Oct 2021 04:58:27 +0200
> Subject: [PATCH] guix: opam: Do not fail when refreshing.
>
> Because we throw an error when a package is not in the opam repository,
> the updater would crash when encountering a package that is not in opam
> but uses the ocaml-build-system, such as opam itself.  This catches the
> error and continues without updating said package, and lets us update
> the rest of the packages.
>
> * guix/import/opam.scm (latest-release): Catch errors and do not crash.
> ---
>  guix/import/opam.scm | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/guix/import/opam.scm b/guix/import/opam.scm
> index fe13d29f03..8ff1a3ae63 100644
> --- a/guix/import/opam.scm
> +++ b/guix/import/opam.scm
> @@ -409,16 +409,19 @@ package in OPAM."
>=20=20
>  (define (latest-release package)
>    "Return an <upstream-source> for the latest release of PACKAGE."
> -  (and-let* ((opam-name (guix-package->opam-name package))
> -             (opam-file (opam-fetch opam-name))
> -             (version (assoc-ref opam-file "version"))
> -             (opam-content (assoc-ref opam-file "metadata"))
> -             (url-dict (metadata-ref opam-content "url"))
> -             (source-url (metadata-ref url-dict "src")))
> -    (upstream-source
> -      (package (package-name package))
> -      (version version)
> -      (urls (list source-url)))))
> +  (catch #t

Using (catch #t ...) is generally not a good idea.  Maybe =E2=80=98opam-fet=
ch=E2=80=99 should
raise a =E2=80=98opam-fetch=E2=80=99 condition, and then we would only catc=
h those
conditions?

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmFhY0sVHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x556cP/2YgvaXx7HRVhnHBGhlST4urdQNM
x4qcJn5KPXUF+S2UFjwRrRspaLLLvIZcyM2wyeoWBtqkeWC5QaJyZdnYXM1iKrEz
Dt9Y3GJ31RmPkn0Ssv2B+Qq+AhHp3t0KjEmBaheqdT8PE9Pnr9FQCdpLicMEd3Gf
7F6+k06cLjZZqDABofq+NWFA359XLFZyEEBkRyanqIvcRFFAJ68VZlToqPbK9U2F
hnkPuFyea3ki4LrdqN61sy512aapkCQ2pmBeWe1Mxkk7itCXmVevj4LzlgzwEjvn
0NiWz3XrEJLWBKosYl53vR8fvBw5iWHn87mbAzVSey8028ACXalZWvgdWajeVL45
9KzPdmD3jzI+Ba2h/IOIidhGphBUTnGz1w6OlpchGpE3pTK692xgpSDebX1DFBq1
MCxsizihpikJ2vBfMt5UzHXjOBpazebqsvrM5UElfL1IWLO76BG3DOaKVCa9TWus
YwbVK8CjpzawFv6KVwohWF37Efw1rdGOdD0vD0r2UtdYC4/ho5Hpm9uvVbUgDZSU
G2qwwntBi6jHWKjAebZbL12rCP3S37iUiPCsCGiwQ4XePNG71ksHJ/TI+pw7Jzlf
CW5SYxSn2dmA/TghbuEBCcYdsXdqOkM97lu6cBxLjZ4jAkfZDCx6Nvl2FS8dcZjT
L0FLfozTXLK1/VOp
=M5U1
-----END PGP SIGNATURE-----
--=-=-=--




Information forwarded to guix-patches@HIDDEN:
bug#51091; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Oct 2021 03:03:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 07 23:03:30 2021
Received: from localhost ([127.0.0.1]:48837 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mYgAU-0008Up-0q
	for submit <at> debbugs.gnu.org; Thu, 07 Oct 2021 23:03:30 -0400
Received: from lists.gnu.org ([209.51.188.17]:33918)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <julien@HIDDEN>) id 1mYgAR-0008Uh-Cn
 for submit <at> debbugs.gnu.org; Thu, 07 Oct 2021 23:03:29 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42274)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <julien@HIDDEN>)
 id 1mYgAR-0008E1-75
 for guix-patches@HIDDEN; Thu, 07 Oct 2021 23:03:27 -0400
Received: from lepiller.eu ([2a00:5884:8208::1]:51800)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <julien@HIDDEN>)
 id 1mYgAP-0006CR-71
 for guix-patches@HIDDEN; Thu, 07 Oct 2021 23:03:27 -0400
Received: from lepiller.eu (localhost [127.0.0.1])
 by lepiller.eu (OpenSMTPD) with ESMTP id db01a4e0
 for <guix-patches@HIDDEN>; Fri, 8 Oct 2021 03:03:19 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=date:from
 :to:subject:message-id:mime-version:content-type; s=dkim; bh=yI9
 fZGZhjczlkOFc6NsEYs/GjssuS0LYfAAHwV4JA9w=; b=cmhcGEOUiVS4wFw0mPg
 3OuWUWZeVd6mfOyt1jjtdRhNpQPWz3ERqYh+qhHC1Ra+vfG4U+90Br93280egwBp
 H+rcpp5aVA4MVrjJrlk/2h2nz4OGcNfECTn4PkLwm2oM4UyVYoCknR/ONxX2PLNu
 FJYwjOQFHuqCkcLoj7NRhSklJ8ny2XQ/QrAW/UtcW0N9lY46kNrck+Mwv34eouPa
 vL06L8zEi9G6drMXctRJGotXj50ZlZcgTe64xJ72QvcqkOmmbiWPY8YGk6c3mP0c
 WZXJJgL525N0PZCVG+0uQbEcoQ39DOPbdyEJ9XSHMTUYCKbVFYPEG7bWwOB3uPHd
 cvg==
Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id ba079159
 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for <guix-patches@HIDDEN>;
 Fri, 8 Oct 2021 03:03:19 +0000 (UTC)
Date: Fri, 8 Oct 2021 05:03:10 +0200
From: Julien Lepiller <julien@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] guix: opam: Do not fail when refreshing.
Message-ID: <20211008050310.407d6b23@HIDDEN>
X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="MP_/ANWqyJ7tcmsQj3Y9/jwX1+H"
Received-SPF: pass client-ip=2a00:5884:8208::1;
 envelope-from=julien@HIDDEN; helo=lepiller.eu
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, SPF_HELO_PASS=-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
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--MP_/ANWqyJ7tcmsQj3Y9/jwX1+H
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi Guix!

the attached patch prevents early failures in "guix refresh -t opam".
It will now simply continue when it encounters a package that is not in
the opam repository.

--MP_/ANWqyJ7tcmsQj3Y9/jwX1+H
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0001-guix-opam-Do-not-fail-when-refreshing.patch

From f6260b762dd78772e0d90d96dd92d22346a09007 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@HIDDEN>
Date: Fri, 8 Oct 2021 04:58:27 +0200
Subject: [PATCH] guix: opam: Do not fail when refreshing.

Because we throw an error when a package is not in the opam repository,
the updater would crash when encountering a package that is not in opam
but uses the ocaml-build-system, such as opam itself.  This catches the
error and continues without updating said package, and lets us update
the rest of the packages.

* guix/import/opam.scm (latest-release): Catch errors and do not crash.
---
 guix/import/opam.scm | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index fe13d29f03..8ff1a3ae63 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -409,16 +409,19 @@ package in OPAM."
 
 (define (latest-release package)
   "Return an <upstream-source> for the latest release of PACKAGE."
-  (and-let* ((opam-name (guix-package->opam-name package))
-             (opam-file (opam-fetch opam-name))
-             (version (assoc-ref opam-file "version"))
-             (opam-content (assoc-ref opam-file "metadata"))
-             (url-dict (metadata-ref opam-content "url"))
-             (source-url (metadata-ref url-dict "src")))
-    (upstream-source
-      (package (package-name package))
-      (version version)
-      (urls (list source-url)))))
+  (catch #t
+    (lambda _
+      (and-let* ((opam-name (guix-package->opam-name package))
+                 (opam-file (opam-fetch opam-name))
+                 (version (assoc-ref opam-file "version"))
+                 (opam-content (assoc-ref opam-file "metadata"))
+                 (url-dict (metadata-ref opam-content "url"))
+                 (source-url (metadata-ref url-dict "src")))
+        (upstream-source
+          (package (package-name package))
+          (version version)
+          (urls (list source-url)))))
+    (const #f)))
 
 (define %opam-updater
   (upstream-updater
-- 
2.33.0


--MP_/ANWqyJ7tcmsQj3Y9/jwX1+H--




Acknowledgement sent to Julien Lepiller <julien@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#51091; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 18 Oct 2021 08:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.