homebrew-core/Formula/kibana.rb
2015-12-29 17:33:47 +01:00

99 lines
3.3 KiB
Ruby

class Kibana < Formula
desc "Analytics and search dashboard for Elasticsearch"
homepage "https://www.elastic.co/products/kibana"
url "https://github.com/elastic/kibana.git", :tag => "v4.3.1", :revision => "d6e412dc2fa54666bf6ceb54a197508a4bc70baf"
head "https://github.com/elastic/kibana.git"
bottle do
sha256 "982230d782a879a0d073aa28a514a8b1ca168e5814dce528b0de7f2df1de7d9b" => :el_capitan
sha256 "7ba6e3a76d4745cea036ec36185920648e52b3068585b7af688b7494fe394235" => :yosemite
sha256 "db2c5626df644ff1249e054b911f819487d80ecb9400970672f5887cca1a4a1a" => :mavericks
end
resource "node" do
url "https://nodejs.org/dist/v0.12.9/node-v0.12.9.tar.gz"
sha256 "35daad301191e5f8dd7e5d2fbb711d081b82d1837d59837b8ee224c256cfe5e4"
end
def install
resource("node").stage buildpath/"node"
cd buildpath/"node" do
system "./configure", "--prefix=#{libexec}/node"
system "make", "install"
end
# do not download binary installs of Node.js
inreplace buildpath/"tasks/build/index.js", %r{('_build:downloadNodeBuilds:\w+',)}, "// \\1"
# do not build packages for other platforms
platforms = Set.new(["darwin-x64", "linux-x64", "linux-x86", "windows"])
if OS.mac? && Hardware::CPU.is_64_bit?
platform = "darwin-x64"
elsif OS.linux?
platform = if Hardware::CPU.is_64_bit? then "linux-x64" else "linux-x86" end
else
raise "Installing Kibana via Homebrew is only supported on Darwin x86_64, Linux i386, Linux i686, and Linux x86_64"
end
platforms.delete(platform)
sub = platforms.to_a.join("|")
inreplace buildpath/"tasks/config/platforms.js", %r{('(#{sub})',?(?!;))}, "// \\1"
# do not build zip package
inreplace buildpath/"tasks/build/archives.js", %r{(await exec\('zip'.*)}, "// \\1"
ENV.prepend_path "PATH", prefix/"libexec/node/bin"
system "npm", "install"
system "npm", "run", "build"
mkdir "tar" do
system "tar", "--strip-components", "1", "-xf", Dir[buildpath/"target/kibana-*-#{platform}.tar.gz"].first
rm_f Dir["bin/*.bat"]
prefix.install "bin", "config", "node_modules", "optimize", "package.json", "src", "webpackShims"
end
inreplace "#{bin}/kibana", %r{/node/bin/node}, "/libexec/node/bin/node"
cd prefix do
inreplace "config/kibana.yml", %{/var/run/kibana.pid}, var/"run/kibana.pid"
(etc/"kibana").install Dir["config/*"]
rm_rf "config"
end
end
def post_install
ln_s etc/"kibana", prefix/"config"
(var/"lib/kibana/installedPlugins").mkpath
ln_s var/"lib/kibana/installedPlugins", prefix/"installedPlugins"
end
plist_options :manual => "kibana"
def caveats; <<-EOS.undent
Plugins: #{var}/kibana/installedPlugins/
Config: #{etc}/kibana/
EOS
end
def plist; <<-EOS.undent
<?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}/kibana</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
ENV["BABEL_CACHE_PATH"] = testpath/".babelcache.json"
assert_match /#{version}/, shell_output("#{bin}/kibana -V")
end
end