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.2.5",
|
|
:revision => "d1cc5451e933f39986bdc1069e9d26e534cde548"
|
|
head "https://github.com/hashicorp/packer.git"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "3568f0d34660c07137dffab120cfb59882b6f743518af9f2f05701e730f30bdf" => :mojave
|
|
sha256 "5784d882676622c80b6e19f99bf443ba085c4753a0bb1c73fd435f5a49df6ddd" => :high_sierra
|
|
sha256 "f454077a2ddd265254e8c6aadfdadd1db6a42308d588fec1089b2ac6c4b50ed0" => :sierra
|
|
sha256 "712f7afc336c0b7a2c30d58a2746674339172812a9cc7102f9f0b969f86a02fb" => :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
|