homebrew-core/Formula/packetbeat.rb

84 lines
2.6 KiB
Ruby

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.1.1.tar.gz"
sha256 "c69f0047644be919e42a1d8fa3383c894ca8e054d5b6f727f161ed4ce497ca84"
head "https://github.com/elastic/beats.git"
bottle do
cellar :any_skip_relocation
sha256 "b986062fbc0bc7dc38c576a16791bb87ec93afd2fce98916aea38d3c73a9cc22" => :high_sierra
sha256 "a65e3cd7cba5bc7012dfbed7645d64dc5e53dbecb30caecf40f2c00a8de52948" => :sierra
sha256 "fa7fe4ddf8b97d1e5e2c763cd19264cd57652a3210d684c2e02cb0432a267e91" => :el_capitan
end
depends_on "go" => :build
resource "virtualenv" do
url "https://files.pythonhosted.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz"
sha256 "02f8102c2436bb03b3ee6dede1919d1dac8a427541652e5ec95171ec8adbc93a"
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
# prevent downloading binary wheels
inreplace "../libbeat/scripts/Makefile", "pip install", "pip install --no-binary :all"
system "make"
system "make", "update"
(libexec/"bin").install "packetbeat"
libexec.install "_meta/kibana"
inreplace "packetbeat.yml", "packetbeat.interfaces.device: any", "packetbeat.interfaces.device: en0"
(etc/"packetbeat").install Dir["packetbeat*.yml"]
(etc/"packetbeat").install "fields.yml"
prefix.install_metafiles
end
(bin/"packetbeat").write <<~EOS
#!/bin/sh
exec #{libexec}/bin/packetbeat \
-path.config #{etc}/packetbeat \
-path.home #{prefix} \
-path.logs #{var}/logs/packetbeat \
-path.data #{var}/lib/packetbeat \
"$@"
EOS
end
plist_options :manual => "packetbeat"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>Program</key>
<string>#{opt_bin}/packetbeat</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
system "#{bin}/packetbeat", "devices"
end
end