homebrew-core/Formula/kibana.rb
Jerzerak 652b78cede kibana 5.0.0-alpha2 (devel)
Closes #844.

Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
2016-05-05 00:10:24 +02:00

108 lines
3.7 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 => "v4.5.0", :revision => "ff5cfc5d05a58e53f7acaa762428fa803318d31e"
head "https://github.com/elastic/kibana.git"
bottle do
revision 1
sha256 "6af189c5637460bdd3d78492e85d89a11adf17b6d74cedbed58bd2498cd06f55" => :el_capitan
sha256 "785fd76f71b6fb27476a6d722e306edbf7ee5a8b473747c1a432d903c37ad766" => :yosemite
sha256 "bc8cadd81b4a31ea1084ae5835d8950a89c4547a97231f11d00858929ed32056" => :mavericks
end
devel do
url "https://github.com/elastic/kibana.git", :tag => "v5.0.0-alpha2", :revision => "6d7bb147cf9ae7170fde494b1f17128a50123b5f"
end
resource "node" do
url "https://nodejs.org/dist/v4.3.2/node-v4.3.2.tar.gz"
sha256 "1f92f6d31f7292ce56db57d6703efccf3e6c945948f5901610cefa69e78d3498"
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", /('_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 = Hardware::CPU.is_64_bit? ? "linux-x64" : "linux-x86"
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"
# do not build zip package
inreplace buildpath/"tasks/build/archives.js", /(await exec\('zip'.*)/, "// \\1"
# 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"
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"
(prefix/"installedPlugins").mkdir
end
def caveats; <<-EOS.undent
Config: #{etc}/kibana/
If you wish to preserve your plugins upon upgrade, make a copy of
#{prefix}/installedPlugins 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