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.4", :revision => "6e4899c018a34a84593d6abace621cfa93a95d84" head "https://github.com/hashicorp/packer.git" bottle do cellar :any_skip_relocation sha256 "0154f9a02e522198b3c984886b47c5debc68fbd10d8f8cf51229444fe39d54fa" => :mojave sha256 "b4e5bf3d96465d0c096bacf9ce627082b778659664c405ee4a151ae5d5c796c5" => :high_sierra sha256 "669cbb9b854bca1959713de76993e4fd8aa22b8348fd781ec3fa46dcc1c07c16" => :sierra end 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/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