Commit dba536f9 authored by Albert Krewinkel's avatar Albert Krewinkel

Add support for GNU AGPLv3 license (AGPL-3)

It was verified that a generated license file is identical to the
original copy at http://www.gnu.org/licenses/agpl-3.0.html.
parent b27dd6c2
......@@ -16,7 +16,7 @@
-- and it's useful if we can automatically recognise that (eg so we can display
-- it on the hackage web pages). So you can also specify the license itself in
-- the @.cabal@ file from a short enumeration defined in this module. It
-- includes 'GPL', 'LGPL' and 'BSD3' licenses.
-- includes 'GPL', 'AGPL', 'LGPL', 'Apache 2.0', 'MIT' and 'BSD3' licenses.
{- All rights reserved.
......@@ -79,6 +79,9 @@ data License =
-- | GNU Public License. Source code must accompany alterations.
GPL (Maybe Version)
-- | GNU Affero General Public License
| AGPL (Maybe Version)
-- | Lesser GPL, Less restrictive than GPL, useful for libraries.
| LGPL (Maybe Version)
......@@ -114,6 +117,7 @@ data License =
knownLicenses :: [License]
knownLicenses = [ GPL unversioned, GPL (version [2]), GPL (version [3])
, LGPL unversioned, LGPL (version [2,1]), LGPL (version [3])
, AGPL unversioned, AGPL (version [3])
, BSD3, MIT
, Apache unversioned, Apache (version [2, 0])
, PublicDomain, AllRightsReserved, OtherLicense]
......@@ -124,6 +128,7 @@ knownLicenses = [ GPL unversioned, GPL (version [2]), GPL (version [3])
instance Text License where
disp (GPL version) = Disp.text "GPL" <> dispOptVersion version
disp (LGPL version) = Disp.text "LGPL" <> dispOptVersion version
disp (AGPL version) = Disp.text "AGPL" <> dispOptVersion version
disp (Apache version) = Disp.text "Apache" <> dispOptVersion version
disp (UnknownLicense other) = Disp.text other
disp other = Disp.text (show other)
......@@ -134,6 +139,7 @@ instance Text License where
return $! case (name, version :: Maybe Version) of
("GPL", _ ) -> GPL version
("LGPL", _ ) -> LGPL version
("AGPL", _ ) -> AGPL version
("BSD3", Nothing) -> BSD3
("BSD4", Nothing) -> BSD4
("MIT", Nothing) -> MIT
......
......@@ -543,6 +543,9 @@ checkLicense pkg =
unknownLicenseVersion (LGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | LGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (AGPL (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | AGPL (Just v') <- knownLicenses ]
unknownLicenseVersion (Apache (Just v))
| v `notElem` knownVersions = Just knownVersions
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
......@@ -1119,7 +1122,7 @@ checkCabalVersion pkg =
(\v v' -> intersectVersionRanges (orLaterVersion v) (earlierVersion v'))
intersectVersionRanges unionVersionRanges id
compatLicenses = [ GPL Nothing, LGPL Nothing, BSD3, BSD4
compatLicenses = [ GPL Nothing, LGPL Nothing, AGPL Nothing, BSD3, BSD4
, PublicDomain, AllRightsReserved, OtherLicense ]
mentionedExtensions = [ ext | bi <- allBuildInfo pkg
......
......@@ -67,7 +67,7 @@ import Language.Haskell.Extension ( Language(..) )
import Distribution.Client.Init.Types
( InitFlags(..), PackageType(..), Category(..) )
import Distribution.Client.Init.Licenses
( bsd3, gplv2, gplv3, lgpl2, lgpl3, apache20 )
( bsd3, gplv2, gplv3, lgpl2, lgpl3, agplv3, apache20 )
import Distribution.Client.Init.Heuristics
( guessPackageName, guessAuthorNameMail, SourceFileEntry(..),
scanForModules, neededBuildPrograms )
......@@ -179,7 +179,7 @@ getLicense flags = do
return $ flags { license = maybeToFlag lic }
where
listedLicenses =
knownLicenses \\ [GPL Nothing, LGPL Nothing, Apache Nothing, OtherLicense]
knownLicenses \\ [GPL Nothing, LGPL Nothing, AGPL Nothing, Apache Nothing, OtherLicense]
-- | The author's name and email. Prompt, or try to guess from an existing
-- darcs repo.
......@@ -554,6 +554,9 @@ writeLicense flags = do
Flag (LGPL (Just (Version {versionBranch = [3]})))
-> Just lgpl3
Flag (AGPL (Just (Version {versionBranch = [3]})))
-> Just agplv3
Flag (Apache (Just (Version {versionBranch = [2, 0]})))
-> Just apache20
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment