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.5.0", :revision => "34eff659dcc5503b6eb117733c9f7def63f01bad" head "https://github.com/hashicorp/consul.git", :shallow => false bottle do cellar :any_skip_relocation sha256 "f47e4b2dff87574dbf7c52aa06b58baf0435a02c452f6f6622316393c3f4be17" => :mojave sha256 "7165c637dab65bcce8048ca559b8f94a249edf5c8230d6eabddab1f31675fa91" => :high_sierra sha256 "30b35d2970e03f9f06b06834d2ad084caba5f34deaf933fb17c784188128e31f" => :sierra end depends_on "go" => :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