108 lines
3.9 KiB
Ruby
108 lines
3.9 KiB
Ruby
class Logstash < Formula
|
|
desc "Tool for managing events and logs"
|
|
homepage "https://www.elastic.co/products/logstash"
|
|
url "https://github.com/elastic/logstash/archive/v8.5.2.tar.gz"
|
|
sha256 "24c1aafc95e701a13eb5d6f3134811ac24b914457dddd3023890486413f4ebdc"
|
|
license "Apache-2.0"
|
|
version_scheme 1
|
|
head "https://github.com/elastic/logstash.git", branch: "main"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_ventura: "0ac0973a3dadd9e3a11c1117e6dbd778ec4c8000c3606a71bfb325aa9961ea02"
|
|
sha256 cellar: :any, arm64_monterey: "c707f2dc66f103e2b1068870a05d244dcb5cf7297399ce8d667af80c18f9c7b1"
|
|
sha256 cellar: :any, arm64_big_sur: "2dc4d30e47b4905b2e7bbfd1c309aefc4928a658870539a9226a575ebc23c1da"
|
|
sha256 cellar: :any, ventura: "1607cf4a2b42d1735a08fcc0af28b77541e3ce641fc120244b7faa775d5db56c"
|
|
sha256 cellar: :any, monterey: "e0b9d37cc40446491e3c7d2254ae14152be2ec7b768568ad971bc61d29bb8f1d"
|
|
sha256 cellar: :any, big_sur: "674cd30b818b70a84aebdb7dbdcacfce48c1c9bed2e3bbda345f0687e7fc5399"
|
|
sha256 cellar: :any, catalina: "d36aaf2111b6d7b36d4cdbdda3abacbe89baa371c2f7250c00324a84f32f1274"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "c09dfa53df65d6ea6dddd7bb8c9b8dd84772d29f00c79bc1dd31ffed92b1a3ff"
|
|
end
|
|
|
|
depends_on "openjdk@17"
|
|
|
|
uses_from_macos "ruby" => :build
|
|
|
|
def install
|
|
# remove non open source files
|
|
rm_rf "x-pack"
|
|
ENV["OSS"] = "true"
|
|
|
|
# Build the package from source
|
|
system "rake", "artifact:no_bundle_jdk_tar"
|
|
# Extract the package to the current directory
|
|
mkdir "tar"
|
|
system "tar", "--strip-components=1", "-xf", Dir["build/logstash-*.tar.gz"].first, "-C", "tar"
|
|
cd "tar"
|
|
|
|
inreplace "bin/logstash",
|
|
%r{^\. "\$\(cd `dirname \$\{SOURCEPATH\}`/\.\.; pwd\)/bin/logstash\.lib\.sh"},
|
|
". #{libexec}/bin/logstash.lib.sh"
|
|
inreplace "bin/logstash-plugin",
|
|
%r{^\. "\$\(cd `dirname \$0`/\.\.; pwd\)/bin/logstash\.lib\.sh"},
|
|
". #{libexec}/bin/logstash.lib.sh"
|
|
inreplace "bin/logstash.lib.sh",
|
|
/^LOGSTASH_HOME=.*$/,
|
|
"LOGSTASH_HOME=#{libexec}"
|
|
|
|
# Delete Windows and other Arch/OS files
|
|
paths_to_keep = OS.linux? ? "#{Hardware::CPU.arch}-#{OS.kernel_name}" : OS.kernel_name
|
|
rm Dir["bin/*.bat"]
|
|
Dir["vendor/jruby/lib/jni/*"].each do |path|
|
|
rm_r path unless path.include? paths_to_keep
|
|
end
|
|
|
|
libexec.install Dir["*"]
|
|
|
|
# Move config files into etc
|
|
(etc/"logstash").install Dir[libexec/"config/*"]
|
|
(libexec/"config").rmtree
|
|
|
|
bin.install libexec/"bin/logstash", libexec/"bin/logstash-plugin"
|
|
bin.env_script_all_files libexec/"bin", LS_JAVA_HOME: "${LS_JAVA_HOME:-#{Language::Java.java_home("17")}}"
|
|
end
|
|
|
|
def post_install
|
|
ln_s etc/"logstash", libexec/"config"
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
Configuration files are located in #{etc}/logstash/
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run opt_bin/"logstash"
|
|
keep_alive false
|
|
working_dir var
|
|
log_path var/"log/logstash.log"
|
|
error_log_path var/"log/logstash.log"
|
|
end
|
|
|
|
test do
|
|
# workaround https://github.com/elastic/logstash/issues/6378
|
|
(testpath/"config").mkpath
|
|
["jvm.options", "log4j2.properties", "startup.options"].each do |f|
|
|
cp prefix/"libexec/config/#{f}", testpath/"config"
|
|
end
|
|
(testpath/"config/logstash.yml").write <<~EOS
|
|
path.queue: #{testpath}/queue
|
|
EOS
|
|
(testpath/"data").mkpath
|
|
(testpath/"logs").mkpath
|
|
(testpath/"queue").mkpath
|
|
|
|
data = "--path.data=#{testpath}/data"
|
|
logs = "--path.logs=#{testpath}/logs"
|
|
settings = "--path.settings=#{testpath}/config"
|
|
|
|
output = pipe_output("#{bin}/logstash -e '' #{data} #{logs} #{settings} --log.level=fatal", "hello world\n")
|
|
assert_match "hello world", output
|
|
end
|
|
end
|