-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from bdunne/update_lockfiles
Update lockfiles
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'bundler' | ||
ENV["BUNDLE_GEMFILE"] = "/tmp/lock_generator/Gemfile" | ||
|
||
# Set up working directory | ||
require 'fileutils' | ||
FileUtils.mkdir_p("/tmp/lock_generator/bundler.d") | ||
FileUtils.cp("/mnt/Gemfile", "/tmp/lock_generator/") | ||
FileUtils.cp("/mnt/Gemfile.release.rb", "/tmp/lock_generator/bundler.d/") if File.file?("/mnt/Gemfile.release.rb") | ||
branch = Bundler.load.dependencies.detect { |i| i.name == "manageiq-api" }.branch | ||
puts "Bundling for branch: #{branch}..." | ||
exit $?.exitstatus unless system("git clone --branch #{branch} --depth 1 https://github.com/ManageIQ/manageiq-appliance.git /tmp/manageiq-appliance") | ||
FileUtils.cp("/tmp/manageiq-appliance/manageiq-appliance-dependencies.rb", "/tmp/lock_generator/bundler.d/") | ||
|
||
# Generate Gemfile.lock | ||
exit $?.exitstatus unless system({"APPLIANCE" => "true", "BUNDLE_GEMFILE" => ENV["BUNDLE_GEMFILE"]}, "bundle update --jobs=8 --retry=3") | ||
|
||
# Generate the lockfiles | ||
p = Bundler::LockfileParser.new(Bundler.read_file("#{ENV["BUNDLE_GEMFILE"]}.lock")) | ||
lock_contents = p.specs.each_with_object("") do |gem, lock| | ||
next if gem.source.kind_of?(Bundler::Source::Git) | ||
lock << "ensure_gem \"#{gem.name}\", \"=#{gem.version}\"\n" | ||
end | ||
|
||
# Copy results back to the mounted manageiq repo | ||
File.write("/mnt/bundler.d/Gemfile.release.rb", lock_contents) | ||
FileUtils.cp("#{ENV["BUNDLE_GEMFILE"]}.lock", "/mnt/Gemfile.lock.release") | ||
|
||
puts "Complete!" |