[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#42338] [PATCH 6/9] guix: import: composer: More robust string->lice
From: |
Nicolas Graves |
Subject: |
[bug#42338] [PATCH 6/9] guix: import: composer: More robust string->license. |
Date: |
Thu, 2 Nov 2023 16:04:26 +0100 |
* guix/import/composer.scm (string->license): Use spdx-string->license. Fall
back to unknown-license!.
---
guix/import/composer.scm | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/guix/import/composer.scm b/guix/import/composer.scm
index 3acbbecf82..49f16caedf 100644
--- a/guix/import/composer.scm
+++ b/guix/import/composer.scm
@@ -109,7 +109,10 @@ (define-json-mapping <composer-package>
make-composer-package composer-package?
(dev-require composer-package-dev-require "require-dev" json->require)
(license composer-package-license "license"
(lambda (vector)
- (map string->license (vector->list vector)))))
+ (let ((l (map string->license (vector->list vector))))
+ (if (eq? (length l) 1)
+ (car l)
+ `(list ,@l))))))
(define* (composer-fetch name #:optional version)
"Return an alist representation of the Composer metadata for the package
NAME,
@@ -194,10 +197,8 @@ (define (make-php-sexp composer-package)
(synopsis "")
(description ,(composer-package-description composer-package))
(home-page ,(composer-package-homepage composer-package))
- (license ,(match (composer-package-license composer-package)
- (() #f)
- ((license) license)
- (_ license)))))))))
+ (license ,(or (composer-package-license composer-package)
+ 'unknown-license!))))))))
(define composer->guix-package
(memoize
@@ -234,14 +235,15 @@ (define (guix-package->composer-name package)
(define (string->license str)
"Convert the string STR into a license object."
- (match str
- ("GNU LGPL" 'license:lgpl2.0)
- ("GPL" 'license:gpl3)
- ((or "BSD" "BSD License" "BSD-3-Clause") 'license:bsd-3)
- ((or "MIT" "MIT license" "Expat license") 'license:expat)
- ("Public domain" 'license:public-domain)
- ((or "Apache License, Version 2.0" "Apache 2.0") 'license:asl2.0)
- (_ #f)))
+ (or (spdx-string->license str)
+ (match str
+ ("GNU LGPL" 'license:lgpl2.0)
+ ("GPL" 'license:gpl3)
+ ((or "BSD" "BSD License") 'license:bsd-3)
+ ((or "MIT" "MIT license" "Expat license") 'license:expat)
+ ("Public domain" 'license:public-domain)
+ ((or "Apache License, Version 2.0" "Apache 2.0") 'license:asl2.0)
+ (_ 'unknown-license!))))
(define (php-package? package)
"Return true if PACKAGE is a PHP package from Packagist."
--
2.41.0
- [bug#42338] [PATCH 0/9] Composer build system, Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 3/9] guix: Add composer-build-system., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 9/9] gnu: composer-build-system: Full check phase rewrite., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 5/9] guix: import: composer: Fix json->require., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 1/9] guix: import: Add composer importer., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 2/9] gnu: Add composer-classloader., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 6/9] guix: import: composer: More robust string->license.,
Nicolas Graves <=
- [bug#42338] [PATCH 4/9] guix: import: composer: Use memoization., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 7/9] guix: import: composer: Modern inputs formatting., Nicolas Graves, 2023/11/02
- [bug#42338] [PATCH 8/9] guix: import: composer: Full rewrite composer-fetch., Nicolas Graves, 2023/11/02