homebrew-core/Formula/kibana.rb
2017-02-10 15:41:10 +00:00

99 lines
3.4 KiB
Ruby

require "language/node"
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 => "v5.2.0",
:revision => "9b0119b706e53fbd67b447381fe80f71b9996893"
head "https://github.com/elastic/kibana.git"
bottle do
rebuild 1
sha256 "2d749497642924d97b9dedeecea785e0c77fdc7063eb93517d6c1f6ac4cefde2" => :sierra
sha256 "c9e9134df53cf08b1cde25703895e56b16514a3a42243f66be640572989b91d1" => :el_capitan
sha256 "51b54e132e0baa0f7c5a5fe4fdb658cf27bae4ed50ee8c7f48ab9c0c787ccc8b" => :yosemite
end
resource "node" do
url "https://nodejs.org/dist/v6.9.0/node-v6.9.0.tar.xz" # N.B. includes vendored dependencies
sha256 "656342ed8a84c95a36af902f309aeeca7103b16d61c02925bd37bd47d2194915"
end
def install
resource("node").stage do
system "./configure", "--prefix=#{libexec}/node"
system "make", "test"
system "make", "install"
end
# do not build packages for other platforms
platforms = Set.new(["darwin-x64", "linux-x64", "linux-x86", "windows-x86"])
if MacOS.prefer_64_bit?
platform = "darwin-x64"
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", /('(#{sub})',?(?!;))/, "// \\1"
# trick the build into thinking we've already downloaded the Node.js binary
mkdir_p buildpath/".node_binaries/#{resource("node").version}/#{platform}"
# set npm env and fix cache edge case (https://github.com/Homebrew/brew/pull/37#issuecomment-208840366)
ENV.prepend_path "PATH", prefix/"libexec/node/bin"
Pathname.new("#{ENV["HOME"]}/.npmrc").write Language::Node.npm_cache_config
system "npm", "install", "--verbose"
system "npm", "run", "build", "--", "--release", "--skip-os-packages", "--skip-archives"
prefix.install Dir["build/kibana-#{version}-#{platform.sub("x64", "x86_64")}/{bin,config,node_modules,optimize,package.json,src,webpackShims}"]
inreplace "#{bin}/kibana", %r{/node/bin/node}, "/libexec/node/bin/node"
inreplace "#{bin}/kibana-plugin", %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"
(prefix/"data").mkdir
(prefix/"plugins").mkdir
end
def caveats; <<-EOS.undent
Config: #{etc}/kibana/
If you wish to preserve your plugins upon upgrade, make a copy of
#{opt_prefix}/plugins before upgrading, and copy it into the
new keg location after upgrading.
EOS
end
plist_options :manual => "kibana"
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