1. 程式人生 > >常見開源協議詳解

常見開源協議詳解

自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原創,阮一峰翻譯`)展示一下常用的開源協議: ![分析圖:烏克蘭程式設計師Paul Bagwell原創 阮一峰翻譯](https://upload-images.jianshu.io/upload_images/5969042-03a44f7484efc38f?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ### 一、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)