diff options
-rw-r--r-- | Gemfile | 17 | ||||
-rwxr-xr-x | tasks/bin/bundle-platform | 8 | ||||
-rw-r--r-- | tasks/bundle_util.rb | 20 |
3 files changed, 30 insertions, 15 deletions
@@ -4,17 +4,12 @@ extend GemfileUtil source "https://rubygems.org" -# Pick the gemspec for our platform -gemspec_name = "chef" -Dir.glob("chef-*.gemspec").each do |gemspec_filename| - gemspec_filename =~ /^chef-(.+).gemspec/ - gemspec_platform = $1 - if Gem::Platform.match(Gem::Platform.new(gemspec_platform)) - Bundler.ui.info "Using gemspec #{gemspec_filename} for current platform." - gemspec_name = "chef-#{gemspec_platform}" - end -end -gemspec name: gemspec_name +# Note we do not use the gemspec DSL which restricts to the +# gemspec for the current platform and filters out other platforms +# during a bundle lock operation. We actually want dependencies from +# both of our gemspecs. Also note this this mimics gemspec behavior +# of bundler versions prior to 1.12.0 (https://github.com/bundler/bundler/commit/193a14fe5e0d56294c7b370a0e59f93b2c216eed) +gem "chef", path: "." gem "chef-config", path: File.expand_path("../chef-config", __FILE__) if File.exist?(File.expand_path("../chef-config", __FILE__)) # Ensure that we can always install rake, regardless of gem groups diff --git a/tasks/bin/bundle-platform b/tasks/bin/bundle-platform index 7c77393cb1..10d9bb2b3d 100755 --- a/tasks/bin/bundle-platform +++ b/tasks/bin/bundle-platform @@ -1,10 +1,14 @@ #!/usr/bin/env ruby platforms = ARGV.shift +platforms = platforms.split(" ").map { |p| Gem::Platform.new(p) } +Gem::Platform.instance_eval { @local = platforms.last } old_platforms = Gem.platforms -Gem.platforms = platforms.split(" ").map { |p| Gem::Platform.new(p) } +Gem.platforms = platforms puts "bundle-platform set Gem.platforms to #{Gem.platforms.map { |p| p.to_s }} (was #{old_platforms.map { |p| p.to_s } })" +desired_version = ARGV.shift.delete("_", "") + # The rest of this is a normal bundler binstub require "pathname" ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", @@ -12,4 +16,4 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", require "rubygems" -load Gem.bin_path("bundler", "bundle") +load Gem.bin_path("bundler", "bundle", desired_version) diff --git a/tasks/bundle_util.rb b/tasks/bundle_util.rb index a057db858a..67647dd4f0 100644 --- a/tasks/bundle_util.rb +++ b/tasks/bundle_util.rb @@ -57,7 +57,14 @@ module BundleUtil # Run the bundle command ruby_platforms = platform ? PLATFORMS[platform].join(" ") : "ruby" - cmd = Shellwords.join([Gem.ruby, "-S", bundle_platform, ruby_platforms, *args]) + cmd = Shellwords.join([ + Gem.ruby, + "-S", + bundle_platform, + ruby_platforms, + "_#{desired_bundler_version}_", + *args, + ]) puts "#{prefix}#{Shellwords.join(["bundle", *args])}#{platform ? " for #{platform} platform" : ""}:" with_gemfile(gemfile) do puts "#{prefix}BUNDLE_GEMFILE=#{gemfile}" @@ -65,7 +72,7 @@ module BundleUtil if extract_output `#{cmd}` else - unless system(bundle_platform, ruby_platforms, *args) + unless system(bundle_platform, ruby_platforms, "_#{desired_bundler_version}_", *args) raise "#{bundle_platform} failed: exit code #{$?}" end end @@ -91,4 +98,13 @@ module BundleUtil def platforms PLATFORMS.keys end + + def desired_bundler_version + @desired_bundler_version ||= begin + omnibus_overrides = File.join(project_root, "omnibus_overrides.rb") + File.readlines(omnibus_overrides).each do |line| + return $1 if line =~ /^override :bundler, version: "(.+)"$/ + end + end + end end |