class Packetbeat < Formula desc "Lightweight Shipper for Network Data" homepage "https://www.elastic.co/products/beats/packetbeat" url "https://github.com/elastic/beats/archive/v6.2.4.tar.gz" sha256 "87d863cf55863329ca80e76c3d813af2960492f4834d4fea919f1d4b49aaf699" head "https://github.com/elastic/beats.git" bottle do cellar :any_skip_relocation sha256 "c49e265502b3be8c83ec949e1c25781ca2560a2956fe4bdcb462dd871c35a4b7" => :high_sierra sha256 "db873b1e0f6344a316b234402f8994b12eef03eb4deb662b50277e6eabea8053" => :sierra sha256 "a655b33e3a1602a68ae3e2954cb03bd3b3f2d17954a68b9df2e48eb990c8c140" => :el_capitan end depends_on "go" => :build depends_on "python@2" => :build resource "virtualenv" do url "https://files.pythonhosted.org/packages/b1/72/2d70c5a1de409ceb3a27ff2ec007ecdd5cc52239e7c74990e32af57affe9/virtualenv-15.2.0.tar.gz" sha256 "1d7e241b431e7afce47e77f8843a276f652699d1fa4f93b9d8ce0076fd7b0b54" end def install ENV["GOPATH"] = buildpath (buildpath/"src/github.com/elastic/beats").install buildpath.children ENV.prepend_create_path "PYTHONPATH", buildpath/"vendor/lib/python2.7/site-packages" resource("virtualenv").stage do system "python", *Language::Python.setup_install_args(buildpath/"vendor") end ENV.prepend_path "PATH", buildpath/"vendor/bin" cd "src/github.com/elastic/beats/packetbeat" do system "make" # prevent downloading binary wheels during python setup system "make", "PIP_INSTALL_COMMANDS=--no-binary :all", "python-env" system "make", "DEV_OS=darwin", "update" inreplace "packetbeat.yml", "packetbeat.interfaces.device: any", "packetbeat.interfaces.device: en0" (etc/"packetbeat").install Dir["packetbeat.*", "fields.yml"] (libexec/"bin").install "packetbeat" prefix.install "_meta/kibana" end prefix.install_metafiles buildpath/"src/github.com/elastic/beats" (bin/"packetbeat").write <<~EOS #!/bin/sh exec #{libexec}/bin/packetbeat \ --path.config #{etc}/packetbeat \ --path.data #{var}/lib/packetbeat \ --path.home #{prefix} \ --path.logs #{var}/log/packetbeat \ "$@" EOS end plist_options :manual => "packetbeat" def plist; <<~EOS Label #{plist_name} Program #{opt_bin}/packetbeat RunAtLoad EOS end test do system "#{bin}/packetbeat", "devices" end end