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.1", :revision => "0b740f508f4f9b63442879a8c8f7a197b9a83dc1" head "https://github.com/hashicorp/packer.git" bottle do cellar :any_skip_relocation sha256 "10ed514ee743fea1d39e8d0684ea930a65969f2ce9b2f2bb87a7eb51df534989" => :high_sierra sha256 "8334e14b29ce519ec92d741de6ab936163228a782c8cfaf388bbc0b9b777cee9" => :sierra sha256 "58b198bc7b759cd9c3493f4095ca45ad007b2712f37b4684c115ca5764b79bed" => :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