From cdec595eee4ce272529f39cd2c7f466849a2ddfa Mon Sep 17 00:00:00 2001 From: Francesco Ariis Date: Sat, 14 Sep 2024 13:25:51 +0200 Subject: [PATCH 1/2] Handle licences starting with a digit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cabal has a devscript that parses a json file (containing SPDX licences) and returns a number of of Haskell data constructors. There have been problems when the SPDX short identifier starts with a digit (e.g. “0BSD”), as that would generate an data constructor starting with a digit, which is not valid Haskell. The way to handle such occourrences was in an ad-hoc basis. This patch prepends “N_” to the beginning of every SPDX licence starting with a digit, future-proofing the script. --- cabal-dev-scripts/src/GenUtils.hs | 9 +++++---- changelog.d/pr-10356 | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 changelog.d/pr-10356 diff --git a/cabal-dev-scripts/src/GenUtils.hs b/cabal-dev-scripts/src/GenUtils.hs index f64388463da..17b4669c837 100644 --- a/cabal-dev-scripts/src/GenUtils.hs +++ b/cabal-dev-scripts/src/GenUtils.hs @@ -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 @@ -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 [] = " []" diff --git a/changelog.d/pr-10356 b/changelog.d/pr-10356 new file mode 100644 index 00000000000..dbe464ae492 --- /dev/null +++ b/changelog.d/pr-10356 @@ -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`. + +} From 52b2082a992d81aa5e94db00d671b7dfb29c73b7 Mon Sep 17 00:00:00 2001 From: Francesco Ariis Date: Sat, 14 Sep 2024 16:27:59 +0200 Subject: [PATCH 2/2] Regenerate licence files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useless since we are going to have to do it again before a release, needed to make CI green (“Check that diff is clean”). --- .../Distribution/SPDX/LicenseExceptionId.hs | 8 ++++---- .../src/Distribution/SPDX/LicenseId.hs | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs b/Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs index 2ab6eb9eeff..6d0bb37caba 100644 --- a/Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs +++ b/Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs @@ -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 @@ -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" @@ -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" @@ -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 diff --git a/Cabal-syntax/src/Distribution/SPDX/LicenseId.hs b/Cabal-syntax/src/Distribution/SPDX/LicenseId.hs index 16421e475f9..95d315906c7 100644 --- a/Cabal-syntax/src/Distribution/SPDX/LicenseId.hs +++ b/Cabal-syntax/src/Distribution/SPDX/LicenseId.hs @@ -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 @@ -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" @@ -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" @@ -2042,7 +2042,7 @@ licenseName ZPL_2_1 = "Zope Public License 2.1" -- -- See . licenseIsOsiApproved :: LicenseId -> Bool -licenseIsOsiApproved NullBSD = True +licenseIsOsiApproved N_0BSD = True licenseIsOsiApproved AAL = True licenseIsOsiApproved AFL_1_1 = True licenseIsOsiApproved AFL_1_2 = True @@ -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 @@ -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