97 lines
2.9 KiB
Ruby
97 lines
2.9 KiB
Ruby
require "language/go"
|
|
|
|
class Packer < Formula
|
|
desc "Tool for creating identical machine images for multiple platforms"
|
|
homepage "https://packer.io"
|
|
url "https://github.com/mitchellh/packer.git",
|
|
:tag => "v0.12.0",
|
|
:revision => "e2fa87a402d9677257e2fbf1b4541b74db6abe63"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "640cff80db8cba94dcda6b6be8cb46ef160e48a78e21a5065688a426a999f53d" => :sierra
|
|
sha256 "13091ba841da46693e6426831ec19a8df457b2d3271011ac508b55d421da5bef" => :el_capitan
|
|
sha256 "fe07b24939e18adfb2da8c3077634abe32655a2631c1dd47fafa75055bab531e" => :yosemite
|
|
end
|
|
|
|
depends_on :hg => :build
|
|
depends_on "go" => :build
|
|
depends_on "govendor" => :build
|
|
|
|
go_resource "github.com/mitchellh/gox" do
|
|
url "https://github.com/mitchellh/gox.git",
|
|
:revision => "c9740af9c6574448fd48eb30a71f964014c7a837"
|
|
end
|
|
|
|
go_resource "github.com/mitchellh/iochan" do
|
|
url "https://github.com/mitchellh/iochan.git",
|
|
:revision => "87b45ffd0e9581375c491fef3d32130bb15c5bd7"
|
|
end
|
|
|
|
go_resource "golang.org/x/tools" do
|
|
url "https://go.googlesource.com/tools.git",
|
|
:revision => "c6efba04dd0d931bb11cd7f556285fa3c9305398"
|
|
end
|
|
|
|
def install
|
|
ENV["XC_OS"] = "darwin"
|
|
ENV["XC_ARCH"] = MacOS.prefer_64_bit? ? "amd64" : "386"
|
|
ENV["GOPATH"] = buildpath
|
|
# For the gox buildtool used by packer, which
|
|
# doesn't need to be installed permanently.
|
|
ENV.append_path "PATH", buildpath
|
|
|
|
packerpath = buildpath/"src/github.com/mitchellh/packer"
|
|
packerpath.install Dir["{*,.git}"]
|
|
Language::Go.stage_deps resources, buildpath/"src"
|
|
|
|
cd "src/github.com/mitchellh/gox" do
|
|
system "go", "build"
|
|
buildpath.install "gox"
|
|
end
|
|
|
|
cd "src/golang.org/x/tools/cmd/stringer" do
|
|
system "go", "build"
|
|
buildpath.install "stringer"
|
|
end
|
|
|
|
cd "src/github.com/mitchellh/packer" do
|
|
# We handle this step above. Don't repeat it.
|
|
inreplace "Makefile" do |s|
|
|
s.gsub! "go get github.com/mitchellh/gox", ""
|
|
s.gsub! "go get golang.org/x/tools/cmd/stringer", ""
|
|
s.gsub! "go get github.com/kardianos/govendor", ""
|
|
end
|
|
|
|
(buildpath/"bin").mkpath
|
|
system "make", "releasebin"
|
|
bin.install buildpath/"bin/packer"
|
|
zsh_completion.install "contrib/zsh-completion/_packer"
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
test do
|
|
minimal = testpath/"minimal.json"
|
|
minimal.write <<-EOS.undent
|
|
{
|
|
"builders": [{
|
|
"type": "amazon-ebs",
|
|
"region": "us-east-1",
|
|
"source_ami": "ami-59a4a230",
|
|
"instance_type": "m3.medium",
|
|
"ssh_username": "ubuntu",
|
|
"ami_name": "homebrew packer test {{timestamp}}"
|
|
}],
|
|
"provisioners": [{
|
|
"type": "shell",
|
|
"inline": [
|
|
"sleep 30",
|
|
"sudo apt-get update"
|
|
]
|
|
}]
|
|
}
|
|
EOS
|
|
system "#{bin}/packer", "validate", minimal
|
|
end
|
|
end
|