聊聊 Apache 開源協議

jopen 9年前發布 | 9K 次閱讀 Apache

摘要

本文原創,轉載請注明地址: http://kymjs.com/manager/2015/11/21/01

用一句話概括 Apache License 就是,你可以用這代碼,但是如果開源你必須保留我寫的聲明;你可以改我的代碼,但是如果開源你必須寫清楚你改了哪些;你可以加新的協議要求,但不能與我所 公布的協議要求產生沖突;你用這代碼干什么我不管,但是你不能讓我承擔任何責任。

  • 事出有因
  • 開源協議
  • Apache License
  • 一句話

事出有因

前些天有朋友提醒我,KJFrameForAndroid中的DB模塊使用的是基于afinal的finalDB模塊確沒有在代碼中給出聲明。對 此我很抱歉,已經立即加上了。其實在舊版本的時候我是保留了對finalDB的引用聲明和作者信息,后來經過一次重構后卻忘記補上了。

開源協議

現在開源社區常用的開源協議有 MIT LicenseGPLApache License 。但是想必大家都沒有完整的看過開源協議內容吧,其實之前我自己也沒有看過,畢竟全英文又不是什么技術文檔,誰去看那東西。

不過沒關系,花了一個多星期,我已經把Apache License翻譯了一遍,大家可以看 這里 ,其他的一些主流開源協議也將陸續翻譯出來。

今天,咱們就來聊聊開源協議。

首先,作為程序員,我們肯定都知道,Android系統是開源的。但是是基于什么協議開源你知道嗎?Android內核是Linux內核,使用了 GPL代碼,而GPL代碼規定所有使用了GPL代碼的代碼,必須開源。但是,你知道嗎,Android中真正使用了GPL代碼的部分非常少,僅僅是一個 Linux Kernel,也就是只有一個內核(當然,這并不是說不重要)。

這就是說,與傳統Linux發行版相比,只有系統的底層結構是一樣的,其他東西在Android里都不一樣,尤其是程序員的編程接口是完全不同的。因此,Android應用程序都必須重新寫過,現存的Linux程序無法移植上去。

那么,Android只采用kernel、而不是完全采用GPL開源應用,到底是什么?臺灣的科技網志MMDays一語道破真相:

“Linux kernel 的版權是 GPL。 這下問題來了:如果你是硬件廠商,希望你的硬件能在 Linux kernel 下運作,那么就必須要有驅動程序。如果驅動程序的程序代碼公開,等于硬件規格也公開的差不多了。許多廠商不愿意這么做,所以就提供編好的驅動程序,但不提 供原始碼。 Android 的重點就是商業應用,Google采用了一些手法來繞過這問題。他們把驅動程序移到 “userspace”,也就是說,把驅動程序變成在 Linux kernel 上頭跑,而不是一起跑的東西,這樣就可以避過GPL。然后,在 kernel 這邊開個小門,讓本來不能直接控制到硬件的 “userspace” 程序也可以碰得到,這樣只要把”開個小門”的程序代碼公布就行啦。”

這就又說回了我們今天的問題:開源協議有什么不同。

關于這個問題,網上有一張很著名的圖,相信大家都看過 聊聊 Apache 開源協議

Apache License

再來說回Apache協議,上文可以看出Android選擇了Apache協議開源,就是因為Apache協議允許使用了本協議開源的代碼不必開源。這一點,我們可以看協議的第四條:

(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and

(d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.

意思也就是說,如果你用了Apache協議的開源代碼,必須保留協議文本。你可以修改源碼,但必須聲明你修改了哪些,并且保留原開源項目中原作者的信息。

以及第五條:

Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.

除非貢獻提交者明確聲明,否則任何被合并到項目中的代碼,認為在無任何附加條款下符合本許可證的條款。盡管有上述規定,在遵循許可證頒發者的聲明的前提下,你也可以添加附加條款。

一句話

最后,用一句話概括 Apache License 就是,你可以用這代碼,但是如果開源你必須保留我寫的聲明;你可以改我的代碼,但是如果開源你必須寫清楚你改了哪些;你可以加新的協議要求,但不能與我所公布的協議要求產生沖突;你用這代碼干什么我不管,但是你不能讓我承擔任何責任。

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!