MacPortsの代替になるパッケージ管理ソフトHomebrewを導入してみた
Homebrew — MacPorts driving you to drink? Try Homebrew!
VMの母艦として利用しているMac miniが素のままだとwgetやrsync3系(SnowLeopardに搭載されているrsyncは2.6.9)などのunix系コマンドや最新のバージョンなど利用できないものがあり、不便なことが多いので、シャレオツプログラマが利用しているというHomebrewを利用してみました。
Homebrewとは
MacPortsの代替えになるパッケージ管理用のソフトで、CentOSのyum、debianのaptと同じような形で利用でき、/usr/local/Cellarの下に各種ソフトがインストールされ、もともとpathの通っている、/usr/local/binの下にシンボリックリンクが張られるようです。
Rubyで記述されたこのプログラムは、/usr/local以下の領域を使用、インストールされるコマンドも「brew」のみ。しかも、Snow Leopardデフォルトのコマンドサーチパス(/usr/libexec/path_helper)に登録された/usr/local/binへインストールされるので、「brew search ***」としてサーバにあるパッケージを検索し、「brew install ***」としてインストールすればOK。スリムな状態で利用できる、Yet Anotherなパッケージ環境なのだ。
FinkでもMacPortsでもないパッケージ環境「Homebrew」 – builder by ZDNet Japan
導入の手順
導入環境はMacmini(2009 Late)でOSX(10.6) Snow Leopardです。Homebrewの導入にはXcodeが必須なので、あらかじめ
Xcode – Developer Tools Technology Overview – Apple Developer
からダウンロードして用意しておきましょう。(Xcodeの導入手順は省きます)
インストールは公式ページのインストール方法に従い、下記コマンドを一般ユーザで実行するだけ。
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)" |
実際に導入した際のログ
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)" ==> This script will install: /usr/local/bin/brew /usr/local/Library/Formula/... /usr/local/Library/Homebrew/... ==> The following directories will be made group writable: /usr/local/. /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/lib/pkgconfig /usr/local/sbin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man8 /usr/local/share/doc ==> The following directories will have their group set to staff: /usr/local/. /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/lib/pkgconfig /usr/local/sbin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man8 /usr/local/share/doc Press enter to continue ==> /usr/bin/sudo /bin/chmod g+w /usr/local/. /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/lib/pkgconfig /usr/local/sbin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man8 /usr/local/share/doc Password: ==> /usr/bin/sudo /usr/bin/chgrp staff /usr/local/. /usr/local/bin /usr/local/etc /usr/local/lib /usr/local/lib/pkgconfig /usr/local/sbin /usr/local/share /usr/local/share/man /usr/local/share/man/man1 /usr/local/share/man/man5 /usr/local/share/man/man8 /usr/local/share/doc ==> Downloading and Installing Homebrew... ==> Installation successful! |
途中でsudoのパスワード入力を求められるので、入力するとインストール完了。楽ですし、早いです。
とりあえずwgetをインストールしてみる。
$ brew install wget ==> Downloading http://ftp.gnu.org/gnu/wget/wget-1.12.tar.bz2 ######################################################################## 100.0% ==> Downloading patches ######################################################################## 100.0% ==> Patching patching file src/openssl.c ==> ./configure --disable-debug --prefix=/usr/local/Cellar/wget/1.12 --disable-iri ==> make install /usr/local/Cellar/wget/1.12: 9 files, 776K, built in 37 seconds |
rsyncも2系なので、3系を導入。
brew install rsync |
欲しいパッケージがない場合は、レシピを自分で作成し
/usr/local/Library/Formula |
に配置すると利用ができるようです。まだ自作のレシピは試したことはないですが、各種rubyで書かれたレシピがあるので真似して書けばいけそうな感じです。
各種オプションは下記のようになっています。
Usage: brew [-v|--version] [--prefix [formula]] [--cache [formula]]
[--cellar [formula]] [--config] [--env] [--repository]
[-h|--help] COMMAND [formula] ...
Principal Commands:
install formula ... [--ignore-dependencies] [--HEAD]
list [--unbrewed|--versions] [formula] ...
search [/regex/] [substring]
uninstall formula ...
update
Other Commands:
info formula [--github]
options formula
deps formula
uses formula [--installed]
home formula ...
cleanup [formula]
link formula ...
unlink formula ...
outdated
missing
prune
doctor
Informational:
--version
--config
--prefix [formula]
--cache [formula]
Commands useful when contributing:
create URL
edit [formula]
audit [formula]
log formula
install formula [-vd|-i]
For more information:
man brew
To visit the Homebrew homepage type:
brew home |
Homebrew超便利です。さらばMacPorts
参考サイト
mac ports やめました! ー homebrew で快適 OSX 生活! – TokuLog 改メ tokuhirom’s blog

