bin/autoproj_install in autoproj-2.4.0 vs bin/autoproj_install in autoproj-2.5.0.pre1
- old
+ new
@@ -21,11 +21,11 @@
# It can be required standalone (i.e. does not depend on anything else than
# ruby and the ruby standard library)
class Install
class UnexpectedBinstub < RuntimeError; end
- # The directory in which to install autoproj
+ # The created workspace's root directory
attr_reader :root_dir
# Content of the Gemfile generated to install autoproj itself
attr_accessor :gemfile
# The environment that is passed to the bundler installs
attr_reader :env
@@ -314,16 +314,16 @@
if !result
STDERR.puts "FATAL: failed to install autoproj in #{dot_autoproj}"
exit 1
end
ensure
- self.class.rewrite_shims(shims_path, ruby_executable, autoproj_gemfile_path, gems_gem_home)
+ self.class.rewrite_shims(shims_path, ruby_executable, root_dir, autoproj_gemfile_path, gems_gem_home)
end
EXCLUDED_FROM_SHIMS = %w{rake thor}
- def self.rewrite_shims(shim_path, ruby_executable, autoproj_gemfile_path, gems_gem_home)
+ def self.rewrite_shims(shim_path, ruby_executable, root_dir, autoproj_gemfile_path, gems_gem_home)
FileUtils.mkdir_p shim_path
File.open(File.join(shim_path, 'ruby'), 'w') do |io|
io.puts "#! /bin/sh"
io.puts "exec #{ruby_executable} \"$@\""
end
@@ -345,11 +345,11 @@
File.open(bin_shim, 'w') do |io|
if bin_name == 'bundler' || bin_name == 'bundle'
io.puts shim_bundler(ruby_executable, autoproj_gemfile_path, gems_gem_home)
else
load_line = bin_script_lines.grep(/load Gem.bin_path/).first
- io.puts shim_script(ruby_executable, autoproj_gemfile_path, gems_gem_home, load_line)
+ io.puts shim_script(ruby_executable, root_dir, autoproj_gemfile_path, gems_gem_home, load_line)
end
end
FileUtils.chmod 0755, bin_shim
end
end
@@ -369,11 +369,11 @@
Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
load Gem.bin_path('bundler', 'bundler')"
end
- def self.shim_script(ruby_executable, autoproj_gemfile_path, gems_gem_home, load_line)
+ def self.shim_script(ruby_executable, root_dir, autoproj_gemfile_path, gems_gem_home, load_line)
"#! #{ruby_executable}
if defined?(Bundler)
Bundler.with_clean_env do
exec(Hash['RUBYLIB' => nil], $0, *ARGV)
@@ -381,10 +381,11 @@
elsif ENV['RUBYLIB']
exec(Hash['RUBYLIB' => nil], $0, *ARGV)
end
ENV['BUNDLE_GEMFILE'] = '#{autoproj_gemfile_path}'
+ENV['AUTOPROJ_CURRENT_ROOT'] = '#{root_dir}'
require 'rubygems'
Gem.paths = Hash['GEM_HOME' => '#{gems_gem_home}', 'GEM_PATH' => '']
require 'bundler/setup'
#{load_line}"
end
@@ -429,11 +430,11 @@
gemfile += [
"",
"config_path = File.join(__dir__, 'config.yml')",
"if File.file?(config_path)",
" require 'yaml'",
- " config = YAML.load(File.read(config_path))",
+ " config = YAML.load(File.read(config_path)) || Hash.new",
" (config['plugins'] || Hash.new).each do |plugin_name, (version, options)|",
" gem plugin_name, version, **options",
" end",
"end"
].join("\n")
@@ -498,10 +499,11 @@
end
end
self.class.rewrite_shims(
File.join(dot_autoproj, 'bin'),
ruby_executable,
+ root_dir,
autoproj_gemfile_path,
gems_gem_home)
env['PATH'].unshift File.join(dot_autoproj, 'bin')
save_gemfile
@@ -512,13 +514,13 @@
def load_config
v1_config_path = File.join(root_dir, 'autoproj', 'config.yml')
config = Hash.new
if File.file?(v1_config_path)
- config.merge!(YAML.load(File.read(v1_config_path)))
+ config.merge!(YAML.load(File.read(v1_config_path)) || Hash.new)
end
if File.file?(autoproj_config_path)
- config.merge!(YAML.load(File.read(autoproj_config_path)))
+ config.merge!(YAML.load(File.read(autoproj_config_path)) || Hash.new)
end
ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
ruby_bindir = RbConfig::CONFIG['bindir']
ruby_executable = File.join(ruby_bindir, ruby)