すずけんメモ

技術メモです

golangとPackerをソースからインストール

ついでにpackerもいれておく。

goがはいってないので、ひとまずhomebrewでいれる。

$ brew install go
==> Downloading https://go.googlecode.com/files/go1.1.src.tar.gz
######################################################################## 100.0%
==> ./make.bash --no-clean
==> Caveats
The go get command no longer allows $GOROOT as
the default destination in Go 1.1 when downloading package source.
To use the go get command, a valid $GOPATH is now required.

As a result of the previous change, the go get command will also fail
when $GOPATH and $GOROOT are set to the same value.

More information here: http://golang.org/doc/code.html#GOPATH

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/go/1.1: 3878 files, 109M, built in 59 seconds

ちなみにこうなってる。

$ ll /usr/local/bin/go
lrwxr-xr-x  1 user  staff  23  7 17 21:05 /usr/local/bin/go -> ../Cellar/go/1.1/bin/go

ここでGOPATHを設定する必要がある。以下を.bashrcなどに書く。

GOPATH=$HOME/work/packer
export GOPATH

packerのソースをcloneしてくる。

$ cd work
$ git clone https://github.com/mitchellh/packer.git

あとはmakeすれば使えるようになる。

$ cd packer
$ make
...
$ bin/packer
usage: packer [--version] [--help] <command> [<args>]

Available commands are:
    build        build image(s) from template
    fix          fixes templates from old versions of packer
    validate     check that a template is valid

とりあえず動作してるっぽい。$GOPATHの設定がwork/packerで良いのかどうかはよくわかってない。