Skip to content

Commit 39db02e

Browse files
committed
Merge pull request #1 from iustin/master
Add support for the Apache license
2 parents 85f959a + f06a8fa commit 39db02e

File tree

5 files changed

+223
-3
lines changed

5 files changed

+223
-3
lines changed

Cabal/Distribution/License.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ data License =
8989
-- | The MIT license, similar to the BSD3. Very free license.
9090
| MIT
9191

92+
-- | The Apache License. Version 2.0 is the current version,
93+
-- previous versions are considered historical.
94+
95+
| Apache (Maybe Version)
96+
9297
-- | Holder makes no claim to ownership, least restrictive license.
9398
| PublicDomain
9499

@@ -107,6 +112,7 @@ knownLicenses :: [License]
107112
knownLicenses = [ GPL unversioned, GPL (version [2]), GPL (version [3])
108113
, LGPL unversioned, LGPL (version [2,1]), LGPL (version [3])
109114
, BSD3, MIT
115+
, Apache unversioned, Apache (version [2, 0])
110116
, PublicDomain, AllRightsReserved, OtherLicense]
111117
where
112118
unversioned = Nothing
@@ -115,6 +121,7 @@ knownLicenses = [ GPL unversioned, GPL (version [2]), GPL (version [3])
115121
instance Text License where
116122
disp (GPL version) = Disp.text "GPL" <> dispOptVersion version
117123
disp (LGPL version) = Disp.text "LGPL" <> dispOptVersion version
124+
disp (Apache version) = Disp.text "Apache" <> dispOptVersion version
118125
disp (UnknownLicense other) = Disp.text other
119126
disp other = Disp.text (show other)
120127

@@ -127,6 +134,7 @@ instance Text License where
127134
("BSD3", Nothing) -> BSD3
128135
("BSD4", Nothing) -> BSD4
129136
("MIT", Nothing) -> MIT
137+
("Apache", _ ) -> Apache version
130138
("PublicDomain", Nothing) -> PublicDomain
131139
("AllRightsReserved", Nothing) -> AllRightsReserved
132140
("OtherLicense", Nothing) -> OtherLicense

Cabal/Distribution/PackageDescription/Check.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ checkLicense pkg =
516516
unknownLicenseVersion (LGPL (Just v))
517517
| v `notElem` knownVersions = Just knownVersions
518518
where knownVersions = [ v' | LGPL (Just v') <- knownLicenses ]
519+
unknownLicenseVersion (Apache (Just v))
520+
| v `notElem` knownVersions = Just knownVersions
521+
where knownVersions = [ v' | Apache (Just v') <- knownLicenses ]
519522
unknownLicenseVersion _ = Nothing
520523

521524
checkSourceRepos :: PackageDescription -> [PackageCheck]

Cabal/tests/UnitTest/Distribution/PackageDescription.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ hunitTests =
199199
[ TestLabel "license parsers" $ TestCase $
200200
sequence_ [ assertParseOk ("license " ++ show lVal) lVal
201201
(runP 1 "license" parseLicenseQ (show lVal))
202-
| lVal <- [GPL,LGPL,BSD3,BSD4] ]
202+
| lVal <- [GPL,LGPL,BSD3,BSD4,Apache] ]
203203

204204
, TestLabel "Required fields" $ TestCase $
205205
do assertParseOk "some fields"

cabal-install/Distribution/Client/Init.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import qualified Distribution.Package as P
6767
import Distribution.Client.Init.Types
6868
( InitFlags(..), PackageType(..), Category(..) )
6969
import Distribution.Client.Init.Licenses
70-
( bsd3, gplv2, gplv3, lgpl2, lgpl3 )
70+
( bsd3, gplv2, gplv3, lgpl2, lgpl3, apache20 )
7171
import Distribution.Client.Init.Heuristics
7272
( guessPackageName, guessAuthorNameMail, SourceFileEntry(..), scanForModules, neededBuildPrograms )
7373

@@ -178,7 +178,7 @@ getLicense flags = do
178178
return $ flags { license = maybeToFlag lic }
179179
where
180180
listedLicenses =
181-
knownLicenses \\ [GPL Nothing, LGPL Nothing, OtherLicense]
181+
knownLicenses \\ [GPL Nothing, LGPL Nothing, Apache Nothing, OtherLicense]
182182

