diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-09-07 23:12:27 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-09-08 00:47:35 +0200 |
| commit | b5eb901ab508e13a10d8c11fe0c9d0d06dddce96 (patch) | |
| tree | e8555d5c52e27edf3dfa097c402964ccb24ffd0d | |
| parent | d15c7974a2346ec0d379eba3fd60ef59012d9a80 (diff) | |
Remove (guix json) and require Guile-JSON 4.3.0+.
This is a followup to 4071879c86d059ee087c8986915ea72b8c742b72.
* guix/json.scm: Remove.
* Makefile.am (MODULES): Adjust accordingly.
* m4/guix.m4 (GUIX_CHECK_GUILE_JSON): Check for 'define-json-mapping'.
* doc/guix.texi (Requirements): Require Guile-JSON 4.3.0+.
* guix/ci.scm, guix/cve.scm, guix/import/cpan.scm,
guix/import/crate.scm, guix/swh.scm: Remove (guix json) import.
* guix/import/gem.scm, guix/import/pypi.scm: Likewise, and import (json).
* guix/self.scm (specification->package): Switch to GUILE-JSON-4.
* guix/git-download.scm (git-fetch): Likewise.
| -rw-r--r-- | Makefile.am | 1 | ||||
| -rw-r--r-- | doc/guix.texi | 3 | ||||
| -rw-r--r-- | guix/ci.scm | 1 | ||||
| -rw-r--r-- | guix/cve.scm | 1 | ||||
| -rw-r--r-- | guix/git-download.scm | 4 | ||||
| -rw-r--r-- | guix/import/cpan.scm | 1 | ||||
| -rw-r--r-- | guix/import/crate.scm | 1 | ||||
| -rw-r--r-- | guix/import/gem.scm | 2 | ||||
| -rw-r--r-- | guix/import/pypi.scm | 2 | ||||
| -rw-r--r-- | guix/json.scm | 83 | ||||
| -rw-r--r-- | guix/self.scm | 2 | ||||
| -rw-r--r-- | guix/swh.scm | 1 | ||||
| -rw-r--r-- | m4/guix.m4 | 19 |
13 files changed, 21 insertions, 100 deletions
diff --git a/Makefile.am b/Makefile.am index 49fe57a0956..8e91e1e5587 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -68,7 +68,6 @@ MODULES = \ | |||
| 68 | guix/cpio.scm \ | 68 | guix/cpio.scm \ |
| 69 | guix/deprecation.scm \ | 69 | guix/deprecation.scm \ |
| 70 | guix/docker.scm \ | 70 | guix/docker.scm \ |
| 71 | guix/json.scm \ | ||
| 72 | guix/records.scm \ | 71 | guix/records.scm \ |
| 73 | guix/openpgp.scm \ | 72 | guix/openpgp.scm \ |
| 74 | guix/pki.scm \ | 73 | guix/pki.scm \ |
diff --git a/doc/guix.texi b/doc/guix.texi index f224e356bce..4e9e5581c35 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -790,7 +790,8 @@ or later; | |||
| 790 | @c FIXME: Specify a version number once a release has been made. | 790 | @c FIXME: Specify a version number once a release has been made. |
| 791 | @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August | 791 | @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August |
| 792 | 2017 or later; | 792 | 2017 or later; |
| 793 | @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON} 3.x; | 793 | @item @uref{https://savannah.nongnu.org/projects/guile-json/, |
| 794 | Guile-JSON} 4.3.0 or later; | ||
| 794 | @item @url{https://www.gnu.org/software/make/, GNU Make}. | 795 | @item @url{https://www.gnu.org/software/make/, GNU Make}. |
| 795 | @end itemize | 796 | @end itemize |
| 796 | 797 | ||
diff --git a/guix/ci.scm b/guix/ci.scm index 02eb90e6c32..7a03befc7cb 100644 --- a/guix/ci.scm +++ b/guix/ci.scm | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | 19 | ||
| 20 | (define-module (guix ci) | 20 | (define-module (guix ci) |
| 21 | #:use-module (guix http-client) | 21 | #:use-module (guix http-client) |
| 22 | #:use-module (guix json) | ||
| 23 | #:use-module (json) | 22 | #:use-module (json) |
| 24 | #:use-module (srfi srfi-1) | 23 | #:use-module (srfi srfi-1) |
| 25 | #:use-module (ice-9 match) | 24 | #:use-module (ice-9 match) |
diff --git a/guix/cve.scm b/guix/cve.scm index ae9cca23418..57b8459d016 100644 --- a/guix/cve.scm +++ b/guix/cve.scm | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | (define-module (guix cve) | 19 | (define-module (guix cve) |
| 20 | #:use-module (guix utils) | 20 | #:use-module (guix utils) |
| 21 | #:use-module (guix http-client) | 21 | #:use-module (guix http-client) |
| 22 | #:use-module (guix json) | ||
| 23 | #:use-module (guix i18n) | 22 | #:use-module (guix i18n) |
| 24 | #:use-module ((guix diagnostics) #:select (formatted-message)) | 23 | #:use-module ((guix diagnostics) #:select (formatted-message)) |
| 25 | #:use-module (json) | 24 | #:use-module (json) |
diff --git a/guix/git-download.scm b/guix/git-download.scm index 90634a8c4ce..8e575e3b5f1 100644 --- a/guix/git-download.scm +++ b/guix/git-download.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2017 Mathieu Lirzin <mthl@gnu.org> | 3 | ;;; Copyright © 2017 Mathieu Lirzin <mthl@gnu.org> |
| 4 | ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net> | 4 | ;;; Copyright © 2017 Christopher Baines <mail@cbaines.net> |
| 5 | ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> | 5 | ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> |
| @@ -85,7 +85,7 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f." | |||
| 85 | 'tar))))) | 85 | 'tar))))) |
| 86 | 86 | ||
| 87 | (define guile-json | 87 | (define guile-json |
| 88 | (module-ref (resolve-interface '(gnu packages guile)) 'guile-json-3)) | 88 | (module-ref (resolve-interface '(gnu packages guile)) 'guile-json-4)) |
| 89 | 89 | ||
| 90 | (define guile-zlib | 90 | (define guile-zlib |
| 91 | (module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib)) | 91 | (module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib)) |
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm index 085467b8719..fd940415a29 100644 --- a/guix/import/cpan.scm +++ b/guix/import/cpan.scm | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #:use-module (srfi srfi-1) | 28 | #:use-module (srfi srfi-1) |
| 29 | #:use-module (srfi srfi-26) | 29 | #:use-module (srfi srfi-26) |
| 30 | #:use-module (json) | 30 | #:use-module (json) |
| 31 | #:use-module (guix json) | ||
| 32 | #:use-module (gcrypt hash) | 31 | #:use-module (gcrypt hash) |
| 33 | #:use-module (guix store) | 32 | #:use-module (guix store) |
| 34 | #:use-module (guix utils) | 33 | #:use-module (guix utils) |
diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 796a7641e98..f87c89163c1 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #:use-module ((guix download) #:prefix download:) | 24 | #:use-module ((guix download) #:prefix download:) |
| 25 | #:use-module (gcrypt hash) | 25 | #:use-module (gcrypt hash) |
| 26 | #:use-module (guix http-client) | 26 | #:use-module (guix http-client) |
| 27 | #:use-module (guix json) | ||
| 28 | #:use-module (guix import json) | 27 | #:use-module (guix import json) |
| 29 | #:use-module (guix import utils) | 28 | #:use-module (guix import utils) |
| 30 | #:use-module ((guix licenses) #:prefix license:) | 29 | #:use-module ((guix licenses) #:prefix license:) |
diff --git a/guix/import/gem.scm b/guix/import/gem.scm index a2d99ddbca4..3fe240f36a8 100644 --- a/guix/import/gem.scm +++ b/guix/import/gem.scm | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | (define-module (guix import gem) | 22 | (define-module (guix import gem) |
| 23 | #:use-module (ice-9 match) | 23 | #:use-module (ice-9 match) |
| 24 | #:use-module (srfi srfi-1) | 24 | #:use-module (srfi srfi-1) |
| 25 | #:use-module (guix json) | 25 | #:use-module (json) |
| 26 | #:use-module ((guix download) #:prefix download:) | 26 | #:use-module ((guix download) #:prefix download:) |
| 27 | #:use-module (guix import utils) | 27 | #:use-module (guix import utils) |
| 28 | #:use-module (guix import json) | 28 | #:use-module (guix import json) |
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm index a4a24896880..15116e349d7 100644 --- a/guix/import/pypi.scm +++ b/guix/import/pypi.scm | |||
| @@ -46,7 +46,7 @@ | |||
| 46 | #:use-module (guix import utils) | 46 | #:use-module (guix import utils) |
| 47 | #:use-module ((guix download) #:prefix download:) | 47 | #:use-module ((guix download) #:prefix download:) |
| 48 | #:use-module (guix import json) | 48 | #:use-module (guix import json) |
| 49 | #:use-module (guix json) | 49 | #:use-module (json) |
| 50 | #:use-module (guix packages) | 50 | #:use-module (guix packages) |
| 51 | #:use-module (guix upstream) | 51 | #:use-module (guix upstream) |
| 52 | #:use-module ((guix licenses) #:prefix license:) | 52 | #:use-module ((guix licenses) #:prefix license:) |
diff --git a/guix/json.scm b/guix/json.scm deleted file mode 100644 index 3e3a28b749a..00000000000 --- a/guix/json.scm +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (guix json) | ||
| 20 | #:use-module (json) | ||
| 21 | #:use-module (srfi srfi-9)) | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | ;;; | ||
| 25 | ;;; Helpers to map JSON objects to SRFI-9 records. Taken from (guix swh). | ||
| 26 | ;;; This module is superseded by 'define-json-mapping' as found since version | ||
| 27 | ;;; 4.2.0 of Guile-JSON and will be removed once migration is complete. | ||
| 28 | ;;; | ||
| 29 | ;;; Code: | ||
| 30 | |||
| 31 | (define-syntax define-as-needed | ||
| 32 | (lambda (s) | ||
| 33 | "Define the given syntax rule unless (json) already provides it." | ||
| 34 | (syntax-case s () | ||
| 35 | ((_ (macro args ...) body ...) | ||
| 36 | (if (module-defined? (resolve-interface '(json)) | ||
| 37 | (syntax->datum #'macro)) | ||
| 38 | #'(eval-when (expand load eval) | ||
| 39 | ;; Re-export MACRO from (json). | ||
| 40 | (module-re-export! (current-module) '(macro))) | ||
| 41 | #'(begin | ||
| 42 | ;; Using Guile-JSON < 4.2.0, so provide our own MACRO. | ||
| 43 | (define-syntax-rule (macro args ...) | ||
| 44 | body ...) | ||
| 45 | (eval-when (expand load eval) | ||
| 46 | (module-export! (current-module) '(macro))))))))) | ||
| 47 | |||
| 48 | (define-syntax-rule (define-json-reader json->record ctor spec ...) | ||
| 49 | "Define JSON->RECORD as a procedure that converts a JSON representation, | ||
| 50 | read from a port, string, or hash table, into a record created by CTOR and | ||
| 51 | following SPEC, a series of field specifications." | ||
| 52 | (define (json->record input) | ||
| 53 | (let ((table (cond ((port? input) | ||
| 54 | (json->scm input)) | ||
| 55 | ((string? input) | ||
| 56 | (json-string->scm input)) | ||
| 57 | ((or (null? input) (pair? input)) | ||
| 58 | input)))) | ||
| 59 | (let-syntax ((extract-field (syntax-rules () | ||
| 60 | ((_ table (field key json->value)) | ||
| 61 | (json->value (assoc-ref table key))) | ||
| 62 | ((_ table (field key)) | ||
| 63 | (assoc-ref table key)) | ||
| 64 | ((_ table (field)) | ||
| 65 | (assoc-ref table | ||
| 66 | (symbol->string 'field)))))) | ||
| 67 | (ctor (extract-field table spec) ...))))) | ||
| 68 | |||
| 69 | ;; For some reason we cannot just have colliding definitions of | ||
| 70 | ;; 'define-json-mapping' (that leads to a build failure in users of this | ||
| 71 | ;; module), hence the use of 'define-as-needed'. | ||
| 72 | (define-as-needed (define-json-mapping rtd ctor pred json->record | ||
| 73 | (field getter spec ...) ...) | ||
| 74 | "Define RTD as a record type with the given FIELDs and GETTERs, à la SRFI-9, | ||
| 75 | and define JSON->RECORD as a conversion from JSON to a record of this type." | ||
| 76 | (begin | ||
| 77 | (define-record-type rtd | ||
| 78 | (ctor field ...) | ||
| 79 | pred | ||
| 80 | (field getter) ...) | ||
| 81 | |||
| 82 | (define-json-reader json->record ctor | ||
| 83 | (field spec ...) ...))) | ||
diff --git a/guix/self.scm b/guix/self.scm index 6a1640acdf2..02ef982c7c9 100644 --- a/guix/self.scm +++ b/guix/self.scm | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | (module-ref (resolve-interface module) variable)))) | 49 | (module-ref (resolve-interface module) variable)))) |
| 50 | (match-lambda | 50 | (match-lambda |
| 51 | ("guile" (ref '(gnu packages guile) 'guile-3.0/libgc-7)) | 51 | ("guile" (ref '(gnu packages guile) 'guile-3.0/libgc-7)) |
| 52 | ("guile-json" (ref '(gnu packages guile) 'guile-json-3)) | 52 | ("guile-json" (ref '(gnu packages guile) 'guile-json-4)) |
| 53 | ("guile-ssh" (ref '(gnu packages ssh) 'guile-ssh)) | 53 | ("guile-ssh" (ref '(gnu packages ssh) 'guile-ssh)) |
| 54 | ("guile-git" (ref '(gnu packages guile) 'guile-git)) | 54 | ("guile-git" (ref '(gnu packages guile) 'guile-git)) |
| 55 | ("guile-sqlite3" (ref '(gnu packages guile) 'guile-sqlite3)) | 55 | ("guile-sqlite3" (ref '(gnu packages guile) 'guile-sqlite3)) |
diff --git a/guix/swh.scm b/guix/swh.scm index a343ccfdd7a..0b765cc7432 100644 --- a/guix/swh.scm +++ b/guix/swh.scm | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #:use-module (guix build utils) | 22 | #:use-module (guix build utils) |
| 23 | #:use-module ((guix build syscalls) #:select (mkdtemp!)) | 23 | #:use-module ((guix build syscalls) #:select (mkdtemp!)) |
| 24 | #:use-module (web uri) | 24 | #:use-module (web uri) |
| 25 | #:use-module (guix json) | ||
| 26 | #:use-module (web client) | 25 | #:use-module (web client) |
| 27 | #:use-module (web response) | 26 | #:use-module (web response) |
| 28 | #:use-module (json) | 27 | #:use-module (json) |
diff --git a/m4/guix.m4 b/m4/guix.m4 index 7256e792a52..2fcc65e039c 100644 --- a/m4/guix.m4 +++ b/m4/guix.m4 | |||
| @@ -161,14 +161,23 @@ dnl GUIX_CHECK_GUILE_JSON | |||
| 161 | dnl | 161 | dnl |
| 162 | dnl Check whether a recent-enough Guile-JSON is available. | 162 | dnl Check whether a recent-enough Guile-JSON is available. |
| 163 | AC_DEFUN([GUIX_CHECK_GUILE_JSON], [ | 163 | AC_DEFUN([GUIX_CHECK_GUILE_JSON], [ |
| 164 | dnl Check whether we're using Guile-JSON 3.x, which uses a JSON-to-Scheme | 164 | dnl Check whether we're using Guile-JSON 4.3+, which provides |
| 165 | dnl mapping different from that of earlier versions. | 165 | dnl 'define-json-mapping'. |
| 166 | AC_CACHE_CHECK([whether Guile-JSON is available and recent enough], | 166 | AC_CACHE_CHECK([whether Guile-JSON is available and recent enough], |
| 167 | [guix_cv_have_recent_guile_json], | 167 | [guix_cv_have_recent_guile_json], |
| 168 | [GUILE_CHECK([retval], | 168 | [GUILE_CHECK([retval], |
| 169 | [(use-modules (json) (ice-9 match)) | 169 | [(use-modules (json)) |
| 170 | (match (json-string->scm \"[[ { \\\"a\\\": 42 } ]]\") | 170 | |
| 171 | (#((("a" . 42))) #t))]) | 171 | (define-json-mapping <frob> make-frob |
| 172 | frob? | ||
| 173 | json->frob | ||
| 174 | (a frob-a) | ||
| 175 | (b frob-b \"bee\")) | ||
| 176 | |||
| 177 | (exit | ||
| 178 | (equal? (json->frob | ||
| 179 | (open-input-string \"{ \\\"a\\\": 1, \\\"bee\\\": 2 }\")) | ||
| 180 | (make-frob 1 2)))]) | ||
| 172 | if test "$retval" = 0; then | 181 | if test "$retval" = 0; then |
| 173 | guix_cv_have_recent_guile_json="yes" | 182 | guix_cv_have_recent_guile_json="yes" |
| 174 | else | 183 | else |
