homebrew-core/Formula/packer.rb
2018-11-04 11:48:04 +00: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.3.2",
:revision => "6881d841a1a8374d696d79f156cbc462efe17984"
head "https://github.com/hashicorp/packer.git"
bottle do
cellar :any_skip_relocation
sha256 "e6ea7c912bf76cc1e5bcc6043365c75f59a4fbc80df80f8e7f98faea5f237a15" => :mojave
sha256 "4d6422b0c1c3b52904967f2fc6a48e76002ad2bdd3d4370ae6a358ab8ec90c7f" => :high_sierra
sha256 "05bdc1a8ce1c79769ed156dffad8c40fe30c62a12f38108afafa145385cc2464" => :sierra
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", "-syntax-only", minimal
end
end