See also Ruby

Homebrew

Homebrew 是一个 Mac OS X 下的软件包管理工具。既然已经有了MacPorts 和 Fink,那么为什么还要制造新的轮子呢?

1. Homebrew的安装、卸载与更新

Refer to https://github.com/mxcl/homebrew/wiki/Installation

1.1. Requirements

1.2. Install

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
Password:
==> Downloading and installing Homebrew...
remote: Counting objects: 202201, done.
remote: Compressing objects: 100% (54549/54549), done.
remote: Total 202201 (delta 146509), reused 202141 (delta 146467)
Receiving objects: 100% (202201/202201), 42.19 MiB | 31.00 KiB/s, done.
Resolving deltas: 100% (146509/146509), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
HEAD is now at 0049b1a mercurial: update 3.1.2 bottle.
==> Installation successful!
==> Next steps
Run `brew doctor` before you install anything
Run `brew help` to get started

1.3. Uninstall

rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup

Before Install Available check is : 33,455M,after is 33,415M

/usr/local size from 22M to 50M

1.4. Update

Fetch the newest version of Homebrew from GitHub using git

brew --version
0.9.4

brew update
Updated Homebrew from 32723234 to 32726535.

brew --version
0.9.5

2. Homebrew的使用

2.1. System Structure

ll /usr/local/
Cellar/         # download pkg, can hold multiple version
Library/        #
├── Aliases     #
├── ENV/        # xcode compile tools
├── Formula/    # pkg install config, such as nginx.rb
bin/            # commands
etc/            # configurations
opt/            # current version: mysql@ -> ../Cellar/mysql/5.6.10

2.2. 软件管理

2.2.1. 查看已经安装的软件(list)

brew list

2.2.2. 搜索需要的软件并安装(search&install)

$ brew search rar
gnu-scientific-library     unrar
$ brew install unrar

2.3. Problem Solve

http://stackoverflow.com/questions/12757694/brew-install-maven-404-error

## error info
curl: (56) Recv failure: Operation timed out
Error: Download failed: https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz

brew edit gd
#  url 'https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz'
  url 'http://fossies.org/linux/www/libgd-2.1.0.tar.gz'
brew install gd

2.4. Check Status

$ brew doctor
Warning: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.

Install Command Line Tools in Xcode

brew doctor
Your system is raring to brew.

3. Skills on Homebrew

3.1. brew help

##  --build-from-source
man brew  # user menu
brew install NAME  # install software by name
brew doctor        #Troubleshooting

3.2. USING HOMEBREW BEHIND A PROXY

http_proxy=http://<host>:<port> brew install foo
http_proxy=http://<user>:<password>@<host>:<port> brew install foo
ALL_PROXY=socks5://<user>:<password>@<host>:<port> brew install foo

3.3. python homebrew by default

http://stackoverflow.com/questions/5157678/python-homebrew-by-default

brew link --overwrite python

3.4. nginx config

Change Compile info:

#vi /usr/local/Library/Formula/nginx.rb brew edit nginx

  def install                                
    args = ["--prefix=#{prefix}",            
            "--with-http_ssl_module",        
            "--with-pcre",                   
            "--with-ipv6",                   
            "--with-http_stub_status_module", # add here

sudo nginx -s stop
brew uninstall nginx
brew install nginx
sudo nginx
curl http://localhost/status

Nginx Config:

user  liyan admin;

make auto run service

cp /usr/local/Cellar/nginx/1.2.7/homebrew.mxcl.nginx.plist /srv/www/moin/etc/
# vi .plist and remove user info
# To have launchd start nginx at login with root right(port at 80):
ln -sfv /srv/www/moin/etc/homebrew.mxcl.nginx.plist /System/Library/LaunchDaemons/homebrew.mxcl.nginx.plist
# Load nginx manually:
sudo launchctl load /System/Library/LaunchDaemons/homebrew.mxcl.nginx.plist

3.5. Local Formulas

3.5.1. sshpass(black list)

➜  ~  brew install /srv/www/moin/wiki/datas/main/pages/Homebrew/attachments/sshpass.rb
➜  attachments  brew install /srv/www/moin/wiki/datas/main/pages/Homebrew/attachments/sshpass.rb
==> Downloading http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/ss
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/sshpass/1.05
==> make
==> make install
🍺  /usr/local/Cellar/sshpass/1.05: 8 files, 60K, built in 10 seconds

3.5.2. rsync(duplicated)

➜  ~  brew info /srv/www/moin/wiki/datas/main/pages/Homebrew/attachments/rsync.rb
rsync: stable 3.1.1
https://rsync.samba.org/
Not installed
fatal: Not a git repository (or any of the parent directories): .git
From: https://github.com//homebrew/blob/master/../../srv/www/moin/wiki/datas/main/pages/Homebrew/attachments/rsync.rb
==> Dependencies
Build: autoconf ✔
➜  ~  brew install /srv/www/moin/wiki/datas/main/pages/Homebrew/attachments/rsync.rb 

➜  ~  brew cask info /srv/www/moin/wiki/datas/main/pages/Homebrew/attachments/menumeters.rb
menumeters: latest
http://www.ragingmenace.com/software/menumeters/
/opt/homebrew-cask/Caskroom/menumeters/latest (89 files, 2.5M)
https://github.com/caskroom/homebrew-cask/blob/master/Casks/menumeters.rb
==> Contents
  MenuMeters Installer.app/Contents/Resources/MenuMeters.prefPane (prefpane)

4. Homebrew Cask

Homebrew Cask是Homebrew的一个扩展,用来安装OS X应用。目前应用早已经过千了,据说更新速度也很不错。

4.1. Get Cask

# just on cmd: brew install caskroom/cask/brew-cask
➜  ~  brew install caskroom/cask/brew-cask
Cloning into '/usr/local/Library/Taps/caskroom/homebrew-cask'...
remote: Counting objects: 77163, done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 77163 (delta 84), reused 106 (delta 67)
Receiving objects: 100% (77163/77163), 22.15 MiB | 43.00 KiB/s, done.
Resolving deltas: 100% (50083/50083), done.
Checking connectivity... done.
Tapped 1 formula
==> Cloning https://github.com/caskroom/homebrew-cask.git
Cloning into '/Library/Caches/Homebrew/brew-cask--git'...
remote: Counting objects: 2272, done.
remote: Compressing objects: 100% (2221/2221), done.
remote: Total 2272 (delta 55), reused 334 (delta 39)
Receiving objects: 100% (2272/2272), 5.15 MiB | 48.00 KiB/s, done.
Resolving deltas: 100% (55/55), done.
Checking connectivity... done.
Note: checking out '096a13ed738cff431e39414bd33420a32f885ff4'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

==> Checking out tag v0.44.0
🍺  /usr/local/Cellar/brew-cask/0.44.0: 2055 files, 8.1M, built in 2.3 minutes

4.2. upgrade

brew upgrade caskroom/cask/brew-cask
brew cask -version

brew cask home: open homepage

4.3. 常用命令

与brew一致: https://github.com/caskroom/homebrew-cask/blob/master/USAGE.md

# 列出所有可以被安装的软件
brew cask search <name>
brew cask info <name>
brew cask uninstall <name>

4.4. 常用软件列表

brew cask install alfred\
virtualbox java menumeters tunnelblick\
firefox google-chrome \
evernote xmind mou sublime-text
the-unarchiver sogouinput \
rtx qq wechat \
thunder mplayerx adobe-photoshop-lightroom xee\

5. Reference


CategorymacOS CategoryTool

MainWiki: Homebrew (last edited 2014-10-11 18:03:45 by twotwo)