From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 30 16:55:57 2021 Received: (at submit) by debbugs.gnu.org; 30 Sep 2021 20:55:57 +0000 Received: from localhost ([127.0.0.1]:54135 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW35x-0005vU-H1 for submit@debbugs.gnu.org; Thu, 30 Sep 2021 16:55:57 -0400 Received: from lists.gnu.org ([209.51.188.17]:45404) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW35w-0005vL-2X for submit@debbugs.gnu.org; Thu, 30 Sep 2021 16:55:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mW35v-0005ie-Bz for guix-patches@gnu.org; Thu, 30 Sep 2021 16:55:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59704) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mW35v-00074v-3V; Thu, 30 Sep 2021 16:55:55 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36442 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mW35B-0003Kk-DQ; Thu, 30 Sep 2021 16:55:52 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/2] (guix import stackage) cleanups Date: Thu, 30 Sep 2021 22:54:54 +0200 Message-Id: <20210930205454.1157-1-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! The following changes were prompted by the vision of a ‘list-ref’ call and that of the whole alist family sitting at the JSON table. Feedback welcome! Ludo’. Ludovic Courtès (2): import: stackage: Use 'define-json-mapping'. import: stackage: Use the standard diagnostic procedures. guix/import/stackage.scm | 96 ++++++++++++++++++++++------------------ tests/lint.scm | 6 ++- 2 files changed, 58 insertions(+), 44 deletions(-) -- 2.33.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 30 17:02:02 2021 Received: (at 50922) by debbugs.gnu.org; 30 Sep 2021 21:02:03 +0000 Received: from localhost ([127.0.0.1]:54148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW3Bq-000677-BG for submit@debbugs.gnu.org; Thu, 30 Sep 2021 17:02:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW3Bo-00066k-0A for 50922@debbugs.gnu.org; Thu, 30 Sep 2021 17:02:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59944) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mW3Bi-0003XE-OZ; Thu, 30 Sep 2021 17:01:54 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36446 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mW3Bi-0006lk-CU; Thu, 30 Sep 2021 17:01:54 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 50922@debbugs.gnu.org Subject: [PATCH 2/2] import: stackage: Use the standard diagnostic procedures. Date: Thu, 30 Sep 2021 23:01:44 +0200 Message-Id: <20210930210144.1798-2-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210930210144.1798-1-ludo@gnu.org> References: <20210930210144.1798-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50922 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/import/stackage.scm (leave-with-message): Remove. (stackage-lts-info-fetch): Use 'raise' and 'formatted-message'. (stackage->guix-package): Likewise. (latest-lts-release): Use 'warning' instead of 'format'. --- guix/import/stackage.scm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index 4eff09ad01..b4b20ebcf0 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -32,6 +32,8 @@ #:use-module (guix memoization) #:use-module (guix packages) #:use-module (guix upstream) + #:use-module (guix diagnostics) + #:use-module (guix i18n) #:export (%stackage-url stackage->guix-package stackage-recursive-import @@ -71,9 +73,6 @@ (version stackage-package-version) (synopsis stackage-package-synopsis)) -(define (leave-with-message fmt . args) - (raise (condition (&message (message (apply format #f fmt args)))))) - (define stackage-lts-info-fetch ;; "Retrieve the information about the LTS Stackage release VERSION." (memoize @@ -84,7 +83,8 @@ version))) (lts-info (and=> (json-fetch url) json->stackage-lts))) (or lts-info - (leave-with-message "LTS release version not found: ~a" version)))))) + (raise (formatted-message (G_ "LTS release version not found: ~a") + version))))))) (define (lts-package-version packages name) "Return the version of the package with upstream NAME included in PACKAGES." @@ -120,7 +120,8 @@ included in the Stackage LTS release." (hackage->guix-package name-version #:include-test-dependencies? include-test-dependencies?) - (leave-with-message "~a: Stackage package not found" package-name)))))) + (raise (formatted-message (G_ "~a: Stackage package not found") + package-name))))))) (define (stackage-recursive-import package-name . args) (recursive-import package-name @@ -145,10 +146,10 @@ PACKAGE or #f if the package is not included in the Stackage LTS release." (version (lts-package-version (packages) hackage-name)) (name-version (hackage-name-version hackage-name version))) (match (and=> name-version hackage-fetch) - (#f (format (current-error-port) - "warning: failed to parse ~a~%" - (hackage-cabal-url hackage-name)) - #f) + (#f + (warning (G_ "failed to parse ~a~%") + (hackage-cabal-url hackage-name)) + #f) (_ (let ((url (hackage-source-url hackage-name version))) (upstream-source (package (package-name package)) -- 2.33.0 From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 30 17:02:08 2021 Received: (at 50922) by debbugs.gnu.org; 30 Sep 2021 21:02:08 +0000 Received: from localhost ([127.0.0.1]:54150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW3Bq-00067N-SY for submit@debbugs.gnu.org; Thu, 30 Sep 2021 17:02:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mW3Bn-00066h-BJ for 50922@debbugs.gnu.org; Thu, 30 Sep 2021 17:02:00 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59942) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mW3Bi-0003X2-3H; Thu, 30 Sep 2021 17:01:54 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36446 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mW3Bh-0006lk-RA; Thu, 30 Sep 2021 17:01:54 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 50922@debbugs.gnu.org Subject: [PATCH 1/2] import: stackage: Use 'define-json-mapping'. Date: Thu, 30 Sep 2021 23:01:43 +0200 Message-Id: <20210930210144.1798-1-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 50922 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) * guix/import/stackage.scm (, ) (): New record types and JSON mappings. (lts-info-packages, stackage-package-name) (stackage-package-version): Remove. (lts-package-version): Rename 'pkgs-info' to 'packages'; assume 'packages' is a list of . (stackage->guix-package): Use 'stackage-lts-packages' instead of 'lts-info-packages'. Rename 'packages-info' to 'packages'. (latest-lts-release): Likewise. (stackage-package?): Rename to... (stackage-lts-package?): ... this. Adjust to new API. (%stackage-updater)[pred]: Update accordingly. * tests/lint.scm ("haskell-stackage"): Add "snapshot" entry in JSON snippet. --- guix/import/stackage.scm | 79 ++++++++++++++++++++++------------------ tests/lint.scm | 6 ++- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index 731e69651e..4eff09ad01 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2018 Ricardo Wurmus ;;; Copyright © 2020 Martin Becze ;;; Copyright © 2021 Xinglu Chem +;;; Copyright © 2021 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,13 +22,10 @@ (define-module (guix import stackage) #:use-module (ice-9 match) - #:use-module (ice-9 regex) - #:use-module (ice-9 control) + #:use-module (json) #:use-module (srfi srfi-1) - #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) - #:use-module (srfi srfi-43) #:use-module (guix import json) #:use-module (guix import hackage) #:use-module (guix import utils) @@ -50,9 +48,28 @@ ;; Latest LTS version compatible with GHC 8.6.5. (define %default-lts-version "14.27") -(define (lts-info-packages lts-info) - "Returns the alist of packages contained in LTS-INFO." - (or (assoc-ref lts-info "packages") '())) +(define-json-mapping make-stackage-lts + stackage-lts? + json->stackage-lts + (snapshot stackage-lts-snapshot "snapshot" json->snapshot) + (packages stackage-lts-packages "packages" + (lambda (vector) + (map json->stackage-package (vector->list vector))))) + +(define-json-mapping make-snapshot + stackage-snapshot? + json->snapshot + (name snapshot-name) + (ghc-version snapshot-ghc-version) + (compiler snapshot-compiler)) + +(define-json-mapping make-stackage-package + stackage-package? + json->stackage-package + (origin stackage-package-origin) + (name stackage-package-name) + (version stackage-package-version) + (synopsis stackage-package-synopsis)) (define (leave-with-message fmt . args) (raise (condition (&message (message (apply format #f fmt args)))))) @@ -65,21 +82,14 @@ "/lts-" (if (string-null? version) %default-lts-version version))) - (lts-info (json-fetch url))) - (if lts-info - (reverse lts-info) + (lts-info (and=> (json-fetch url) json->stackage-lts))) + (or lts-info (leave-with-message "LTS release version not found: ~a" version)))))) -(define (stackage-package-name pkg-info) - (assoc-ref pkg-info "name")) - -(define (stackage-package-version pkg-info) - (assoc-ref pkg-info "version")) - -(define (lts-package-version pkgs-info name) - "Return the version of the package with upstream NAME included in PKGS-INFO." +(define (lts-package-version packages name) + "Return the version of the package with upstream NAME included in PACKAGES." (let ((pkg (find (lambda (pkg) (string=? (stackage-package-name pkg) name)) - (vector->list pkgs-info)))) + packages))) (stackage-package-version pkg))) @@ -96,15 +106,15 @@ #:key (include-test-dependencies? #t) (lts-version %default-lts-version) - (packages-info - (lts-info-packages + (packages + (stackage-lts-packages (stackage-lts-info-fetch lts-version)))) "Fetch Cabal file for PACKAGE-NAME from hackage.haskell.org. The retrieved version corresponds to the version of PACKAGE-NAME specified in the LTS-VERSION release at stackage.org. Return the `package' S-expression corresponding to that package, or #f on failure. PACKAGES-INFO is the alist with the packages included in the Stackage LTS release." - (let* ((version (lts-package-version packages-info package-name)) + (let* ((version (lts-package-version packages package-name)) (name-version (hackage-name-version package-name version))) (if name-version (hackage->guix-package name-version @@ -124,14 +134,15 @@ included in the Stackage LTS release." ;;; (define latest-lts-release - (let ((pkgs-info - (mlambda () (lts-info-packages - (stackage-lts-info-fetch %default-lts-version))))) + (let ((packages + (mlambda () + (stackage-lts-packages + (stackage-lts-info-fetch %default-lts-version))))) (lambda* (package) "Return an for the latest Stackage LTS release of PACKAGE or #f if the package is not included in the Stackage LTS release." (let* ((hackage-name (guix-package->hackage-name package)) - (version (lts-package-version (pkgs-info) hackage-name)) + (version (lts-package-version (packages) hackage-name)) (name-version (hackage-name-version hackage-name version))) (match (and=> name-version hackage-fetch) (#f (format (current-error-port) @@ -144,23 +155,21 @@ PACKAGE or #f if the package is not included in the Stackage LTS release." (version version) (urls (list url)))))))))) -(define (stackage-package? package) - "Whether PACKAGE is available on the default Stackage LTS release." +(define (stackage-lts-package? package) + "Return whether PACKAGE is available on the default Stackage LTS release." (and (hackage-package? package) - (let ((packages (lts-info-packages + (let ((packages (stackage-lts-packages (stackage-lts-info-fetch %default-lts-version))) (hackage-name (guix-package->hackage-name package))) - (vector-any identity - (vector-map - (lambda (_ metadata) - (string=? (cdr (list-ref metadata 2)) hackage-name)) - packages))))) + (find (lambda (package) + (string=? (stackage-package-name package) hackage-name)) + packages)))) (define %stackage-updater (upstream-updater (name 'stackage) (description "Updater for Stackage LTS packages") - (pred stackage-package?) + (pred stackage-lts-package?) (latest latest-lts-release))) ;;; stackage.scm ends here diff --git a/tests/lint.scm b/tests/lint.scm index e96265a55a..699a750eb9 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -1319,7 +1319,11 @@ (let* ((stackage (string-append "{ \"packages\": [{" " \"name\":\"pandoc\"," " \"synopsis\":\"synopsis\"," - " \"version\":\"1.0\" }]}")) + " \"version\":\"1.0\" }]," + " \"snapshot\": {" + " \"ghc\": \"8.6.5\"," + " \"name\": \"lts-14.27\"" + " }}")) (packages (map (lambda (version) (dummy-package "ghc-pandoc" -- 2.33.0 From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 02 11:29:19 2021 Received: (at 50922-done) by debbugs.gnu.org; 2 Oct 2021 15:29:19 +0000 Received: from localhost ([127.0.0.1]:60318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWgww-0006M7-UG for submit@debbugs.gnu.org; Sat, 02 Oct 2021 11:29:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWgwv-0006Ls-8a for 50922-done@debbugs.gnu.org; Sat, 02 Oct 2021 11:29:17 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55258) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWgwp-0003Aa-Ru for 50922-done@debbugs.gnu.org; Sat, 02 Oct 2021 11:29:12 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=36508 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWgwp-0006iD-IP for 50922-done@debbugs.gnu.org; Sat, 02 Oct 2021 11:29:11 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 50922-done@debbugs.gnu.org Subject: Re: bug#50922: [PATCH 0/2] (guix import stackage) cleanups References: <20210930205454.1157-1-ludo@gnu.org> Date: Sat, 02 Oct 2021 17:29:10 +0200 In-Reply-To: <20210930205454.1157-1-ludo@gnu.org> ("Ludovic =?utf-8?Q?Cour?= =?utf-8?Q?t=C3=A8s=22's?= message of "Thu, 30 Sep 2021 22:54:54 +0200") Message-ID: <87k0ivv41l.fsf@gnu.org> 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: 50922-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: > import: stackage: Use 'define-json-mapping'. > import: stackage: Use the standard diagnostic procedures. Pushed as b7d8dc5841f9d71c6eac4c2c8faaf7f0b5e7748e! Ludo=E2=80=99. From unknown Sat Jun 21 05:19:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 31 Oct 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator