Skip to content

Commit

Permalink
Update licence list
Browse files Browse the repository at this point in the history
Per https://github.com/haskell/cabal/wiki/Updating-the-license-list
to version 3.23 (2024-02-08) of SPDX License List.
  • Loading branch information
ffaf1 committed Mar 19, 2024
1 parent b75671b commit 983c158
Show file tree
Hide file tree
Showing 11 changed files with 1,047 additions and 141 deletions.
156 changes: 141 additions & 15 deletions Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs

Large diffs are not rendered by default.

971 changes: 855 additions & 116 deletions Cabal-syntax/src/Distribution/SPDX/LicenseId.hs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cabal-syntax/src/Distribution/SPDX/LicenseListVersion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ data LicenseListVersion
| LicenseListVersion_3_9
| LicenseListVersion_3_10
| LicenseListVersion_3_16
| LicenseListVersion_3_23
deriving (Eq, Ord, Show, Enum, Bounded)

cabalSpecVersionToSPDXListVersion :: CabalSpecVersion -> LicenseListVersion
cabalSpecVersionToSPDXListVersion CabalSpecV3_12 = LicenseListVersion_3_23
cabalSpecVersionToSPDXListVersion CabalSpecV3_8 = LicenseListVersion_3_16
cabalSpecVersionToSPDXListVersion CabalSpecV3_6 = LicenseListVersion_3_10
cabalSpecVersionToSPDXListVersion CabalSpecV3_4 = LicenseListVersion_3_9
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SPDX_EXCEPTION_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs

spdx : $(SPDX_LICENSE_HS) $(SPDX_EXCEPTION_HS)

SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10 3.16
SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10 3.16 3.23

$(SPDX_LICENSE_HS) : templates/SPDX.LicenseId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDX.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json
cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-spdx -- templates/SPDX.LicenseId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/licenses-%.json) $(SPDX_LICENSE_HS)
Expand Down
1 change: 1 addition & 0 deletions cabal-dev-scripts/src/GenSPDX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ main = generate =<< O.execParser opts where
<*> licenses "3.9"
<*> licenses "3.10"
<*> licenses "3.16"
<*> licenses "3.23"

template = O.strArgument $ mconcat
[ O.metavar "SPDX.LicenseId.template.hs"
Expand Down
1 change: 1 addition & 0 deletions cabal-dev-scripts/src/GenSPDXExc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ main = generate =<< O.execParser opts where
<*> licenses "3.9"
<*> licenses "3.10"
<*> licenses "3.16"
<*> licenses "3.23"

template = O.strArgument $ mconcat
[ O.metavar "SPDX.LicenseExceptionId.template.hs"
Expand Down
19 changes: 12 additions & 7 deletions cabal-dev-scripts/src/GenUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ data SPDXLicenseListVersion
| SPDXLicenseListVersion_3_9
| SPDXLicenseListVersion_3_10
| SPDXLicenseListVersion_3_16
| SPDXLicenseListVersion_3_23
deriving (Eq, Ord, Show, Enum, Bounded)

allVers :: Set.Set SPDXLicenseListVersion
allVers = Set.fromList [minBound .. maxBound]

prettyVer :: SPDXLicenseListVersion -> Text
prettyVer SPDXLicenseListVersion_3_23 = "SPDX License List 3.23"
prettyVer SPDXLicenseListVersion_3_16 = "SPDX License List 3.16"
prettyVer SPDXLicenseListVersion_3_10 = "SPDX License List 3.10"
prettyVer SPDXLicenseListVersion_3_9 = "SPDX License List 3.9"
Expand All @@ -46,6 +48,7 @@ prettyVer SPDXLicenseListVersion_3_2 = "SPDX License List 3.2"
prettyVer SPDXLicenseListVersion_3_0 = "SPDX License List 3.0"

suffixVer :: SPDXLicenseListVersion -> String
suffixVer SPDXLicenseListVersion_3_23 = "_3_23"
suffixVer SPDXLicenseListVersion_3_16 = "_3_16"
suffixVer SPDXLicenseListVersion_3_10 = "_3_10"
suffixVer SPDXLicenseListVersion_3_9 = "_3_9"
Expand All @@ -57,20 +60,21 @@ suffixVer SPDXLicenseListVersion_3_0 = "_3_0"
-- Per version
-------------------------------------------------------------------------------

data PerV a = PerV a a a a a a
data PerV a = PerV a a a a a a a
deriving (Show, Functor, Foldable, Traversable)

class Functor f => Representable i f | f -> i where
index :: i -> f a -> a
tabulate :: (i -> a) -> f a

instance Representable SPDXLicenseListVersion PerV where
index SPDXLicenseListVersion_3_0 (PerV x _ _ _ _ _) = x
index SPDXLicenseListVersion_3_2 (PerV _ x _ _ _ _) = x
index SPDXLicenseListVersion_3_6 (PerV _ _ x _ _ _) = x
index SPDXLicenseListVersion_3_9 (PerV _ _ _ x _ _) = x
index SPDXLicenseListVersion_3_10 (PerV _ _ _ _ x _) = x
index SPDXLicenseListVersion_3_16 (PerV _ _ _ _ _ x) = x
index SPDXLicenseListVersion_3_0 (PerV x _ _ _ _ _ _) = x
index SPDXLicenseListVersion_3_2 (PerV _ x _ _ _ _ _) = x
index SPDXLicenseListVersion_3_6 (PerV _ _ x _ _ _ _) = x
index SPDXLicenseListVersion_3_9 (PerV _ _ _ x _ _ _) = x
index SPDXLicenseListVersion_3_10 (PerV _ _ _ _ x _ _) = x
index SPDXLicenseListVersion_3_16 (PerV _ _ _ _ _ x _) = x
index SPDXLicenseListVersion_3_23 (PerV _ _ _ _ _ _ x) = x

tabulate f = PerV
(f SPDXLicenseListVersion_3_0)
Expand All @@ -79,6 +83,7 @@ instance Representable SPDXLicenseListVersion PerV where
(f SPDXLicenseListVersion_3_9)
(f SPDXLicenseListVersion_3_10)
(f SPDXLicenseListVersion_3_16)
(f SPDXLicenseListVersion_3_23)

-------------------------------------------------------------------------------
-- Sorting
Expand Down
10 changes: 10 additions & 0 deletions changelog.d/pr-spdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
synopsis: Update SPDX License List to version `3.23 2024-02-08`
packages: Cabal-syntax
prs: #9818

description: {

- LicenseId and LicenseExceptionId now conform to SPDX License List
version 3.23 2024-02-08.

}
7 changes: 7 additions & 0 deletions doc/file-format-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ relative to the respective preceding *published* version.
versions of the ``Cabal`` library denote unreleased development
branches which have no stability guarantee.

``cabal-version: 3.12``
-----------------------

* License fields use identifiers from SPDX License List version
``3.23 2024-02-08``.


``cabal-version: 3.8``
----------------------

Expand Down
10 changes: 9 additions & 1 deletion templates/SPDX.LicenseExceptionId.template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import qualified Text.PrettyPrint as Disp
-- LicenseExceptionId
-------------------------------------------------------------------------------

-- | SPDX License Exceptions identifiers list v3.16
-- | SPDX License Exceptions identifiers list v3.23
data LicenseExceptionId
{{ licenseIds }}
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data, Generic)
Expand Down Expand Up @@ -98,6 +98,9 @@ licenseExceptionIdList LicenseListVersion_3_10 =
licenseExceptionIdList LicenseListVersion_3_16 =
{{licenseList_perv.v_3_16}}
++ bulkOfLicenses
licenseExceptionIdList LicenseListVersion_3_23 =
{{licenseList_perv.v_3_23}}
++ bulkOfLicenses

-- | Create a 'LicenseExceptionId' from a 'String'.
mkLicenseExceptionId :: LicenseListVersion -> String -> Maybe LicenseExceptionId
Expand All @@ -107,6 +110,7 @@ mkLicenseExceptionId LicenseListVersion_3_6 s = Map.lookup s stringLookup_3_6
mkLicenseExceptionId LicenseListVersion_3_9 s = Map.lookup s stringLookup_3_9
mkLicenseExceptionId LicenseListVersion_3_10 s = Map.lookup s stringLookup_3_10
mkLicenseExceptionId LicenseListVersion_3_16 s = Map.lookup s stringLookup_3_16
mkLicenseExceptionId LicenseListVersion_3_23 s = Map.lookup s stringLookup_3_23

stringLookup_3_0 :: Map String LicenseExceptionId
stringLookup_3_0 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
Expand All @@ -132,6 +136,10 @@ stringLookup_3_16 :: Map String LicenseExceptionId
stringLookup_3_16 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
licenseExceptionIdList LicenseListVersion_3_16

stringLookup_3_23 :: Map String LicenseExceptionId
stringLookup_3_23 = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $
licenseExceptionIdList LicenseListVersion_3_23

-- | License exceptions in all SPDX License lists
bulkOfLicenses :: [LicenseExceptionId]
bulkOfLicenses =
Expand Down
9 changes: 8 additions & 1 deletion templates/SPDX.LicenseId.template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import qualified Text.PrettyPrint as Disp
-- LicenseId
-------------------------------------------------------------------------------

-- | SPDX License identifiers list v3.16
-- | SPDX License identifiers list v3.23
data LicenseId
{{ licenseIds }}
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data)
Expand Down Expand Up @@ -174,6 +174,8 @@ licenseIdList LicenseListVersion_3_10 =
++ bulkOfLicenses
licenseIdList LicenseListVersion_3_16 =
{{licenseList_perv.v_3_16}}
licenseIdList LicenseListVersion_3_23 =
{{licenseList_perv.v_3_23}}
++ bulkOfLicenses

-- | Create a 'LicenseId' from a 'String'.
Expand All @@ -184,6 +186,7 @@ mkLicenseId LicenseListVersion_3_6 s = Map.lookup s stringLookup_3_6
mkLicenseId LicenseListVersion_3_9 s = Map.lookup s stringLookup_3_9
mkLicenseId LicenseListVersion_3_10 s = Map.lookup s stringLookup_3_10
mkLicenseId LicenseListVersion_3_16 s = Map.lookup s stringLookup_3_16
mkLicenseId LicenseListVersion_3_23 s = Map.lookup s stringLookup_3_23

stringLookup_3_0 :: Map String LicenseId
stringLookup_3_0 = Map.fromList $ map (\i -> (licenseId i, i)) $
Expand All @@ -209,6 +212,10 @@ stringLookup_3_16 :: Map String LicenseId
stringLookup_3_16 = Map.fromList $ map (\i -> (licenseId i, i)) $
licenseIdList LicenseListVersion_3_16

stringLookup_3_23 :: Map String LicenseId
stringLookup_3_23 = Map.fromList $ map (\i -> (licenseId i, i)) $
licenseIdList LicenseListVersion_3_23

-- | Licenses in all SPDX License lists
bulkOfLicenses :: [LicenseId]
bulkOfLicenses =
Expand Down

0 comments on commit 983c158

Please sign in to comment.