class Consul < Formula desc "Tool for service discovery, monitoring and configuration" homepage "https://www.consul.io" url "https://github.com/hashicorp/consul.git", :tag => "v1.6.2", :revision => "1200f25eabc75368484a78698e75f1e61b6ed010" head "https://github.com/hashicorp/consul.git", :shallow => false bottle do cellar :any_skip_relocation sha256 "32643f0e02d5a1671be58ecc6038214ffbd60742cdcc70b83a6a72c9f419898b" => :catalina sha256 "ffc918f234d61990e4762992d8e337e73d839a64e4c43f9e2fc8bb1d512aca3e" => :mojave sha256 "c9c3305b87e39ffd0b4ae5a31a8b3fd6e811aa3a1314b93a252390ce3edd0bba" => :high_sierra end depends_on "go@1.12" => :build depends_on "gox" => :build def install # Avoid running `go get` inreplace "GNUmakefile", "go get -u -v $(GOTOOLS)", "" ENV["XC_OS"] = "darwin" ENV["XC_ARCH"] = "amd64" ENV["GOPATH"] = buildpath contents = Dir["{*,.git,.gitignore}"] (buildpath/"src/github.com/hashicorp/consul").install contents (buildpath/"bin").mkpath cd "src/github.com/hashicorp/consul" do system "make" bin.install "bin/consul" prefix.install_metafiles end end plist_options :manual => "consul agent -dev -advertise 127.0.0.1" def plist; <<~EOS KeepAlive SuccessfulExit Label #{plist_name} ProgramArguments #{opt_bin}/consul agent -dev -advertise 127.0.0.1 RunAtLoad WorkingDirectory #{var} StandardErrorPath #{var}/log/consul.log StandardOutPath #{var}/log/consul.log EOS end test do fork do exec "#{bin}/consul", "agent", "-data-dir", "." end sleep 3 system "#{bin}/consul", "leave" end end