Update for windows to execute rake bootstrap and bin\logstash.bat

Fixes #2085
This commit is contained in:
wiibaa 2014-12-22 22:17:05 +01:00 committed by Jordan Sissel
parent dd5685dc2e
commit 516cc36e1a
4 changed files with 46 additions and 41 deletions

View file

@ -2,12 +2,23 @@
SETLOCAL
if not defined JAVA_HOME goto missing_java_home
set SCRIPT_DIR=%~dp0
for %%I in ("%SCRIPT_DIR%..") do set LS_HOME=%%~dpfI
if "%USE_RUBY%" == "1" (
goto setup_ruby
) else (
goto setup_jruby
)
:setup_ruby
set RUBYCMD=ruby
set VENDORED_JRUBY=
goto EXEC
:setup_jruby
REM setup_java()
if not defined JAVA_HOME goto missing_java_home
REM ***** JAVA options *****
if "%LS_MIN_MEM%" == "" (
@ -46,26 +57,23 @@ REM The path to the heap dump location, note directory must exists and have enou
REM space for a full heap dump.
REM JAVA_OPTS=%JAVA_OPTS% -XX:HeapDumpPath=$LS_HOME/logs/heapdump.hprof
REM setup_vendored_jruby()
set JRUBY_BIN="%LS_HOME%\vendor\jruby\bin\jruby"
if exist "%JRUBY_BIN%" (
set VENDORED_JRUBY=1
goto EXEC
) else (
goto missing_jruby
)
:EXEC
REM run logstash
set RUBYLIB=%LS_HOME%\lib
set GEM_HOME=%LS_HOME%\vendor\bundle\jruby\1.9\
set GEM_PATH=%GEM_HOME%
for %%I in ("%LS_HOME%\vendor\jar\jruby-complete-*.jar") do set JRUBY_JAR_FILE=%%I
if not defined JRUBY_JAR_FILE goto missing_jruby_jar
set RUBY_CMD="%JAVA_HOME%\bin\java" %JAVA_OPTS% %LS_JAVA_OPTS% -jar "%JRUBY_JAR_FILE%"
if "%*"=="deps" goto install_deps
goto run_logstash
:install_deps
if not exist "%LS_HOME%\logstash.gemspec" goto missing_gemspec
echo Installing gem dependencies. This will probably take a while the first time.
%RUBY_CMD% "%LS_HOME%\gembag.rb"
goto finally
:run_logstash
%RUBY_CMD% "%LS_HOME%\lib\logstash\runner.rb" %*
if "%VENDORED_JRUBY%" == "" (
%RUBYCMD% "%LS_HOME%\lib\logstash\runner.rb" %*
) else (
%JRUBY_BIN% %jruby_opts% "%LS_HOME%\lib\logstash\runner.rb" %*
)
goto finally
:missing_java_home
@ -73,15 +81,10 @@ echo JAVA_HOME environment variable must be set!
pause
goto finally
:missing_jruby_jar
md "%LS_HOME%\vendor\jar\"
echo Please download the JRuby Complete .jar from http://jruby.org/download to %LS_HOME%\vendor\jar\ and re-run this command.
pause
goto finally
:missing_gemspec
echo Cannot install dependencies; missing logstash.gemspec. This 'deps' command only works from a logstash git clone.
pause
:missing_jruby
echo Unable to find JRuby.
echo If you are a user, this is a bug.
echo If you are a developer, please run 'rake bootstrap'. Running 'rake' requires the 'ruby' program be available.
goto finally
:finally

View file

@ -50,8 +50,7 @@ namespace "artifact" do
require "archive/tar/minitar"
require "logstash/version"
tarpath = "build/logstash-#{LOGSTASH_VERSION}.tar.gz"
tarfile = File.new(tarpath, "wb")
gz = Zlib::GzipWriter.new(tarfile, Zlib::BEST_COMPRESSION)
gz = Zlib::GzipWriter.new(File.new(tarpath, "wb"), Zlib::BEST_COMPRESSION)
tar = Archive::Tar::Minitar::Output.new(gz)
files.each do |path|
stat = File.lstat(path)
@ -65,7 +64,7 @@ namespace "artifact" do
tar.tar.mkdir(path_in_tar, opts)
else
tar.tar.add_file_simple(path_in_tar, opts) do |io|
File.open(path) do |fd|
File.open(path,'rb') do |fd|
chunk = nil
size = 0
size += io.write(chunk) while chunk = fd.read(16384)

View file

@ -34,7 +34,7 @@ end
def file_sha1(path)
digest = Digest::SHA1.new
fd = File.new(path, "r")
fd = File.new(path, "rb")
while true
begin
digest << fd.sysread(16384)
@ -57,7 +57,7 @@ def download(url, output)
fail "HTTP fetch failed for #{url}. #{response}" if response.code != "200"
size = (response["content-length"].to_i || -1).to_f
count = 0
File.open(tmp, "w") do |fd|
File.open(tmp, "wb") do |fd|
response.read_body do |chunk|
fd.write(chunk)
digest << chunk

View file

@ -1,5 +1,5 @@
DOWNLOADS = {
"jruby" => { "version" => "1.7.16", "sha1" => "4c912b648f6687622ba590ca2a28746d1cd5d550" },
"jruby" => { "version" => "1.7.17", "sha1" => "e4621bbcc51242061eaa9b62caee69c2a2b433f0" },
"kibana" => { "version" => "3.1.2", "sha1" => "a59ea4abb018a7ed22b3bc1c3bcc6944b7009dc4" },
}
@ -15,8 +15,7 @@ end
def untar(tarball, &block)
Rake::Task["dependency:archive-tar-minitar"].invoke
require "archive/tar/minitar"
tgz = Zlib::GzipReader.new(File.open(tarball))
# Pull out typesdb
tgz = Zlib::GzipReader.new(File.open(tarball,"rb"))
tar = Archive::Tar::Minitar::Input.open(tgz)
tar.each do |entry|
path = block.call(entry)
@ -36,10 +35,15 @@ def untar(tarball, &block)
# expose headers in the entry.
entry_size = entry.instance_eval { @size }
# If file sizes are same, skip writing.
next if stat.size == entry_size && (stat.mode & 0777) == entry_mode
if Gem.win_platform?
#Do not fight with windows permission scheme
next if stat.size == entry_size
else
next if stat.size == entry_size && (stat.mode & 0777) == entry_mode
end
end
puts "Extracting #{entry.full_name} from #{tarball} #{entry_mode.to_s(8)}"
File.open(path, "w") do |fd|
File.open(path, "wb") do |fd|
# eof? check lets us skip empty files. Necessary because the API provided by
# Archive::Tar::Minitar::Reader::EntryStream only mostly acts like an
# IO object. Something about empty files in this EntryStream causes
@ -62,7 +66,6 @@ namespace "vendor" do
name = task.name.split(":")[1]
info = DOWNLOADS[name]
version = info["version"]
#url = "http://jruby.org.s3.amazonaws.com/downloads/#{version}/jruby-complete-#{version}.jar"
url = "http://jruby.org.s3.amazonaws.com/downloads/#{version}/jruby-bin-#{version}.tar.gz"
download = file_fetch(url, info["sha1"])