自12年到北京做程序員,貌似從未關心過項目中使用的“輪子”
涉及到了哪些開源協議
。版權保護方面,雖然相關法規尚有待完善,但在研發商用軟件過程中,作為軟件開發者還是很有必要了解一下,我們平時使用的開源組件/框架
都涉及到了哪些開源協議,以避免今后的法律風險。
現在市面上的開源協議至少有上百種,經過開源促進會(Open Source Initiative)
認可的開源協議也多達 70 多種。
這里標題叫常見開源協議詳解,因此我們只介紹常見的6中開源協議。
- BSD(Berkeley Software Distribution license)
- MIT(Massachusetts Institute of Technology)
- Apache Licence 2.0
- GPL(General Public License)
- LGPL(Lesser General Public License)
- Mozilla(Mozilla Public License)
借用以下分析圖(該圖烏克蘭程序員PaulBagwell原創,阮一峰翻譯
)展示一下常用的開源協議:
一、BSD (Berkeley Software Distribution license)
BSD源自加州大學伯克利分校,是自由軟件中使用最廣泛的許可協議之一,其給於使用者很大自由的協議。
使用者可以自由的使用、修改源代碼,也可以將修改后的代碼開源或閉源,甚至作為商業軟件再發布。前提是發布的源代碼、二進制可執行文件相關文檔中需包含BSD許可協議聲明,並且不能使用開源機構名字做產品的市場推廣
。
使用BSD前提條件:
當你發布使用了BSD協議的代碼,或以BSD協議代碼為基礎做二次開發時,需要滿足以下三個條件:
- 如果再發布的產品中包含源代碼,則在源代碼中必須帶有原來代碼中的BSD協議;
- 如果再發布的是二進制類庫/軟件,則需要在類庫/軟件的文檔和版權聲明中包含原來代碼中的BSD協議;
- 不可以使用開源代碼的作者/機構名字和原來產品的名字做市場推廣;
BSD 鼓勵代碼共享,但需要尊重代碼作者的著作權。
BSD允許使用者修改和重新發布代碼,也允許基於BSD代碼上開發商業軟件的發布和銷售,因此很多公司企業在選用開源產品的時候都首選BSD協議(因為遵循BSD協議的代碼完全可控,必要的時候可以修改或者二次開發)
。
BSD許可條款
Copyright (c) 1998, Regents of the University of California All rights reserved.
Copyright (c) 1998 著作權由加州大學董事會所有,著作權人保留一切權利。
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
在符合以下條件的情況下,允許用戶對源代碼和二進制文件進行使用和再散播,無論源代碼是否進行了修改:
1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
對於源碼的再散播,必須保留以上著作權聲明、此條件列表、以及下述的免責聲明.
2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
以二進制可執行文件的散播,必須將以上著作權聲明、此條件列表、以及下述的免責聲明,添加到文檔 以及/或 其他材料中.
3.Neither the name of the University of California, Berkeley nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
未事前獲取書面許可,不得使用加州大學伯克利分校或本軟件貢獻者之名稱,來為本軟件之派生物做任何表示支持、認可或推廣、促銷之行為。
this software is provided by the regents and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. in no event shall the regents and contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
免責聲明:
本軟件是由加州大學董事會及本軟件之貢獻者提供(本就如此),本軟件包裝不負任何明示或默示之擔保責任,包括但不限於就適售性以及特定目的的適用性為默示性擔保。加州大學董事會及本軟件之貢獻者,無論任何條件、無論成因或任何責任主義、無論此責任為因合約關系、無過失責任主義或因非違約之侵權(包括過失或其他原因等)而起,對於任何因使用本軟件包裝所產生的任何直接性、間接性、偶發性、特殊性、懲罰性或任何結果的損害(包括但不限於替代商品或勞務之購用、使用損失、資料損失、利益損失、業務中斷等等),不負任何責任,即在該種使用已獲事前告知可能會造成此類損害的情形下亦然。
二、MIT(Massachusetts Institute of Technology)
MIT源自麻省理工學院(Massachusetts Institute of Technology, MIT)
MIT是和BSD一樣寬范的許可協議,作者只想保留版權,而無任何其他了限制。
使用者只需在發布的源代碼、二進制可執行文件相關文檔中包含MIT許可協議聲明,便可自由的使用、修改源代碼、作為商業軟件再發布、甚至使用開源機構名字做產品的市場推廣
。
MIT許可條款
Copyright (C) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
the software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
三、Apache Licence 2.0
Apache Licence是一個由Apache軟件基金會
發布的自由軟件許可證,最初為Apache http服務器而撰寫。
該協議與BSD類似,同樣鼓勵代碼共享和尊重原作者的著作權,允許代碼修改、再發布。
Apache Licence也是對商業應用友好的許可,使用者也可以在需要的時候修改代碼來滿足需要並作為開源或商業產品發布/銷售
。
前提條件
需要滿足的條件與BSD類似:
- 需要給使用代碼的用戶拷貝一份Apache Licence
- 如果你修改了代碼,需要再被修改的文件中說明。
- 在延伸的代碼中(修改和有源代碼衍生的代碼中)需要帶有原來代碼中的協議,商標,專利聲明和其他原來作者規定需要包含的說明。
- 如果再發布的產品中包含一個Notice文件,則在Notice文件中需要帶有Apache Licence。你可以在Notice中增加自己的許可,但不可以表現為對Apache Licence構成更改。
你可以在Notice中增加自己的許可,但不可以表現為對Apache Licence構成更改。
如何引用Apache Licence 2.0條款
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
四、GPL(General Public License)
GPL許可證最初由自由軟件基金會(Free Software Foundation)
的理查德·斯托曼
為GNU項目所撰寫。
GPL是一個Copyleft許可證,其派生作品只能以相同的許可條款分發:
使用者在軟件開發中只要使用GPL協議的相關類庫與代碼,則該軟件亦必須采用GPL協議,既必須開源與免費。
我們很熟悉的Linux操作系統、GNU編譯器集合(GCC)就是采用了GPL。
GPL協議和BSD、MIT、Apache Licence等鼓勵代碼重用的許可很不一樣。GPL的出發點是代碼的開源/免費使用和引用/修改/衍生代碼的開源/免費使用,其不允許修改后和衍生的代碼做為閉源的商業軟件發布和銷售(只要使用GPL協議的相關類庫與代碼,則該軟件亦必須采用GPL協議,既必須開源與免費。)
。
這也就是為什么我們能免費使用各種版本的linux,包括商業公司的Linux、個人組織二次開發的Linux版本。
如何引用GPL條款
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
五、LGPL(Lesser General Public License)
LGPL原本被稱為GNU Library General Public License
,最初於1991年發布,為與GPLv2保持一致而采用2.0版的編號;
許可證的2.1版與1999年在修訂后發布,與此同時,它被重命名為GNU Lesser General Public License
,以顯示自由軟件基金會(Free Software Foundation)
認為並不是所有程序庫都應當采用該許可證的態度;
LGPL的第3版於2007年發布,它以在GPL第3版之上附加應用一系列許可的方式表現。
LGPL是GPL的一個主要為類庫使用設計的開源協議,與GPL要求任何使用/修改/衍生之GPL類庫的的軟件必須采用GPL協議不同。
LGPL允許商業軟件通過類庫引用方式使用LGPL類庫而不需要開源商業軟件的代碼
,這使得采用LGPL協議的開源代碼可以被商業軟件作為類庫引用並發布和銷售;但使用者如果修改了LGPL協議的代碼或衍生,則所有修改的代碼和衍生的代碼都必須采用LGPL協議
。
如何引用LGPL條款
Copyright (C) year name of author
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
六、Mozilla(Mozilla Public License)
Mozilla開源協議由Mozilla基金會
開發並維護。
該協議融合了BSD許可與GNU通用公共許可協議的特性,追求平衡專有軟件和開源軟件開發者之間的顧慮(平衡開發者對源代碼的需求和他們利用源代碼獲得的利益
)。
Mozilla允許使用者在自己已有的源代碼庫上加一個接口,除了對接Mozilla Public License開源庫的接口程序源代碼以MPL許可的形式對外許可外,源代碼中的其他源碼可以不用MPL許可證的方式強制對外許可
。
使用BSD前提條件:
- 經MPL許可證發布的源代碼的修改也要以MPL許可證的方式再許可出來;
- 如果修改了代碼,需要有一個專門文件描述對源代碼程序的修改時間和修改方式;