74 lines
2.2 KiB
Ruby
74 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.5",
|
|
:revision => "542cb1d872b4fbba57f34ebb5913a266017a38df"
|
|
head "https://github.com/hashicorp/packer.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "d89789a2b9eb05c72f95c160c218a1b34281de16940cecb906c0b87ff6c04f30" => :mojave
|
|
sha256 "4ed4109eb62477592281fb36a9ab543265fdb70916095140f9c488f06550ad3c" => :high_sierra
|
|
sha256 "8168a91a5748a5f673f714a398d648a6197c45ee1565a9718439c0a4ae894e31" => :sierra
|
|
end
|
|
|
|
depends_on "coreutils" => :build
|
|
depends_on "go" => :build
|
|
depends_on "govendor" => :build
|
|
depends_on "gox" => :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
|
|
# Avoid running `go get`
|
|
inreplace "Makefile" do |s|
|
|
s.gsub! "go get github.com/kardianos/govendor", ""
|
|
s.gsub! "go get github.com/mitchellh/gox", ""
|
|
s.gsub! "go get -u github.com/mna/pigeon", ""
|
|
s.gsub! "go get golang.org/x/tools/cmd/goimports", ""
|
|
s.gsub! "go get golang.org/x/tools/cmd/stringer", ""
|
|
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", "-syntax-only", minimal
|
|
end
|
|
end
|