mirror of
https://https.git.savannah.gnu.org/git/guix.git/
synced 2025-07-10 16:50:43 +02:00
import/utils: spdx-string->license: Support '+' operator.
Previously, '+' was supported only via special cases for deprecated GNU identifiers like 'GPL-N+'. This commit adds support for other uses of '+', such as 'AFL-2.0+' and 'LPPL-1.0+'. Strictly speaking, '+' is an operator, not part of the SPDX license identifier, but it is useful to handle it here. * guix/import/utils.scm (spdx-string->license): Support '+' operator. * tests/import-utils.scm ("spdx-string->license"): Test it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
07482dc051
commit
fd5e642513
2 changed files with 16 additions and 11 deletions
|
@ -139,10 +139,11 @@ of the string VERSION is replaced by the symbol 'version."
|
||||||
;; Please update guix/licenses.scm when modifying
|
;; Please update guix/licenses.scm when modifying
|
||||||
;; this list to avoid mismatches.
|
;; this list to avoid mismatches.
|
||||||
;;
|
;;
|
||||||
;; "GPL-N+" has been deprecated in favour of "GPL-N-or-later".
|
;; "GPL-N+" has been deprecated in favour of "GPL-N-or-later". "GPL-N" has
|
||||||
;; "GPL-N" has been deprecated in favour of "GPL-N-only"
|
;; been deprecated in favour of "GPL-N-only" or "GPL-N-or-later" as
|
||||||
;; or "GPL-N-or-later" as appropriate. Likewise for LGPL
|
;; appropriate. Likewise for LGPL and AGPL. However, we list the
|
||||||
;; and AGPL.
|
;; deprecated forms here (with and without the "+" operator) to get better
|
||||||
|
;; results from old license expressions.
|
||||||
'(("AGPL-1.0" . license:agpl1)
|
'(("AGPL-1.0" . license:agpl1)
|
||||||
("AGPL-1.0-only" . license:agpl1)
|
("AGPL-1.0-only" . license:agpl1)
|
||||||
("AGPL-3.0" . license:agpl3)
|
("AGPL-3.0" . license:agpl3)
|
||||||
|
@ -255,10 +256,11 @@ of the string VERSION is replaced by the symbol 'version."
|
||||||
("Zlib" . license:zlib)))
|
("Zlib" . license:zlib)))
|
||||||
|
|
||||||
(define (spdx-string->license str)
|
(define (spdx-string->license str)
|
||||||
"Convert STR, an SPDX license identifier, to a symbol like 'license:gpl3+
|
"Convert STR, an SPDX license identifier (possibly with a postfix +
|
||||||
giving the prefixed name of a license object exported from (guix licenses).
|
operator), to a symbol like 'license:gpl3+ giving the prefixed name of a
|
||||||
Return #f if STR does not match any known SPDX license identifiers. Per the
|
license object exported from (guix licenses). Return #f if STR does not match
|
||||||
SPDX specification, license identifiers are compared case-insensitively."
|
any known SPDX license identifiers. Per the SPDX specification, license
|
||||||
|
identifiers are compared case-insensitively."
|
||||||
;; https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/#d2-case-sensitivity
|
;; https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/#d2-case-sensitivity
|
||||||
;; Operators AND, OR, and WITH are case-sensitive, but identifiers are
|
;; Operators AND, OR, and WITH are case-sensitive, but identifiers are
|
||||||
;; case-insensitive for matching, though the canonical case is used in URIs.
|
;; case-insensitive for matching, though the canonical case is used in URIs.
|
||||||
|
@ -266,7 +268,10 @@ SPDX specification, license identifiers are compared case-insensitively."
|
||||||
((_ . license)
|
((_ . license)
|
||||||
license)
|
license)
|
||||||
(#f
|
(#f
|
||||||
#f)))
|
(and (string-suffix? "+" str)
|
||||||
|
;; We try the form with the + to support deprecated identifiers for
|
||||||
|
;; GNU licenses (see above). Here, we handle other uses of +.
|
||||||
|
(spdx-string->license (string-drop-right str 1))))))
|
||||||
|
|
||||||
(define (license->symbol license)
|
(define (license->symbol license)
|
||||||
"Convert LICENSE object to a prefixed symbol representing the variable the
|
"Convert LICENSE object to a prefixed symbol representing the variable the
|
||||||
|
|
|
@ -236,8 +236,8 @@ Differences are hard to spot, e.g. in CLOS vs. GOOPS."))
|
||||||
(hidden-package? pkg))))
|
(hidden-package? pkg))))
|
||||||
|
|
||||||
(test-equal "spdx-string->license"
|
(test-equal "spdx-string->license"
|
||||||
'(license:gpl3+ license:agpl3)
|
'(license:gpl3+ license:agpl3 license:gpl2+)
|
||||||
(map spdx-string->license
|
(map spdx-string->license
|
||||||
'("GPL-3.0-oR-LaTeR" "AGPL-3.0")))
|
'("GPL-3.0-oR-LaTeR" "AGPL-3.0" "GPL-2.0+")))
|
||||||
|
|
||||||
(test-end "import-utils")
|
(test-end "import-utils")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue