Open-Source Project Directory Structure
專案資料夾架構
基本檔案
- LICENSE
- Open Source Licenses | Open Source Initiative
- 簡易 License 的選擇方法 (自由软件和开源协议)
- Makefile
- README.md
- CHANGELOG.md
- TODO.md
- INSTALL
- .gitignore (GitHub useful .gitignore templates)
主程式
- src/
- core/ 與 plugins/ 搭配
- bin/ 通常與 lib/ 或 src/ 搭配,如 python, ruby 的主程式可以去掉副檔名,放在 bin/ 中
- bin/python/ 若有不同語言的實做,可建立不同語言的子資料夾
- bin/java/
編譯所需標頭檔、函式庫
Plugins
Build Source 主程式與輔助工具
Build package
- debian/
- rpm/
- https://github.com/threatstream/snort/tree/master/rpm
- opensuse/
- osx/
- msi/
- system/ 將 package 相關工具放在一起 (但這個命名較少見)
- packages/
- startup/
- tildeslash / Monit / source / system — Bitbucket
Release 版本
- dist/
- https://github.com/ducksboard/gridster.js/tree/master/dist
- release/
- https://github.com/CSSLint/csslint/tree/master/release
Patches
測試
CI 設定檔
使用範例 (library 或 API 使用範例程式)
- examples/
- sample/
- https://github.com/ruby/ruby/tree/trunk/sample
- demos/
- https://github.com/CSSLint/csslint/tree/master/demos
設定檔範例
文件
部署指令稿
開發時的輔助工具,或是第三方貢獻者使用的輔助工具,但與主程式通常沒有直接關係
- contrib/
- nginx/contrib
- graphite-web/contrib
- 一些不同的意見:反對 contrib 資料夾
- Against "contrib" | Secret Weblog
貢獻
- AUTHORS
- AUTHORS.md
- mapnik/AUTHORS.md
- ql.io/AUTHORS.md
- CONTRIBUTORS.md (YUI 建立了另一種 Contributor Model)
- CONTRIBUTING.md (如何加入專案的說明文件)
Makefile 常見選項
all
install
install-html
install-dvi
install-pdf
install-ps
uninstall
install-strip
clean
distclean
mostlyclean
maintainer-clean
TAGS
info
dvi
html
pdf
ps
dist
check
installcheck
installdirs
常見安裝系統路徑
Filesystem Hierarchy Standard (FHS)
/
- /bin Essential user command binaries (for use by all users) 所有使用者使用的基本工具 (buzybox 工具等)
- /etc Host-specific system configuration 系統服務與程式的主要設定檔位置
- /lib Essential shared libraries and kernel modules 動態連結檔共用函式庫位置
- /opt Add-on application software packages 程式獨立維護的安裝位置 /google、/teamviewer9
- /sbin System binaries 系統管理使用的工具
- /usr the second major section of the filesystem. 應用程式共用的表頭檔 (.h)、文件 (man) 或是不同版本的函式庫 (lib、local/lib) 等
- /var variable data files 可儲存、可變動的程式資料檔
/usr
- /usr/bin
- /usr/include (*.h)
- /usr/lib (*.so)
- /usr/local
- /usr/local/bin (ex : /usr/local/bin/virtualenv-2.7)
- /usr/local/lib (ex : /usr/local/lib/python2.7/)
- /usr/sbin (ex : /usr/sbin/visudo)
- /usr/share (ex : /usr/share/applications)
- /usr/src (ex : /usr/src/linux-headers-$(uname -r)/include)
/var
- /var/cache (ex: /var/cache/apt/)
- /var/log (ex: /var/log/syslog)
- /var/run (ex: /var/run/apache2/apache2.pid)
語言範例
C / C++
linux-test-project/ltp https://github.com/linux-test-project/ltp
mongodb/mongo https://github.com/mongodb/mongo
openssl/openssl https://github.com/openssl/openssl
antirez/redis https://github.com/antirez/redis
C#
nunit/nunit https://github.com/nunit/nunit
Go
docker/docker https://github.com/docker/docker
Python
- setup.py (python setup.py install)
- requirements.txt (pip install -r requirements.txt)
- MANIFEST.in
- bin/
- libxxx/
mattharrison/poachplate https://github.com/mattharrison/poachplate
版本號
N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN]
PEP 386 - Changing the version comparison module in Distutils | Python.org
twisted/twisted https://github.com/twisted/twisted
django/django https://github.com/django/django/tree/master/django
qtile/qtile https://github.com/qtile/qtile
Open Sourcing a Python Project the Right Way
Interesting Things, Largely Python and Twisted Related: Filesystem structure of a Python project
6. Modules — Python 2.7.9 documentation
Packaging Your Code — The Hitchhiker’s Guide to Python
PyPI
Python project layout
PyCon 2013 : Scripting to PyPi to GitHub and More (p28)
JAVA
jenkinsci/jenkins https://github.com/jenkinsci/jenkins
JAVA - Maven
Maven – Introduction to the Standard Directory Layout
Ruby
- bin/
- install.rb
- Gemfile
- Rakefile
rails/rails https://github.com/rails/rails
opscode/chef https://github.com/opscode/chef
puppetlabs/puppet https://github.com/puppetlabs/puppet
Directory layout for pure Ruby project - Stack Overflow
Ruby on Rails
sass/sass https://github.com/sass/sass
JavaScript /
- .jshintrc
- .jshintignore
- Gruntfile.js
- bower.json
- package.json (npm install)
jquery/jquery https://github.com/jquery/jquery
What is the best directory structure for organizing an Open Source JavaScript project? - Quora
NodeJS
less/less.js https://github.com/less/less.js
strongloop/express https://github.com/strongloop/express
跨平臺程式
ruby/ruby
go
參考網站
Chapter 2: Project management and the GNU coding standards
Starting An Open-Source Project - Smashing Magazine
PyCon 2013 : Scripting to PyPi to GitHub and More