包管理器是神馬東西?讓我們看看wikipedia上的介紹。
In software, a package management system, also called package manager, is a collection of software tools to automate the process of installing, upgrading, configuring, and removing software packages for a computer’s operating system in a consistent manner.
簡單的來說,包管理器就是一個提供對一系列軟件包的安裝、卸載、升級的自動化工具。 包管理器大體分為兩種,一種是管理預編譯好的軟件(Binary installation/Precomplied packages),如MAC上的App Store,Windows下的Windows installer。另一種是基于源碼的安裝包,通過編譯腳本來安裝軟件(Sourcecode-based installation/installing using compile scripts),如MAC上的Homebrew,Linux上的apt-build。
今天就給大家講解下Homebrew。
Homebrew官網上稱自己為:
The missing package manager for OS X
即自己彌補了在OS X上無包管理器的缺陷。
需求環境
安裝Homebrew
只需要在terminal下敲這樣一行代碼就行。
1
|
|
brew會被默認安裝到/usr/local文件夾中。從上述命令可以看出homebrew是基于ruby的一款包管理器,并且host在github上。
使用
在Homebrew中支持安裝的軟件被稱為Formula。
查看所有支持的Formual。可以在這里查看。如果不能上網的話可以通過
brew server
來在本地開啟一個server來查看。brew search [Formula]
, 搜索某個Formula是否被支持。brew install [Formula]
, 安裝某個Formula。brew upgrade [Formula]
, 升級某個Formula。brew uninstall [Formula]
, 刪除某個Formula。brew update
, 更新brew支持的Formula列表。
所有的軟件都會默認被安裝到/usr/local/Cellar
目錄下,然后將部分可執行腳本文件通過軟鏈接鏈接到/usr/local\bin
目錄下,這樣我們就可以在Terminal下使用這些軟件。
Homebrew對于Formula的管理是基于git的。你可以在/usr/local/
下發現有一個.git
的文件夾。通過查看.git
目錄下的config
文件,可以知道其實目錄是被鏈接到github上的一個repository。
1 2 3 4 5 6 7 8 9 10 |
|
你也可以為自己的軟件加入到Homebrew的支持列表中。只需要寫一個ruby腳本check in到其github中。 下面是一個腳本示例。
1 2 3 4 5 6 7 8 9 10 11 12 |
|
文章列表