2013-07-05

MacPortsの後継としてHomebrewを導入してさらにgettextをインストール

ディスクの空きを増やしたくてMacPortsをアンインストールした。wineとか入れててやたらと重かったし、依存関係でごちゃごちゃしすぎてわけが分からなくなったので全部消してやった。でも、そしたらGNUのgettextが動かない。当たり前か。

Djangoで多言語対応をするためにはGNUのgettextが必要だ。そこで、MacPortsの代わりにHomebrewをインストールすることにした。MacPortsもHomebrew、パッケージ管理システムだが、Homebrewの方はMacにもともと入っているパッケージをなるべくつかうようにしているため、ビルドの時間やディスクの容量を節約できるという噂だ。

インストールのためには、Xcodeがインストールされていることが前提らしい。昔っからXcodeは入っているのでこれは問題なし。
あとは、ターミナルで
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
と打ち込む。途中でパスワードを聞かれたから教えてあげた。
次のような出力があった。
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
/usr/local/share
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin
/usr/local/share

Press ENTER to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/share
Password:
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin /usr/local/share
==> Downloading and Installing Homebrew...
remote: Counting objects: 119077, done.
remote: Compressing objects: 100% (57206/57206), done.
remote: Total 119077 (delta 83061), reused 94319 (delta 60911)
Receiving objects: 100% (119077/119077), 18.97 MiB | 326 KiB/s, done.
Resolving deltas: 100% (83061/83061), done.
From https://github.com/mxcl/homebrew
* [new branch] master -> origin/master
HEAD is now at 4c74e09 fish: don't search extra folders for libiconv
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help

最初に、ターミナルで「$ brew doctor」を実行しろって書いてある。やってみると次のような警告が出た。
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
[省略]
Consider amending your PATH so that /usr/local/bin
occurs before /usr/bin in your PATH.
Homebrewもシステムと重複するプログラムとインストールすることもあるってことかな。とりあえず放ったらかし。

肝心なのは、gettextを入れること。インストールは「$ brew install なんちゃら」でいける。
$ brew install gettext
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gettext-0.18.2.lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gettext-0.18.2.lion.bottle.tar.gz
==> Caveats
This formula is keg-only: so it was not symlinked into /usr/local.

OS X provides the BSD gettext library and some software gets confused if both are in the library path.

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/gettext/lib
CPPFLAGS: -I/usr/local/opt/gettext/include

==> Summary
🍺 /usr/local/Cellar/gettext/0.18.2: 366 files, 11M

これでGNU gettextがインストールできた。しかし、「which gettext」とやっても何もでてこない。パスが通ってないからだ。
インストールのときの出力を見ると、OS XのBSD gettextと競合するかもしれないっていう配慮でパスを通していないようだ。こんな情報も見つけた。https://github.com/mxcl/homebrew/issues/8461

パスを通すには、「$ brew link --force gettext」とやる。いまは「--force」を忘れちゃダメみたい。

0 件のコメント: