72 lines
2.2 KiB
Ruby
72 lines
2.2 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.3.0",
|
|
:revision => "20eb6c98edcbb5cd3b78299c8ca1b5cba67ce0cb"
|
|
head "https://github.com/hashicorp/packer.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "15fbbf96d8c2fc95d9a12478b550470022d595bdacc455bfefc942d0e6d9440d" => :mojave
|
|
sha256 "ec256aa1fe04fc11838457858c7c5bf38edf2e9839314cbed23967faeb5a66d6" => :high_sierra
|
|
sha256 "1c21a5ff88fa7f80e1503c95bdc6dcd8ba8e443e9d4015a3cb1fe2333b2a7670" => :sierra
|
|
sha256 "d0d25ce6108af1e7ff2afb321d1b0c47a5d5361008edcbf2da190db08d0256d7" => :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
|