Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle SPDX licences starting with a digit #10356

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import qualified Text.PrettyPrint as Disp

-- | SPDX License Exceptions identifiers list v3.25
data LicenseExceptionId
= DS389_exception -- ^ @389-exception@, 389 Directory Server Exception
= N_389_exception -- ^ @389-exception@, 389 Directory Server Exception
| Asterisk_exception -- ^ @Asterisk-exception@, Asterisk exception, SPDX License List 3.23, SPDX License List 3.25
| Asterisk_linking_protocols_exception -- ^ @Asterisk-linking-protocols-exception@, Asterisk linking protocols exception, SPDX License List 3.25
| Autoconf_exception_2_0 -- ^ @Autoconf-exception-2.0@, Autoconf exception 2.0
Expand Down Expand Up @@ -137,7 +137,7 @@ instance NFData LicenseExceptionId where

-- | License SPDX identifier, e.g. @"BSD-3-Clause"@.
licenseExceptionId :: LicenseExceptionId -> String
licenseExceptionId DS389_exception = "389-exception"
licenseExceptionId N_389_exception = "389-exception"
licenseExceptionId Asterisk_exception = "Asterisk-exception"
licenseExceptionId Asterisk_linking_protocols_exception = "Asterisk-linking-protocols-exception"
licenseExceptionId Autoconf_exception_2_0 = "Autoconf-exception-2.0"
Expand Down Expand Up @@ -212,7 +212,7 @@ licenseExceptionId X11vnc_openssl_exception = "x11vnc-openssl-exception"

-- | License name, e.g. @"GNU General Public License v2.0 only"@
licenseExceptionName :: LicenseExceptionId -> String
licenseExceptionName DS389_exception = "389 Directory Server Exception"
licenseExceptionName N_389_exception = "389 Directory Server Exception"
licenseExceptionName Asterisk_exception = "Asterisk exception"
licenseExceptionName Asterisk_linking_protocols_exception = "Asterisk linking protocols exception"
licenseExceptionName Autoconf_exception_2_0 = "Autoconf exception 2.0"
Expand Down Expand Up @@ -504,7 +504,7 @@ stringLookup_3_25 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
-- | License exceptions in all SPDX License lists
bulkOfLicenses :: [LicenseExceptionId]
bulkOfLicenses =
[ DS389_exception
[ N_389_exception
, Autoconf_exception_2_0
, Autoconf_exception_3_0
, Bison_exception_2_2
Expand Down
18 changes: 9 additions & 9 deletions Cabal-syntax/src/Distribution/SPDX/LicenseId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import qualified Text.PrettyPrint as Disp

-- | SPDX License identifiers list v3.25
data LicenseId
= NullBSD -- ^ @0BSD@, BSD Zero Clause License
| X3D_Slicer_1_0 -- ^ @3D-Slicer-1.0@, 3D Slicer License v1.0, SPDX License List 3.25
= N_0BSD -- ^ @0BSD@, BSD Zero Clause License
| N_3D_Slicer_1_0 -- ^ @3D-Slicer-1.0@, 3D Slicer License v1.0, SPDX License List 3.25
| AAL -- ^ @AAL@, Attribution Assurance License
| Abstyles -- ^ @Abstyles@, Abstyles License
| AdaCore_doc -- ^ @AdaCore-doc@, AdaCore Doc License, SPDX License List 3.23, SPDX License List 3.25
Expand Down Expand Up @@ -756,8 +756,8 @@ licenseIdMigrationMessage = go where

-- | License SPDX identifier, e.g. @"BSD-3-Clause"@.
licenseId :: LicenseId -> String
licenseId NullBSD = "0BSD"
licenseId X3D_Slicer_1_0 = "3D-Slicer-1.0"
licenseId N_0BSD = "0BSD"
licenseId N_3D_Slicer_1_0 = "3D-Slicer-1.0"
licenseId AAL = "AAL"
licenseId Abstyles = "Abstyles"
licenseId AdaCore_doc = "AdaCore-doc"
Expand Down Expand Up @@ -1398,8 +1398,8 @@ licenseId ZPL_2_1 = "ZPL-2.1"

-- | License name, e.g. @"GNU General Public License v2.0 only"@
licenseName :: LicenseId -> String
licenseName NullBSD = "BSD Zero Clause License"
licenseName X3D_Slicer_1_0 = "3D Slicer License v1.0"
licenseName N_0BSD = "BSD Zero Clause License"
licenseName N_3D_Slicer_1_0 = "3D Slicer License v1.0"
licenseName AAL = "Attribution Assurance License"
licenseName Abstyles = "Abstyles License"
licenseName AdaCore_doc = "AdaCore Doc License"
Expand Down Expand Up @@ -2042,7 +2042,7 @@ licenseName ZPL_2_1 = "Zope Public License 2.1"
--
-- See <https://opensource.org/licenses/alphabetical>.
licenseIsOsiApproved :: LicenseId -> Bool
licenseIsOsiApproved NullBSD = True
licenseIsOsiApproved N_0BSD = True
licenseIsOsiApproved AAL = True
licenseIsOsiApproved AFL_1_1 = True
licenseIsOsiApproved AFL_1_2 = True
Expand Down Expand Up @@ -2886,7 +2886,7 @@ licenseIdList LicenseListVersion_3_23 =
]
++ bulkOfLicenses
licenseIdList LicenseListVersion_3_25 =
[ X3D_Slicer_1_0
[ N_3D_Slicer_1_0
, AdaCore_doc
, Adobe_Display_PostScript
, Adobe_Utopia
Expand Down Expand Up @@ -3232,7 +3232,7 @@ stringLookup_3_25 = Map.fromList $ map (\i -> (licenseId i, i)) $
-- | Licenses in all SPDX License lists
bulkOfLicenses :: [LicenseId]
bulkOfLicenses =
[ NullBSD
[ N_0BSD
, AAL
, Abstyles
, Adobe_2006
Expand Down
9 changes: 5 additions & 4 deletions cabal-dev-scripts/src/GenUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Data.Text (Text)
import GHC.Generics (Generic)

import qualified Data.Algorithm.Diff as Diff
import qualified Data.Char as C
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.Text as T
Expand Down Expand Up @@ -165,10 +166,10 @@ toConstructorName t = t
f c = c

special :: Text -> Text
special "0BSD" = "NullBSD"
special "389_exception" = "DS389_exception"
special "3D_Slicer_1_0" = "X3D_Slicer_1_0"
special u = u
special u
| Just (c, _) <- T.uncons u
, C.isDigit c = "N_" <> u
special u = u

mkList :: [Text] -> Text
mkList [] = " []"
Expand Down
11 changes: 11 additions & 0 deletions changelog.d/pr-10356
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: New licence constructors for SPDX licences starting with a digit
packages: Cabal-syntax
prs: #10356

description: {

- LicenseId constructor `NullBSD` is now `N_0BSD`.
- LicenseId constructor `DS389_exception` is now and `N_389_exception`.
- LicenseId constructor `X3D_Slicer_1_0` is now and `N_3D_Slicer_1_0`.

}
Loading