mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
d955077d26
commit
288cb1fc05
3 changed files with 33 additions and 51 deletions
|
@ -30,22 +30,39 @@ module LogStash
|
|||
end
|
||||
end
|
||||
|
||||
def gem_home
|
||||
[::File.join(BUNDLE_DIR, ruby_engine, gem_ruby_version), BOOTSTRAP_GEM_PATH].join(':')
|
||||
def logstash_gem_home
|
||||
::File.join(BUNDLE_DIR, ruby_engine, gem_ruby_version)
|
||||
end
|
||||
|
||||
def plugins_home
|
||||
def plugins_gem_home
|
||||
# plugins are gems, respect same path structure as core gems_home
|
||||
::File.join(PLUGINS_DIR, ruby_engine, gem_ruby_version)
|
||||
end
|
||||
|
||||
# set GEM_PATH for logstash runtime
|
||||
# GEM_PATH should include the logstash gems, the plugin gems and the bootstrap gems.
|
||||
# the bootstrap gems are required specificly for bundler which is a runtime dependency
|
||||
# of some plugins dependedant gems.
|
||||
def set_gem_paths!
|
||||
require ::File.join(BUNDLE_DIR, "bundler", "setup.rb")
|
||||
ENV["GEM_PATH"] = gem_home
|
||||
ENV["GEM_HOME"] = plugins_home
|
||||
Gem.paths = plugins_home
|
||||
ENV["GEM_PATH"] = [logstash_gem_home, plugins_gem_home, BOOTSTRAP_GEM_PATH].join(":")
|
||||
end
|
||||
|
||||
def bundler_install_command(gem_file, gem_path)
|
||||
[
|
||||
File.join(BOOTSTRAP_GEM_PATH, "bin", "bundle"),
|
||||
"install",
|
||||
"--gemfile=#{gem_file}",
|
||||
"--standalone",
|
||||
"--clean",
|
||||
"--without", "development",
|
||||
"--jobs", "4",
|
||||
"--path", gem_path,
|
||||
]
|
||||
end
|
||||
|
||||
def ruby_bin
|
||||
ENV["USE_RUBY"] == "1" ? "ruby" : File.join("vendor", "jruby", "bin", "jruby")
|
||||
end
|
||||
|
||||
# @return [String] major.minor ruby version, ex 1.9
|
||||
def ruby_abi_version
|
||||
|
|
|
@ -12,26 +12,16 @@ namespace "plugin" do
|
|||
end # task "install"
|
||||
|
||||
task "install-defaults" do
|
||||
gem_path = ENV['GEM_PATH']
|
||||
gem_home = ENV['GEM_HOME']
|
||||
|
||||
env = {
|
||||
"GEM_PATH" => [
|
||||
ENV['GEM_PATH'],
|
||||
::File.join(LogStash::Environment::LOGSTASH_HOME, 'build/bootstrap'),
|
||||
LogStash::Environment.gem_home
|
||||
].join(":"),
|
||||
"GEM_HOME" => LogStash::Environment.plugins_home,
|
||||
"BUNDLE_GEMFILE" => "tools/Gemfile.plugins"
|
||||
LogStash::Environment.logstash_gem_home,
|
||||
LogStash::Environment.plugins_gem_home,
|
||||
::File.join(LogStash::Environment::LOGSTASH_HOME, "build/bootstrap"),
|
||||
].join(":")
|
||||
}
|
||||
if ENV['USE_RUBY'] != '1'
|
||||
jruby = File.join("vendor", "jruby", "bin", "jruby")
|
||||
bundle = File.join("build", "bootstrap", "bin", "bundle")
|
||||
system(env, jruby, "-S", bundle, "install")
|
||||
else
|
||||
system(env, "bundle", "install")
|
||||
end
|
||||
ENV['GEM_PATH'] = gem_path
|
||||
ENV['GEM_HOME'] = gem_home
|
||||
cmd = [LogStash::Environment.ruby_bin, "-S"] + LogStash::Environment.bundler_install_command("tools/Gemfile.plugins", LogStash::Environment::PLUGINS_DIR)
|
||||
system(env, *cmd)
|
||||
raise RuntimeError, $!.to_s unless $?.success?
|
||||
end
|
||||
end # namespace "plugin"
|
||||
|
|
|
@ -226,43 +226,18 @@ namespace "vendor" do
|
|||
# Try installing a few times in case we hit the "bad_record_mac" ssl error during installation.
|
||||
10.times do
|
||||
begin
|
||||
#Bundler::CLI.start(["install", "--gemfile=tools/Gemfile", "--path", LogStash::Environment.gem_home, "--clean", "--standalone", "--without", "development", "--jobs", 4])
|
||||
# There doesn't seem to be a way to invoke Bundler::CLI *and* have a
|
||||
# different GEM_HOME set that doesn't impact Bundler's view of what
|
||||
# gems are available. I asked about this in #bundler on freenode, and I
|
||||
# was told to stop using the bundler ruby api. Oh well :(
|
||||
bundler = File.join(Gem.bindir, "bundle")
|
||||
if ENV['USE_RUBY'] == '1'
|
||||
# Use the local jruby binary
|
||||
jruby = 'ruby'
|
||||
else
|
||||
# Use the vendored jruby binary
|
||||
jruby = File.join("vendor", "jruby", "bin", "jruby")
|
||||
bundler = File.join("build", "bootstrap", "bin", "bundle")
|
||||
end
|
||||
backup_gem_home = ENV['GEM_HOME']
|
||||
backup_gem_path = ENV['GEM_PATH']
|
||||
env = {
|
||||
'GEM_HOME' => LogStash::Environment.gem_home,
|
||||
'GEM_PATH' => [
|
||||
LogStash::Environment.logstash_gem_home,
|
||||
::File.join(LogStash::Environment::LOGSTASH_HOME, 'build/bootstrap'),
|
||||
::File.join(LogStash::Environment::LOGSTASH_HOME, 'vendor/jruby/lib/ruby/gems/shared')
|
||||
].join(":")
|
||||
}
|
||||
cmd = [jruby, "-S", bundler, "install", "--gemfile=tools/Gemfile",
|
||||
"--standalone",
|
||||
"--clean",
|
||||
"--without", "development",
|
||||
"--jobs", "4",
|
||||
"--path", LogStash::Environment::BUNDLE_DIR
|
||||
]
|
||||
cmd = [LogStash::Environment.ruby_bin, "-S"] + LogStash::Environment.bundler_install_command("tools/Gemfile", LogStash::Environment::BUNDLE_DIR)
|
||||
system(env, *cmd)
|
||||
|
||||
# because --path creates a .bundle/config file and changes bundler path
|
||||
# we need to remove this file so it doesn't influence following bundler calls
|
||||
FileUtils.rm_rf(::File.join(LogStash::Environment::LOGSTASH_HOME, "tools/.bundle"))
|
||||
ENV['GEM_HOME'] = backup_gem_home
|
||||
ENV['GEM_PATH'] = backup_gem_path
|
||||
raise RuntimeError, $!.to_s unless $?.success?
|
||||
break
|
||||
rescue Gem::RemoteFetcher::FetchError => e
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue