文章作者:Tyan
博客:noahsnail.com ?|? CSDN ?|? 簡書
1. 簡介
Homebrew是Mac OSX上的軟件包管理工具秧骑,能在Mac中方便的安裝軟件或者卸載軟件爽室,相當(dāng)于linux下的apt-get、yum监透;Homebre可以在Mac上安裝一些OS X沒有的UNIX工具,Homebrew安裝工具的目錄為/usr/local/Cellar目养,并在/usr/local/bin中創(chuàng)建了工具對應(yīng)的符號鏈接煮仇。例如Homebrew安裝的cmake:
# lrwxr-xr-x中的l表示link(鏈接),->表示鏈接的文件
$ ls -l /usr/local/bin/cmake
lrwxr-xr-x 1 *** *** 31 12 1 09:23 /usr/local/bin/cmake -> ../Cellar/cmake/3.7.0/bin/cmake
2. 安裝
Home是通過Ruby安裝的,而Mac上默認安裝了Ruby召夹。Homebrew的安裝命令為:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3. Homebrew用法
- 安裝軟件
# 命令形式: brew install software-name
# 安裝wget
$ brew install wget
==> Installing dependencies for wget: openssl
==> Installing wget dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
==> Summary
?? /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.18.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wget-1.18.el_capitan.bottle.tar.gz
?? /usr/local/Cellar/wget/1.18: 9 files, 1.6M
- 卸載軟件
# 命令形式: brew uninstall software-name
# 卸載wget
$ brew uninstall wget
Uninstalling /usr/local/Cellar/wget/1.18... (9 files, 1.6M)
- 查看安裝的軟件
# 命令形式: brew list
$ brew list
cmake maven node openssl pkg-config wget xz
- 查看哪些軟件需要更新
# 命令形式:brew outdated
$ brew outdated
node (6.5.0) < 7.2.0
pkg-config (0.29.1_1) < 0.29.1_2
- 更新Homebrew
# 命令形式:brew update
$ brew update
Already up-to-date.
- 顯示brew信息
# 命令形式:brew info
$ brew info
7 kegs, 7,868 files, 95.5M
- 軟件升級
# 命令形式:brew upgrade software-name
$ brew upgrade pkg-config
==> Upgrading 1 outdated package, with result:
pkg-config 0.29.1_2
==> Upgrading pkg-config
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.29.1_2.el_capitan.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/pkg-config
Target /usr/local/bin/pkg-config
is a symlink belonging to pkg-config. You can unlink it:
brew unlink pkg-config
To force the link and overwrite all conflicting files:
brew link --overwrite pkg-config
To list all files that would be deleted:
brew link --overwrite --dry-run pkg-config
Possible conflicting files are:
/usr/local/bin/pkg-config -> /usr/local/Cellar/pkg-config/0.29.1_1/bin/pkg-config
/usr/local/share/aclocal/pkg.m4 -> /usr/local/Cellar/pkg-config/0.29.1_1/share/aclocal/pkg.m4
/usr/local/share/doc/pkg-config/pkg-config-guide.html
/usr/local/share/doc/pkg-config/pkg-config-guide.html
/usr/local/share/man/man1/pkg-config.1 -> /usr/local/Cellar/pkg-config/0.29.1_1/share/man/man1/pkg-config.1
==> Summary
?? /usr/local/Cellar/pkg-config/0.29.1_2: 10 files, 627.4K
$ brew link --overwrite pkg-config
- 搜索軟件
# 命令形式:brew search software-name
$ brew search wget
wget ? wgetpaste