homebrew-core/Formula/packer.rb
2019-11-04 19:54:14 -05:00

63 lines
1.8 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.4.5",
:revision => "5ddd02d1c0e5d8b1b0e2171d2d40c7d7b5641e68"
head "https://github.com/hashicorp/packer.git"
bottle do
cellar :any_skip_relocation
sha256 "08ec8a4a9c53c072150651471e084761287f912e8dc7b47a1672e6b615fc012d" => :catalina
sha256 "824bc5c626e4b6924b0447c401f23440f91ef2da893aa929e5473b2442905446" => :mojave
sha256 "82512049d11b9f94d77e54cc2f56b704bf66212a1fae9b2374ac15b7f9f3d6ae" => :high_sierra
end
depends_on "coreutils" => :build
depends_on "go" => :build
def install
ENV["XC_OS"] = "darwin"
ENV["XC_ARCH"] = "amd64"
ENV["GOPATH"] = buildpath
packerpath = buildpath/"src/github.com/hashicorp/packer"
packerpath.install Dir["{*,.git}"]
cd packerpath do
(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", "-syntax-only", minimal
end
end