unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Philip McGrath <philip@philipmcgrath.com>
To: 58621@debbugs.gnu.org
Cc: Philip McGrath <philip@philipmcgrath.com>
Subject: [bug#58621] [PATCH 3/3] import/utils: spdx-string->license: Support '+' operator.
Date: Wed, 19 Oct 2022 01:04:49 -0400	[thread overview]
Message-ID: <13f3bbfbd88f0e9c984fd61a5c936de08d814ce0.1666146461.git.philip@philipmcgrath.com> (raw)
In-Reply-To: <cover.1666146461.git.philip@philipmcgrath.com>

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.
---
 guix/import/utils.scm | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 9944b606f3..a32fa4857e 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -139,10 +139,11 @@ (define %spdx-license-identifiers
   ;; Please update guix/licenses.scm when modifying
   ;; 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-only"
-  ;; or "GPL-N-or-later" as appropriate.  Likewise for LGPL
-  ;; and AGPL.
+  ;; "GPL-N+" has been deprecated in favour of "GPL-N-or-later".  "GPL-N" has
+  ;; been deprecated in favour of "GPL-N-only" or "GPL-N-or-later" as
+  ;; appropriate.  Likewise for LGPL and AGPL.  However, we list the
+  ;; deprecated forms here (with and without the "+" operator) to get better
+  ;; results from old license expressions.
   '(("AGPL-1.0"                   . license:agpl1)
     ("AGPL-1.0-only"              . license:agpl1)
     ("AGPL-3.0"                   . license:agpl3)
@@ -255,10 +256,11 @@ (define %spdx-license-identifiers
     ("Zlib"                       . license:zlib)))
 
 (define (spdx-string->license str)
-  "Convert STR, an SPDX license identifier, to a symbol like 'license:gpl3+
-giving the prefixed name of a license object exported from (guix licenses).
-Return #f if STR does not match any known SPDX license identifiers.  Per the
-SPDX specification, license identifiers are compared case-insensitively."
+  "Convert STR, an SPDX license identifier (possibly with a postfix +
+operator), to a symbol like 'license:gpl3+ giving the prefixed name of a
+license object exported from (guix licenses).  Return #f if STR does not match
+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
   ;; Operators AND, OR, and WITH are case-sensitive, but identifiers are
   ;; case-insensitive for matching, though the canonical case is used in URIs.
@@ -266,7 +268,11 @@ (define (spdx-string->license str)
     ((_ . license)
      license)
     (#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
+           (substring str 0 (- (string-length str) 1)))))))
 
 (define (license->symbol license)
   "Convert LICENSE object to a prefixed symbol representing the variable the
-- 
2.38.0





  parent reply	other threads:[~2022-10-19  5:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19  4:55 [bug#58621] [PATCH 0/3] import/utils: spdx-string->license: Match case-insensitively and support '+' operator Philip McGrath
2022-10-19  5:04 ` [bug#58621] [PATCH 1/3] import/utils: spdx-string->license: Fix incorrect docstring Philip McGrath
2022-10-19  5:04 ` [bug#58621] [PATCH 2/3] import/utils: spdx-string->license: Match case-insensitively Philip McGrath
2022-10-19  5:04 ` Philip McGrath [this message]
2022-11-18 13:45   ` bug#58621: [PATCH 0/3] import/utils: spdx-string->license: Match case-insensitively and support '+' operator Ludovic Courtès
2022-11-18 20:21     ` [bug#58621] " Philip McGrath
2022-11-20 10:49       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13f3bbfbd88f0e9c984fd61a5c936de08d814ce0.1666146461.git.philip@philipmcgrath.com \
    --to=philip@philipmcgrath.com \
    --cc=58621@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).