Skip to content

Commit

Permalink
Merge pull request #192 from bdunne/update_lockfiles
Browse files Browse the repository at this point in the history
Update lockfiles
  • Loading branch information
Fryguy authored Nov 10, 2021
2 parents a36bd06 + 2d9f073 commit 2fd2cdb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions bin/generate_core_lockfile.rb
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!"

0 comments on commit 2fd2cdb

Please sign in to comment.