lib/autoproj/package_managers/bundler_manager.rb in autoproj-2.0.0.rc10 vs lib/autoproj/package_managers/bundler_manager.rb in autoproj-2.0.0.rc11
- old
+ new
@@ -35,10 +35,16 @@
env.add_path 'PATH', File.join(ws.prefix_dir, 'gems', 'bin')
env.add_path 'PATH', File.join(config.bundler_gem_home, 'bin')
env.add_path 'PATH', File.join(ws.dot_autoproj_dir, 'autoproj', 'bin')
env.set 'GEM_HOME', config.gems_gem_home
+ root_dir = File.join(ws.prefix_dir, 'gems')
+ gemfile_path = File.join(root_dir, 'Gemfile')
+ if File.file?(gemfile_path)
+ env.set('BUNDLE_GEMFILE', gemfile_path)
+ end
+
if !config.private_bundler? || !config.private_autoproj? || !config.private_gems?
env.set('GEM_PATH', *Gem.default_path)
end
if config.private_bundler?
Autobuild.programs['bundler'] = File.join(config.bundler_gem_home, 'bin', 'bundler')
@@ -152,11 +158,11 @@
end
end
end
end
- def install(gems)
+ def install(gems, filter_uptodate_packages: false, install_only: false)
root_dir = File.join(ws.prefix_dir, 'gems')
gemfile_path = File.join(root_dir, 'Gemfile')
gemfile_lock_path = "#{gemfile_path}.lock"
backups = Hash[
gemfile_path => "#{gemfile_path}.orig",
@@ -177,35 +183,44 @@
if source.local_dir && File.file?(pkg_set_gemfile = File.join(source.local_dir, 'Gemfile'))
gemfiles << pkg_set_gemfile
end
end
# In addition, look into overrides.d
- Dir.glob(File.join(ws.config_dir, "*.gemfile")) do |gemfile_path|
+ Dir.glob(File.join(ws.overrides_dir, "*.gemfile")) do |gemfile_path|
gemfiles << gemfile_path
end
# Generate the gemfile and remove the lockfile
- gems = gems.sort.map do |name|
+ gemfile_lines = gems.map do |name|
name, version = parse_package_entry(name)
"gem \"#{name}\", \"#{version || ">= 0"}\""
- end.join("\n")
+ end
+ gemfiles.each do |gemfile|
+ gemfile_lines.concat(File.readlines(gemfile).map(&:chomp))
+ end
+ gemfile_lines = gemfile_lines.sort.uniq
+ gemfile_contents = [
+ "eval_gemfile \"#{File.join(ws.dot_autoproj_dir, 'autoproj', 'Gemfile')}\"",
+ *gemfile_lines
+ ].join("\n")
+
FileUtils.mkdir_p root_dir
- File.open(gemfile_path, 'w') do |io|
- io.puts "eval_gemfile \"#{File.join(ws.dot_autoproj_dir, 'autoproj', 'Gemfile')}\""
- gemfiles.each do |gemfile|
- io.puts File.read(gemfile)
+ if updated = (!File.exist?(gemfile_path) || File.read(gemfile_path) != gemfile_contents)
+ File.open(gemfile_path, 'w') do |io|
+ io.puts gemfile_contents
end
- io.puts gems
end
options = Array.new
if ws.config.private_gems?
options << "--path" << ws.config.gems_gem_home
end
binstubs_path = File.join(root_dir, 'bin')
- self.class.run_bundler_install ws, gemfile_path, *options,
- binstubs: binstubs_path
+ if updated || !install_only || !File.file?("#{gemfile_path}.lock")
+ self.class.run_bundler_install ws, gemfile_path, *options,
+ binstubs: binstubs_path
+ end
if bundle_rubylib = discover_bundle_rubylib
update_env_rubylib(bundle_rubylib)
else
raise NotCleanState, "bundler executed successfully, but the result was not in a clean state"