183183
-- | The author's name and email. Prompt, or try to guess from an existing
184184
-- darcs repo.
@@ -495,6 +495,9 @@ writeLicense flags = do
495495
Flag (LGPL (Just (Version {versionBranch = [3]})))
496496
-> Just lgpl3
497497

498+
Flag (Apache (Just (Version {versionBranch = [2, 0]})))
499+
-> Just apache20
500+
498501
_ -> Nothing
499502

500503
case licenseFile of

cabal-install/Distribution/Client/Init/Licenses.hs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Distribution.Client.Init.Licenses
55
, gplv3
66
, lgpl2
77
, lgpl3
8+
, apache20
89

910
) where
1011

@@ -1720,3 +1721,208 @@ lgpl3 = unlines
17201721
, "Library."
17211722
]
17221723

1724+
apache20 :: License
1725+
apache20 = unlines
1726+
[ ""
1727+
, " Apache License"
1728+
, " Version 2.0, January 2004"
1729+
, " http://www.apache.org/licenses/"
1730+
, ""
1731+
, " TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION"
1732+
, ""
1733+
, " 1. Definitions."
1734+
, ""
1735+
, " \"License\" shall mean the terms and conditions for use, reproduction,"
1736+
, " and distribution as defined by Sections 1 through 9 of this document."
1737+
, ""
1738+
, " \"Licensor\" shall mean the copyright owner or entity authorized by"
1739+
, " the copyright owner that is granting the License."
1740+
, ""
1741+
, " \"Legal Entity\" shall mean the union of the acting entity and all"
1742+
, " other entities that control, are controlled by, or are under common"
1743+
, " control with that entity. For the purposes of this definition,"
1744+
, " \"control\" means (i) the power, direct or indirect, to cause the"
1745+
, " direction or management of such entity, whether by contract or"
1746+
, " otherwise, or (ii) ownership of fifty percent (50%) or more of the"
1747+
, " outstanding shares, or (iii) beneficial ownership of such entity."
1748+
, ""
1749+
, " \"You\" (or \"Your\") shall mean an individual or Legal Entity"
1750+
, " exercising permissions granted by this License."
1751+
, ""
1752+
, " \"Source\" form shall mean the preferred form for making modifications,"
1753+
, " including but not limited to software source code, documentation"
1754+
, " source, and configuration files."
1755+
, ""
1756+
, " \"Object\" form shall mean any form resulting from mechanical"
1757+
, " transformation or translation of a Source form, including but"
1758+
, " not limited to compiled object code, generated documentation,"
1759+
, " and conversions to other media types."
1760+
, ""
1761+
, " \"Work\" shall mean the work of authorship, whether in Source or"
1762+
, " Object form, made available under the License, as indicated by a"
1763+
, " copyright notice that is included in or attached to the work"
1764+
, " (an example is provided in the Appendix below)."
1765+
, ""
1766+
, " \"Derivative Works\" shall mean any work, whether in Source or Object"
1767+
, " form, that is based on (or derived from) the Work and for which the"
1768+
, " editorial revisions, annotations, elaborations, or other modifications"
1769+
, " represent, as a whole, an original work of authorship. For the purposes"
1770+
, " of this License, Derivative Works shall not include works that remain"
1771+
, " separable from, or merely link (or bind by name) to the interfaces of,"
1772+
, " the Work and Derivative Works thereof."
1773+
, ""
1774+
, " \"Contribution\" shall mean any work of authorship, including"
1775+
, " the original version of the Work and any modifications or additions"
1776+
, " to that Work or Derivative Works thereof, that is intentionally"
1777+
, " submitted to Licensor for inclusion in the Work by the copyright owner"
1778+
, " or by an individual or Legal Entity authorized to submit on behalf of"
1779+
, " the copyright owner. For the purposes of this definition, \"submitted\""
1780+
, " means any form of electronic, verbal, or written communication sent"
1781+
, " to the Licensor or its representatives, including but not limited to"
1782+
, " communication on electronic mailing lists, source code control systems,"
1783+
, " and issue tracking systems that are managed by, or on behalf of, the"
1784+
, " Licensor for the purpose of discussing and improving the Work, but"
1785+
, " excluding communication that is conspicuously marked or otherwise"
1786+
, " designated in writing by the copyright owner as \"Not a Contribution.\""
1787+
, ""
1788+
, " \"Contributor\" shall mean Licensor and any individual or Legal Entity"
1789+
, " on behalf of whom a Contribution has been received by Licensor and"
1790+
, " subsequently incorporated within the Work."
1791+
, ""
1792+
, " 2. Grant of Copyright License. Subject to the terms and conditions of"
1793+
, " this License, each Contributor hereby grants to You a perpetual,"
1794+
, " worldwide, non-exclusive, no-charge, royalty-free, irrevocable"
1795+
, " copyright license to reproduce, prepare Derivative Works of,"
1796+
, " publicly display, publicly perform, sublicense, and distribute the"
1797+
, " Work and such Derivative Works in Source or Object form."
1798+
, ""
1799+
, " 3. Grant of Patent License. Subject to the terms and conditions of"
1800+
, " this License, each Contributor hereby grants to You a perpetual,"
1801+
, " worldwide, non-exclusive, no-charge, royalty-free, irrevocable"
1802+
, " (except as stated in this section) patent license to make, have made,"
1803+
, " use, offer to sell, sell, import, and otherwise transfer the Work,"
1804+
, " where such license applies only to those patent claims licensable"
1805+
, " by such Contributor that are necessarily infringed by their"
1806+
, " Contribution(s) alone or by combination of their Contribution(s)"
1807+
, " with the Work to which such Contribution(s) was submitted. If You"
1808+
, " institute patent litigation against any entity (including a"
1809+
, " cross-claim or counterclaim in a lawsuit) alleging that the Work"
1810+
, " or a Contribution incorporated within the Work constitutes direct"
1811+
, " or contributory patent infringement, then any patent licenses"
1812+
, " granted to You under this License for that Work shall terminate"
1813+
, " as of the date such litigation is filed."
1814+
, ""
1815+
, " 4. Redistribution. You may reproduce and distribute copies of the"
1816+
, " Work or Derivative Works thereof in any medium, with or without"
1817+
, " modifications, and in Source or Object form, provided that You"
1818+
, " meet the following conditions:"
1819+
, ""
1820+
, " (a) You must give any other recipients of the Work or"
1821+
, " Derivative Works a copy of this License; and"
1822+
, ""
1823+
, " (b) You must cause any modified files to carry prominent notices"
1824+
, " stating that You changed the files; and"
1825+
, ""
1826+
, " (c) You must retain, in the Source form of any Derivative Works"
1827+
, " that You distribute, all copyright, patent, trademark, and"
1828+
, " attribution notices from the Source form of the Work,"
1829+
, " excluding those notices that do not pertain to any part of"
1830+
, " the Derivative Works; and"
1831+
, ""
1832+
, " (d) If the Work includes a \"NOTICE\" text file as part of its"
1833+
, " distribution, then any Derivative Works that You distribute must"
1834+
, " include a readable copy of the attribution notices contained"
1835+
, " within such NOTICE file, excluding those notices that do not"
1836+
, " pertain to any part of the Derivative Works, in at least one"
1837+
, " of the following places: within a NOTICE text file distributed"
1838+
, " as part of the Derivative Works; within the Source form or"
1839+
, " documentation, if provided along with the Derivative Works; or,"
1840+
, " within a display generated by the Derivative Works, if and"
1841+
, " wherever such third-party notices normally appear. The contents"
1842+
, " of the NOTICE file are for informational purposes only and"
1843+
, " do not modify the License. You may add Your own attribution"
1844+
, " notices within Derivative Works that You distribute, alongside"
1845+
, " or as an addendum to the NOTICE text from the Work, provided"
1846+
, " that such additional attribution notices cannot be construed"
1847+
, " as modifying the License."
1848+
, ""
1849+
, " You may add Your own copyright statement to Your modifications and"
1850+
, " may provide additional or different license terms and conditions"
1851+
, " for use, reproduction, or distribution of Your modifications, or"
1852+
, " for any such Derivative Works as a whole, provided Your use,"
1853+
, " reproduction, and distribution of the Work otherwise complies with"
1854+
, " the conditions stated in this License."
1855+
, ""
1856+
, " 5. Submission of Contributions. Unless You explicitly state otherwise,"
1857+
, " any Contribution intentionally submitted for inclusion in the Work"
1858+
, " by You to the Licensor shall be under the terms and conditions of"
1859+
, " this License, without any additional terms or conditions."
1860+
, " Notwithstanding the above, nothing herein shall supersede or modify"
1861+
, " the terms of any separate license agreement you may have executed"
1862+
, " with Licensor regarding such Contributions."
1863+
, ""
1864+
, " 6. Trademarks. This License does not grant permission to use the trade"
1865+
, " names, trademarks, service marks, or product names of the Licensor,"
1866+
, " except as required for reasonable and customary use in describing the"
1867+
, " origin of the Work and reproducing the content of the NOTICE file."
1868+
, ""
1869+
, " 7. Disclaimer of Warranty. Unless required by applicable law or"
1870+
, " agreed to in writing, Licensor provides the Work (and each"
1871+
, " Contributor provides its Contributions) on an \"AS IS\" BASIS,"
1872+
, " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or"
1873+
, " implied, including, without limitation, any warranties or conditions"
1874+
, " of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A"
1875+
, " PARTICULAR PURPOSE. You are solely responsible for determining the"
1876+
, " appropriateness of using or redistributing the Work and assume any"
1877+
, " risks associated with Your exercise of permissions under this License."
1878+
, ""
1879+
, " 8. Limitation of Liability. In no event and under no legal theory,"
1880+
, " whether in tort (including negligence), contract, or otherwise,"
1881+
, " unless required by applicable law (such as deliberate and grossly"
1882+
, " negligent acts) or agreed to in writing, shall any Contributor be"
1883+
, " liable to You for damages, including any direct, indirect, special,"
1884+
, " incidental, or consequential damages of any character arising as a"
1885+
, " result of this License or out of the use or inability to use the"
1886+
, " Work (including but not limited to damages for loss of goodwill,"
1887+
, " work stoppage, computer failure or malfunction, or any and all"
1888+
, " other commercial damages or losses), even if such Contributor"
1889+
, " has been advised of the possibility of such damages."
1890+
, ""
1891+
, " 9. Accepting Warranty or Additional Liability. While redistributing"
1892+
, " the Work or Derivative Works thereof, You may choose to offer,"
1893+
, " and charge a fee for, acceptance of support, warranty, indemnity,"
1894+
, " or other liability obligations and/or rights consistent with this"
1895+
, " License. However, in accepting such obligations, You may act only"
1896+
, " on Your own behalf and on Your sole responsibility, not on behalf"
1897+
, " of any other Contributor, and only if You agree to indemnify,"
1898+
, " defend, and hold each Contributor harmless for any liability"
1899+
, " incurred by, or claims asserted against, such Contributor by reason"
1900+
, " of your accepting any such warranty or additional liability."
1901+
, ""
1902+
, " END OF TERMS AND CONDITIONS"
1903+
, ""
1904+
, " APPENDIX: How to apply the Apache License to your work."
1905+
, ""
1906+
, " To apply the Apache License to your work, attach the following"
1907+
, " boilerplate notice, with the fields enclosed by brackets \"[]\""
1908+
, " replaced with your own identifying information. (Don't include"
1909+
, " the brackets!) The text should be enclosed in the appropriate"
1910+
, " comment syntax for the file format. We also recommend that a"
1911+
, " file or class name and description of purpose be included on the"
1912+
, " same \"printed page\" as the copyright notice for easier"
1913+
, " identification within third-party archives."
1914+
, ""
1915+
, " Copyright [yyyy] [name of copyright owner]"
1916+
, ""
1917+
, " Licensed under the Apache License, Version 2.0 (the \"License\");"
1918+
, " you may not use this file except in compliance with the License."
1919+
, " You may obtain a copy of the License at"
1920+
, ""
1921+
, " http://www.apache.org/licenses/LICENSE-2.0"
1922+
, ""
1923+
, " Unless required by applicable law or agreed to in writing, software"
1924+
, " distributed under the License is distributed on an \"AS IS\" BASIS,"
1925+
, " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."
1926+
, " See the License for the specific language governing permissions and"
1927+
, " limitations under the License."
1928+
]

0 commit comments

Comments
 (0)