Skip to content

Commit af9096e

Browse files
committed
Restore old licence acceptance logic for pre-cabal-version:2.2
In 5c06aba the legacy licence enum was mapped to SPDX licences, thereby implicitly disallowing the use of `OtherLicence`; this commit avoids mapping legacy licences to SPDX and restores the original acceptance-check, thereby re-allowing `OtherLicence`s
1 parent c574405 commit af9096e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Distribution/Server/Packages/Unpack.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Distribution.Package
2626
import Distribution.PackageDescription
2727
( GenericPackageDescription(..), PackageDescription(..)
2828
, allBuildInfo, allLibraries
29-
, mixins, signatures, specVersion, license
29+
, mixins, signatures, specVersion, licenseRaw
3030
)
3131
import Distribution.PackageDescription.Configuration
3232
( flattenPackageDescription )
@@ -39,6 +39,7 @@ import Distribution.Text
3939
( Text(..), display, simpleParse )
4040
import Distribution.Server.Util.ParseSpecVer
4141
import qualified Distribution.SPDX as SPDX
42+
import qualified Distribution.License as License
4243
import qualified Distribution.Compat.ReadP as Parse
4344

4445
import Control.Monad.Except
@@ -515,11 +516,12 @@ startsWithBOM bs = LBS.take 3 bs == LBS.pack [0xEF, 0xBB, 0xBF]
515516
-- OSI-accepted licenses or CC0
516517
--
517518
isAcceptableLicense :: PackageDescription -> Bool
518-
isAcceptableLicense = go . license
519+
isAcceptableLicense = either goSpdx goLegacy . licenseRaw
519520
where
520-
go :: SPDX.License -> Bool
521-
go SPDX.NONE = False
522-
go (SPDX.License expr) = goExpr expr
521+
-- `cabal-version: 2.2` and later
522+
goSpdx :: SPDX.License -> Bool
523+
goSpdx SPDX.NONE = False
524+
goSpdx (SPDX.License expr) = goExpr expr
523525
where
524526
goExpr (SPDX.EAnd a b) = goExpr a && goExpr b
525527
goExpr (SPDX.EOr a b) = goExpr a || goExpr b
@@ -530,3 +532,7 @@ isAcceptableLicense = go . license
530532
goSimple (SPDX.ELicenseIdPlus _) = False -- don't allow + licenses (use GPL-3.0-or-later e.g.)
531533
goSimple (SPDX.ELicenseId SPDX.CC0_1_0) = True -- CC0 isn't OSI approved, but we allow it as "PublicDomain", this is eg. PublicDomain in http://hackage.haskell.org/package/string-qq-0.0.2/src/LICENSE
532534
goSimple (SPDX.ELicenseId lid) = SPDX.licenseIsOsiApproved lid -- allow only OSI approved licenses.
535+
536+
-- pre `cabal-version: 2.2`
537+
goLegacy License.AllRightsReserved = False
538+
goLegacy _ = True

0 commit comments

Comments
 (0)