[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#70923] [PATCH v2 04/12] import: crate: Use (guix import utils) proc
From: |
Herman Rimm |
Subject: |
[bug#70923] [PATCH v2 04/12] import: crate: Use (guix import utils) procedures. |
Date: |
Wed, 4 Sep 2024 22:32:58 +0200 |
* guix/import/crate.scm (maybe-cargo-inputs,
maybe-cargo-development-inputs, maybe-arguments): Delete procedures.
(make-crate-sexp): Add 'unwrap' procedure, use with maybe-packages-field
and fix indentation.
* tests/crate.scm: Replace quasiquotes with list procedures.
---
guix/import/crate.scm | 53 +++++++++---------------
tests/crate.scm | 94 +++++++++++++++++++++----------------------
2 files changed, 66 insertions(+), 81 deletions(-)
diff --git a/guix/import/crate.scm b/guix/import/crate.scm
index 263c2a8b16..e451ebee68 100644
--- a/guix/import/crate.scm
+++ b/guix/import/crate.scm
@@ -8,6 +8,7 @@
;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023, 2024 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -159,27 +160,6 @@ (define (make-input input version)
(input (make-input input #f)))
names))
-(define (maybe-cargo-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-inputs (,'unquote (list ,@package-inputs))))))
-
-(define (maybe-cargo-development-inputs package-names)
- (match (package-names->package-inputs package-names)
- (()
- '())
- ((package-inputs ...)
- `(#:cargo-development-inputs (,'unquote (list ,@package-inputs))))))
-
-(define (maybe-arguments arguments)
- (match arguments
- (()
- '())
- ((args ...)
- `((arguments (,'quasiquote ,args))))))
-
(define (version->semver-prefix version)
"Return the version up to and including the first non-zero part"
(first
@@ -203,8 +183,14 @@ (define (format-inputs inputs)
(let* ((port (http-fetch (crate-uri name version)))
(guix-name (crate-name->package-name name))
- (cargo-inputs (format-inputs cargo-inputs))
- (cargo-development-inputs (format-inputs cargo-development-inputs))
+ (unwrap (match-lambda
+ ((lst) lst)
+ (() '())))
+ (cargo-inputs (maybe-packages-field '#:cargo-inputs
+ (format-inputs cargo-inputs)))
+ (cargo-development-inputs
+ (maybe-packages-field '#:cargo-development-inputs
+ (format-inputs cargo-development-inputs)))
(description (beautify-description description))
(pkg `(package
(name ,guix-name)
@@ -223,12 +209,12 @@ (define (format-inputs inputs)
`((properties '((crate-version-yanked? . #t))))
'())
(build-system cargo-build-system)
- ,@(maybe-arguments (append (if build?
- '()
- '(#:skip-build? #t))
- (maybe-cargo-inputs cargo-inputs)
- (maybe-cargo-development-inputs
- cargo-development-inputs)))
+ ,@(maybe-list-field 'arguments
+ (append (if build?
+ '()
+ '(#:skip-build? #t))
+ (unwrap cargo-inputs)
+ (unwrap cargo-development-inputs)))
(home-page ,home-page)
(synopsis ,(beautify-synopsis synopsis))
(description ,(if (string-prefix? "This" description)
@@ -240,11 +226,10 @@ (define (format-inputs inputs)
(#f #f)
((license) license)
(_ `(list ,@license)))))))
- (close-port port)
- (package->definition pkg
- (if yanked?
- (string-append version "-yanked")
- (version->semver-prefix version)))))
+ (close-port port)
+ (package->definition pkg (if yanked?
+ (string-append version "-yanked")
+ (version->semver-prefix version)))))
(define (string->license string)
(filter-map (lambda (license)
diff --git a/tests/crate.scm b/tests/crate.scm
index 63643c2728..95c93712a9 100644
--- a/tests/crate.scm
+++ b/tests/crate.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -498,10 +499,10 @@ (define have-guile-semver?
(? string? hash)))))
(build-system 'cargo-build-system)
(arguments
- ('quasiquote
- (#:skip-build? #t
+ (list
+ #:skip-build? #t
#:cargo-inputs
- ('unquote (list rust-leaf-alice-0.7)))))
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -590,7 +591,7 @@ (define have-guile-semver?
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t)))
+ (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -609,7 +610,7 @@ (define-public 'rust-leaf-alice-0.7
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -628,7 +629,7 @@ (define-public 'rust-leaf-bob-3
(base32
(? string? hash)))))
(build-system cargo-build-system)
- (arguments ('quasiquote (#:skip-build? #t)))
+ (arguments (list #:skip-build? #t))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -648,9 +649,9 @@ (define-public 'rust-intermediate-b-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- ('unquote (list rust-leaf-bob-3)))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -670,11 +671,11 @@ (define-public 'rust-intermediate-a-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:skip-build? #t
- #:cargo-inputs
- ('unquote (list rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3)))))
+ (list #:skip-build? #t
+ #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -694,13 +695,13 @@ (define-public 'rust-root-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-intermediate-a-1
- rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-intermediate-c-1)))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ ((list rust-intermediate-c-1))))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -727,8 +728,8 @@ (define-public 'rust-root-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-development-inputs
- ('unquote (list rust-leaf-alice-0.7)))))
+ (list #:cargo-development-inputs
+ (list rust-leaf-alice-0.7)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -784,9 +785,8 @@ (define-public 'rust-intermediate-b-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- (("rust-leaf-bob"
- ('unquote rust-leaf-bob-3))))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -806,10 +806,10 @@ (define-public 'rust-intermediate-a-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3)))))
+ (list #:cargo-inputs
+ (list rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -829,13 +829,13 @@ (define-public 'rust-root-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-intermediate-a-1
- rust-intermediate-b-1
- rust-leaf-alice-0.7
- rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-intermediate-c-1)))))
+ (list #:cargo-inputs
+ (list rust-intermediate-a-1
+ rust-intermediate-b-1
+ rust-leaf-alice-0.7
+ rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-intermediate-c-1)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -945,11 +945,11 @@ (define rust-leaf-bob-3.0.2-yanked
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-leaf-bob-3.0.2-yanked
- rust-leaf-bob-4.0.0-yanked)))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
@@ -1073,11 +1073,11 @@ (define-public 'rust-bar-1
(? string? hash)))))
(build-system cargo-build-system)
(arguments
- ('quasiquote (#:cargo-inputs
- ('unquote (list rust-leaf-bob-3))
- #:cargo-development-inputs
- ('unquote (list rust-leaf-bob-3.0.2-yanked
- rust-leaf-bob-4.0.0-yanked)))))
+ (list #:cargo-inputs
+ (list rust-leaf-bob-3)
+ #:cargo-development-inputs
+ (list rust-leaf-bob-3.0.2-yanked
+ rust-leaf-bob-4.0.0-yanked)))
(home-page "http://example.com")
(synopsis "summary")
(description "This package provides summary.")
--
2.45.2
- [bug#70923] [PATCH v2 01/12] build-system: cargo: Accept unlabeled #:cargo-inputs., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 02/12] import: utils: Emit new-style inputs from maybe-*inputs procedures., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 04/12] import: crate: Use (guix import utils) procedures.,
Herman Rimm <=
- [bug#70923] [PATCH v2 06/12] import: pypi: Use maybe-upstream-inputs., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 11/12] import: egg: Use maybe-*inputs procedures., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 03/12] tests: elm: Adjust to new-style package inputs., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 08/12] import: hackage: Use maybe-list-field., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 05/12] import: utils: Add maybe-upstream-inputs., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 09/12] import: cran: Refactor format-inputs and use maybe-list-field., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 12/12] import: hexpm: Use maybe-inputs., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 07/12] import: elpa: Use maybe-propagated-inputse., Herman Rimm, 2024/09/04
- [bug#70923] [PATCH v2 10/12] import: cpan: Use maybe-upstream-inputs., Herman Rimm, 2024/09/04