71 lines
2.1 KiB
Ruby
71 lines
2.1 KiB
Ruby
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.2.0",
|
|
:revision => "ca393b96f3909c3cde0f63d5aea211573dd22bc1"
|
|
head "https://github.com/hashicorp/packer.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "ad2106a8f12ecadacb7cc2fbfaa2df1d2d369b43c8b30b6e2e0b9b7a3f729565" => :high_sierra
|
|
sha256 "3ae67d74b897e866cdfdb48cb2bf1ee794a296f403360f4a32dcdfb090bdb370" => :sierra
|
|
sha256 "09667e313a9a4b87def540d39d19602a083e6423270832068c4e06a43561cb8b" => :el_capitan
|
|
end
|
|
|
|
depends_on "go" => :build
|
|
depends_on "govendor" => :build
|
|
depends_on "gox" => :build
|
|
|
|
def install
|
|
ENV["XC_OS"] = "darwin"
|
|
ENV["XC_ARCH"] = MacOS.prefer_64_bit? ? "amd64" : "386"
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
packerpath = buildpath/"src/github.com/hashicorp/packer"
|
|
packerpath.install Dir["{*,.git}"]
|
|
|
|
cd packerpath do
|
|
# Avoid running `go get`
|
|
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
|
|
{
|
|
"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
|