2012年6月14日木曜日

LionにHomebrew入れてec2-api-toolsを動かす

本業が営業なので最新技術は追いつつもあまりコマンドラインは触らない(好きだけど)のでMacにはPortsが入っていたが、同僚から「今時はHomebrew、Portsはありえない」ような話を聞いて、んじゃ入れなおしてみるかと。
$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew
/master/Library/Contributions/install_homebrew.rb)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...

Press enter to continue
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local
==> Downloading and Installing Homebrew...
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help

む、brew doctor とな。
$ brew doctor
Error: You have no /usr/bin/cc.
This means you probably can't build *anything*. You need to install the Command
Line Tools for Xcode. You can either download this from http://connect.apple.com
or install them from inside Xcode's Download preferences. Homebrew does not
require all of Xcode! You only need the Command Line Tools package!
Error: Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
  brew install git
Error: Your Xcode is configured with an invalid path.
You should change it to the correct path. Please note that there is no correct
path at this time if you have *only* installed the Command Line Tools for Xcode.
If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of
these is (probably) what you want:

    sudo xcode-select -switch /Developer
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

DO NOT SET / OR EVERYTHING BREAKS!

どうやらいろいろ足らないようだ。 Xcode の Command Line Tools をAppleのサイトからインストール。 んでgitをinstall。
$ brew install git
==> Downloading http://git-core.googlecode.com/files/git-1.7.10.4.tar.gz
######################################################################## 100.0%
==> make prefix=/usr/local/Cellar/git/1.7.10.4 CC=/usr/bin/cc CFLAGS=-Os -w -pipe
   -march=native -Qunused-arguments LDF

==> Build Environment
CPU: dual-core 64-bit penryn
MacOS: 10.7.4-x86_64
Xcode: dunno
CC: /usr/bin/cc
CXX: /usr/bin/c++
LD: /usr/bin/cc
CFLAGS: -Os -w -pipe   -march=native -Qunused-arguments
CXXFLAGS: -Os -w -pipe   -march=native -Qunused-arguments
MAKEFLAGS: -j2
Error: Failed executing: make prefix=/usr/local/Cellar/git/1.7.10.4 CC=/usr/bin
/cc CFLAGS=-Os\ -w\ -pipe\ \ \ -march=native\ -Qunused-arguments LDFLAGS= install
 (git.rb:49)
These existing issues may help you:
    https://github.com/mxcl/homebrew/issues/8643
    https://github.com/mxcl/homebrew/issues/9618
    https://github.com/mxcl/homebrew/issues/10544
    https://github.com/mxcl/homebrew/issues/11481
    https://github.com/mxcl/homebrew/issues/12325
    https://github.com/mxcl/homebrew/issues/12344
Otherwise, please report the bug:
    https://github.com/mxcl/homebrew/wiki/reporting-bugs

エラーがでてるけど、まぁいいや、あとでみるか。
ではec2-api-toolsを入れてみよう。
$ brew install ec2-api-tools
==> Downloading http://ec2-downloads.s3.amazonaws.com/ec2-api-tools-1.5.2.5.zip
######################################################################## 100.0%
==> Caveats
Before you can use these tools you must export some variables to your $SHELL
and download your X.509 certificate and private key from Amazon Web Services.

Your certificate and private key are available at:
http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key

Download two ".pem" files, one starting with `pk-`, and one starting with `cert-`.
You need to put both into a folder in your home directory, `~/.ec2`.

To export the needed variables, add them to your dotfiles.
 * On Bash, add them to `~/.bash_profile`.
 * On Zsh, add them to `~/.zprofile` instead.

export JAVA_HOME="$(/usr/libexec/java_home)"
export EC2_PRIVATE_KEY="$(/bin/ls "$HOME"/.ec2/pk-*.pem | /usr/bin/head -1)"
export EC2_CERT="$(/bin/ls "$HOME"/.ec2/cert-*.pem | /usr/bin/head -1)"
export EC2_HOME="/usr/local/Library/LinkedKegs/ec2-api-tools/jars"
==> Summary
/usr/local/Cellar/ec2-api-tools/1.5.2.5: 322 files, 15M, built in 41 seconds

うん、入ったな、どれどれ。
$ ec2ver
-bash: ec2ver: command not found

パスが通ってない、そりゃそうだ。ec2-api-toolsインストール時に表示されていた内容どおりに設定。 具体的には pk-***.pem と cert-***.pem を ~/.ec2 に配置して、/.bash_profileにバスを通す。
$ ec2ver
1.5.2.5 2012-03-01

動いた。これで rds-command-line-tools とか elb-tools も簡単に入るみたいなので便利な気がする。よしよし。

0 件のコメント:

コメントを投稿