homebrew-core/Formula/packer.rb
2018-03-27 09:43:19 +10:00

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.2",
:revision => "ab8811dca8f375344f36dfc32710b9790b2ec03e"
head "https://github.com/hashicorp/packer.git"
bottle do
cellar :any_skip_relocation
sha256 "540565d8512b9ed8e9072c40fd4e87706ab2f4f097789239e5dc50193965159d" => :high_sierra
sha256 "a5f518c11e4ef7fdbb706b1c60270eb3686ce75c64406d126c528bb2a9e7c401" => :sierra
sha256 "5dabb27cecf254ee9e663f768b26e26941e3dee9187d3b0130420a84b41dd74e" => :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