Brew—mac中类似apt-get的功能

ubuntu的apt-get实在是方便,需要安装什么,一个命令搞定,相关的依赖包统统由apt-get维护。而Mac中也有一种很牛的替代工具MacPorts

homebrew主页对brew进行了详细的描述(https://github.com/Homebrew/homebrew)

一、安装brew

curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1

然后开始安装
x share/doc/homebrew/brew-test-bot-for-core-contributors-tabs.png
x share/doc/homebrew/brew-test-bot-for-core-contributors-trigger.png
x share/doc/homebrew/brew-test-bot-passed-jenkins.png
x share/doc/homebrew/brew-test-bot-passed-pr.png
x share/doc/homebrew/brew-test-bot-triggered-pr.png
x share/man/
x share/man/man1/
x share/man/man1/brew.1

二、brew安装软件

以wget为例

brew install wget

开始安装了
==> Summary
🍺 /usr/local/Cellar/openssl/1.0.2d_1: 464 files, 18M
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.16.3.yosemite.bottle.tar.
######################################################################## 100.0%
==> Pouring wget-1.16.3.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/wget/1.16.3: 9 files, 1.5M

三、brew卸载软件

brew uninstall <软件名>
卸载之前,可以先用brew list 看一下通过brew安装的工具

四、brew检索软件

brew search /apache*/

五、brew编辑下载软件的内容

案例:sourceforge.net被墙了

报错:

sh-3.2# brew upgrade
==> Upgrading 6 outdated packages, with result:
libpng 1.5.12, imagemagick 6.7.7-6, libtiff 4.0.2, pcre 8.31, lighttpd 1.4.31, wget 1.14
==> Upgrading libpng
==> Downloading http://downloads.sf.net/project/libpng/libpng15/1.5.12/libpng-1.5.12.tar.gz

curl: (56) Recv failure: Connection reset by peer
Error: Download failed: http://downloads.sf.net/project/libpng/libpng15/1.5.12/libpng-1.5.12.tar.gz

解决方案:

brew edit libpng

require 'formula'

class Libpng < Formula
    homepage 'http://www.libpng.org/pub/png/libpng.html'
    #url 'http://downloads.sf.net/project/libpng/libpng15/1.5.12/libpng-1.5.12.tar.gz'
    url 'ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.12.tar.gz'
    sha1 'c329f3a9b720d7ae14e8205fa6e332236573704b'

    keg_only :provided_by_osx if MacOS::X11.installed?

    def install
        system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
        system "make install"
    end
end

很明显我用ftp.simplesystems.org替换了downloads.sf.net的文件地址。

接下来保存好内容,继续brew,成功!

tanqianshan[2.其他公司表型整理]$ brew install pdf2htmlEX
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.
Error: You must `brew link cmake’ before pdf2htmlex can be installed

解决办法:

brew unistall cmake
sudo brew install cmake

参考资料:

http://snowolf.iteye.com/blog/774312

http://community.itbbs.cn/thread/21327/

个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn

Sam avatar
About Sam
专注生物信息 专注转化医学