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.4.2", :revision => "deb133452d38a0e3e71851e05a2af23cc2cc062e" head "https://github.com/hashicorp/packer.git" bottle do cellar :any_skip_relocation sha256 "e3525d4ed1a2054c6af4f3d744da888b6b55fa7ce1d6f864ed0acf8faed0e790" => :mojave sha256 "32b756e971cef6d9ae817e0ff6683541f41653ef0791177e7cae00d6317bf30e" => :high_sierra sha256 "3dbb55ae83123e1d7a6d7b710248a855693c9feb10f79abd57ca7b68cb23eb6d" => :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/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 github.com/alvaroloes/enumer", "" 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