hogehoge foobar Blog Style Beta

Web,Mac,Linux,JavaScript,Perl,PHP,RegExp,Git,Vim,Redmineなど技術的なことのメモや、ちょっと便利そうなものの紹介をしています。

MacPorts から Homebrew へ移行(OS X 10.7.5)

とってもお久しぶりのエントリ。

いまさら感が満載ですが、MacPorts から Homebrew へ変更してみました。

そのときのメモ書きです。

MacPorts のアンインストール

Homebrew をインストールするには、MacPorts はゴッソリ消したほうがいいみたいなので、公式のマニュアルに従ってアンインストールします。

MacPorts のパス確認

念のため、事前に確認しておきます。

$ which port
/opt/local/bin/port

MacPorts でインストールしたパッケージリストの取得

MacPorts をアンインストールするにはパッケージも全部消すことになるので、消す前にインストール済みのリストを取っておきます。

$ port installed > macpots_installed.txt

MacPorts でインストールしたパッケージを全部消す

MacPorts でインストールしたパッケージを全部消します。

$ sudo port -fp uninstall installed

消し終わったあとに、本当に全部消えたか確認します。

$ port installed
No ports are installed.

MacPorts 本体をアンインストール

MacPorts 公式サイト)に掲載されているコマンドをコピペして、MacPorts 本体を消す。

$ sudo rm -rf \
>     /opt/local \
>     /Applications/DarwinPorts \
>     /Applications/MacPortss \
>     /Library/LaunchDaemons/org.macports.* \
>     /Library/Receipts/DarwinPorts*.pkg \
>     /Library/Receipts/MacPortss*.pkg \
>     /Library/StartupItems/DarwinPortsStartup \
>     /Library/Tcl/darwinports1.0 \
>     /Library/Tcl/macports1.0 \
>     ~/.macports

「 which port 」して、コマンドが消えたことを確認。

$ which port
$ 

これで、MacPorts のアンインストールは完了です。

Homebrew のインストール

次に、本題の Homebrew をインストールします。

ruby のバージョンとか確認

Homebrew をインストールするには ruby が必要なので、一応チェック。 (Mac は標準でrubyがインストールされているので、基本はそのままインストールできるるハズです。)

$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]

一応、インストールされているパスも確認しておく。 (私のは、ずっと昔に rvm で使ってインストールしてたので、長いパスになってます。)

$ which ruby
/Users/user/.rvm/rubies/ruby-1.9.2-p180/bin/ruby

Homebrew をインストール

Homebrew 公式サイトにある、インストール用のコマンドをコピペして実行します。

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
==> This script will install:
/usr/local/bin/brew

・・・ 途中省略 ・・・・

Warning: Install the "Command Line Tools for Xcode": http://connect.apple.com
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help

インストールされたかを確認。

$ which brew
/usr/local/bin/brew

バージョンも確認しておく。

$ brew -v
Homebrew 0.9.4

これで、Homebrew のインストールは完了です。

Homebrew の簡単な使い方

最後に、簡単な使い方を覚えるために、Homebrew を使って nginx をインストールしてみます。

nginx のパッケージがあるか確認

brew」コマンドに「search」オプションで、インストール可能なパッケージを探せます。

$ brew search nginx
nginx

nginx のインストールオプションを確認

インストールする前に、「brew options」でインストールオプションを確認しておきます。

$ brew options nginx
--with-debug
    Compile with support for debug log
--with-passenger
    Compile with support for Phusion Passenger module
--with-webdav
    Compile with support for WebDAV module

nginx をインストール

brew install」で、パッケージ名を指定して nginx をインストールします。 (このときは、Xcode4.2 のままだったので、Xcode4.6 にバージョンアップしろという警告がでました。)

$ brew install nginx
Warning: Your Xcode (4.2.1) is outdated
Please install Xcode 4.6.

Homebrew でインストールされたパッケージ一覧

インストールされたパッケージ一覧をみるには、「brew list」を使います。 さっきインストールした、nginx があるのがわかります。

$ brew list
nginx   pcre

nginx をアンインストール

パッケージをアンインストールするには、「brew remove」を使います。

$ brew remove nginx
Uninstalling /usr/local/Cellar/nginx/1.2.6...

簡単な使い方としては、こんな感じです。

今回の参考サイト