91 lines
2.7 KiB
Ruby
91 lines
2.7 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/hashicorp/packer.git",
|
|
:tag => "v1.0.3",
|
|
:revision => "c0ddb4a044551f3c967ca36f612a33ce13e215f0"
|
|
head "https://github.com/hashicorp/packer.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "6b7dd6df7d2020553dba03db75f6c86395fa9fe602b92225447a8f0a3edc54d9" => :sierra
|
|
sha256 "af1f5afce107799415e68f4f0ab45201bb3527e9b14bc1cec14df3708679cc76" => :el_capitan
|
|
sha256 "71c62e8d113432c28072b106ed29db91d2510c35a5dd240c702565f54d53393d" => :yosemite
|
|
end
|
|
|
|
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
|
|
|
|
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/hashicorp/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 packerpath 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
|
|
if build.head?
|
|
system "make", "bin"
|
|
else
|
|
system "make", "releasebin"
|
|
end
|
|
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
|