diff options
author | John Keiser <john@johnkeiser.com> | 2016-04-15 12:10:40 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-04-18 14:21:02 -0700 |
commit | ea2593fe58037739c5c2ada517e3d988dec290ff (patch) | |
tree | 55142ceaef43080201a8d9e54f79868368241f60 /omnibus/files | |
parent | bbc1d6ebccbd7f22fea72a9c2b76ef19f3b5beb3 (diff) | |
download | chef-ea2593fe58037739c5c2ada517e3d988dec290ff.tar.gz |
Make gemfile_util capable of copying groups over
Diffstat (limited to 'omnibus/files')
-rw-r--r-- | omnibus/files/chef-appbundle/build-chef-appbundle.rb | 9 | ||||
-rw-r--r-- | omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb | 21 | ||||
-rw-r--r-- | omnibus/files/chef/build-chef.rb | 15 |
3 files changed, 24 insertions, 21 deletions
diff --git a/omnibus/files/chef-appbundle/build-chef-appbundle.rb b/omnibus/files/chef-appbundle/build-chef-appbundle.rb index 97a94ef5a7..5e4a6afdfd 100644 --- a/omnibus/files/chef-appbundle/build-chef-appbundle.rb +++ b/omnibus/files/chef-appbundle/build-chef-appbundle.rb @@ -19,12 +19,12 @@ module BuildChefAppbundle # times in the file. # distribution_gemfile = Pathname(shared_gemfile).relative_path_from(Pathname(installed_gemfile)).to_s - gemfile_text = IO.read(installed_gemfile) - gemfile_text << <<-EOM.gsub(/^\s+/, "") + gemfile_text = <<-EOM.gsub(/^\s+/, "") # Lock gems that are part of the distribution distribution_gemfile = File.expand_path(#{distribution_gemfile.inspect}, __FILE__) instance_eval(IO.read(distribution_gemfile), distribution_gemfile) EOM + gemfile_text << IO.read(installed_gemfile) create_file(installed_gemfile) { gemfile_text } # Remove the gemfile.lock @@ -50,7 +50,10 @@ module BuildChefAppbundle # "test", "changelog" and "guard" come from berkshelf, "maintenance" comes from chef # "tools" and "integration" come from inspec shellout!("#{bundle_bin} config --local without #{without_groups.join(":")}", env: env, cwd: installed_path) - shellout!("#{bundle_bin} config --local frozen 1") + # TODO Windows cannot be frozen, because Bundler doesn't understand platform-specific + # versions. However, on Windows we have explicit version pins for most things, so + # we will *probably* get the exact versions of everything we want. + shellout!("#{bundle_bin} config --local frozen 1") unless windows? shellout!("#{bundle_bin} check", env: env, cwd: installed_path) diff --git a/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb b/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb index ee096b8ed9..5d77ebf7f2 100644 --- a/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb +++ b/omnibus/files/chef-gem/build-chef-gem/gem-install-software-def.rb @@ -80,7 +80,7 @@ module BuildChefGem end def lockfile_path - @lockfile_path ||= "#{gemfile_path}.lock" + "#{gemfile_path}.lock" end def gem_name @@ -98,16 +98,19 @@ module BuildChefGem def gem_metadata @gem_metadata ||= begin - selected = GemfileUtil.select_gems(gemfile_path, without_groups: without_groups) - result = GemfileUtil.locked_gems(lockfile_path, selected)[gem_name] + bundle = GemfileUtil::Bundle.parse(gemfile_path, lockfile_path) + result = bundle.gems[gem_name] if result - log.info(software.name) { "Using #{gem_name} version #{result[:version]} from #{gemfile_path}" } - result - elsif GemfileUtil.locked_gems(lockfile_path, GemfileUtil.select_gems(gemfile_path))[gem_name] - log.info(software.name) { "#{gem_name} not loaded from #{gemfile_path} because it was only in groups #{without_groups.join(", ")}, skipping" } - nil + if bundle.select_gems(without_groups: without_groups).include?(gem_name) + log.info(software.name) { "Using #{gem_name} version #{result[:version]} from #{gemfile_path}" } + result + else + log.info(software.name) { "#{gem_name} not loaded from #{gemfile_path} because it was only in groups #{without_groups.join(", ")}. Skipping ..." } + nil + end else - raise "#{gem_name} not found in #{gemfile_path} or #{lockfile_path}" + log.info(software.name) { "#{gem_name} was not found in #{lockfile_path}. Skipping ..." } + nil end end end diff --git a/omnibus/files/chef/build-chef.rb b/omnibus/files/chef/build-chef.rb index 21bd6c2250..dd2f76e049 100644 --- a/omnibus/files/chef/build-chef.rb +++ b/omnibus/files/chef/build-chef.rb @@ -9,12 +9,6 @@ module BuildChef include BuildChefGem def create_bundle_config(gemfile, without: without_groups, retries: nil, jobs: nil, frozen: nil) - if without - without = without.dup - # no_aix, no_windows groups - without << "no_#{Omnibus::Ohai["platform"]}" - end - bundle_config = File.expand_path("../.bundle/config", gemfile) block "Put build config into #{bundle_config}: #{ { without: without, retries: retries, jobs: jobs, frozen: frozen } }" do @@ -84,7 +78,7 @@ module BuildChef # Emit blank line to separate different tasks log.info(log_key) { "" } log.info(log_key) { "Properly installing git or path sourced gem #{gem_path} using rake install" } - shellout!("#{bundle_bin} exec #{rake_bin} install", env: chef_env, cwd: gem_path) + shellout!("#{bundle_bin} exec #{rake_bin} install --trace", env: chef_env, cwd: gem_path) end end end @@ -113,7 +107,7 @@ module BuildChef end # Find the installed chef gem by looking for lib/chef.rb - chef_gem = File.expand_path("../..", shellout!("#{gem_bin} which chef").stdout.chomp) + chef_gem = File.expand_path("../..", shellout!("#{gem_bin} which chef", env: chef_env).stdout.chomp) # Figure out the path to gemfile_util from there gemfile_util = Pathname.new(File.join(chef_gem, "tasks", "gemfile_util")) gemfile_util = gemfile_util.relative_path_from(Pathname.new(shared_gemfile).dirname) @@ -136,7 +130,10 @@ module BuildChef bundle "lock", env: shared_gemfile_env # Freeze the location's Gemfile.lock. - create_bundle_config(shared_gemfile, frozen: true) + # TODO Windows cannot be frozen, because Bundler doesn't understand platform-specific + # versions. However, on Windows we have explicit version pins for most things, so + # we will *probably* get the exact versions of everything we want. + create_bundle_config(shared_gemfile, frozen: !windows?) # Clear the now-unnecessary git caches, cached gems, and git-checked-out gems block "Delete bundler git cache and git installs" do |