[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#70923] [PATCH v4 08/11] import: cran: Use 'maybe-list-field' proced
From: |
Herman Rimm |
Subject: |
[bug#70923] [PATCH v4 08/11] import: cran: Use 'maybe-list-field' procedure. |
Date: |
Mon, 9 Dec 2024 20:58:12 +0100 |
* guix/import/cran.scm (format-inputs): Delete procedure.
(maybe-inputs): Use 'maybe-list-field' procedure.
Change-Id: I5148afcebdac1f7fa0f8cce9e82e8cebb56c36c8
---
guix/import/cran.scm | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index fe69cb87f7..11843703ac 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -6,6 +6,7 @@
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -86,21 +87,6 @@ (define-module (guix import cran)
(define %input-style
(make-parameter 'variable)) ; or 'specification
-(define (format-inputs inputs)
- "Generate a sorted list of package inputs from a list of upstream inputs."
- (map (lambda (input)
- (case (%input-style)
- ((specification)
- `(specification->package ,(upstream-input-downstream-name input)))
- (else
- ((compose string->symbol
- upstream-input-downstream-name)
- input))))
- (sort inputs
- (lambda (a b)
- (string-ci<? (upstream-input-name a)
- (upstream-input-name b))))))
-
(define (string->licenses license-string license-prefix)
(let ((licenses
(map string-trim-both
@@ -189,11 +175,21 @@ (define (description->alist description)
(define* (maybe-inputs package-inputs #:optional (input-type 'inputs))
"Given a list of PACKAGE-INPUTS, tries to generate the TYPE field of a
package definition."
- (match package-inputs
- (()
- '())
- ((package-inputs ...)
- `((,input-type (list ,@(format-inputs package-inputs)))))))
+ (define (format-input input)
+ (case (%input-style)
+ ((specification)
+ `(specification->package ,(upstream-input-downstream-name input)))
+ (else
+ ((compose string->symbol
+ upstream-input-downstream-name)
+ input))))
+
+ (define (upstream-input-name<? i1 i2)
+ (string-ci<? (upstream-input-name i1)
+ (upstream-input-name i2)))
+
+ (maybe-list-field input-type
+ (map format-input (sort package-inputs upstream-input-name<?))))
(define %cran-url "https://cloud.r-project.org/web/packages/")
(define %cran-canonical-url "https://cran.r-project.org/package=")
--
2.45.2
- [bug#70923] [PATCH v4 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 02/11] import: utils: Emit new-style package inputs., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 03/11] import: crate: Emit new-style package inputs., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 04/11] import: utils: Add 'maybe-upstream-inputs' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 07/11] import: hackage: Use 'maybe-list-field' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 06/11] import: elpa: Use maybe-propagated-inputs procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 08/11] import: cran: Use 'maybe-list-field' procedure.,
Herman Rimm <=
- [bug#70923] [PATCH v4 10/11] import: egg: Use maybe-*inputs procedures., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 11/11] import: hexpm: Use (guix import utils) 'maybe-inputs' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 09/11] import: cpan: Use 'maybe-upstream-inputs' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 05/11] import: pypi: Use 'maybe-list-field' procedure., Herman Rimm, 2024/12/09
- [bug#70923] [PATCH v4 01/11] build-system: cargo: Accept unlabeled #:cargo-inputs., Efraim Flashner, 2024/12/10