diff --git a/habitat/plan.sh b/habitat/plan.sh index 399b1cad7..3e7f1fc48 100644 --- a/habitat/plan.sh +++ b/habitat/plan.sh @@ -78,6 +78,7 @@ do_build() { build_line "Installing gem dependencies ..." bundle install --jobs=3 --retry=3 build_line "Installing gems from git repos properly ..." + ruby ./post-bundle-install.rb build_line "Installing this project's gems ..." bundle exec rake install:local gem install chef-utils chef-config appbundler aruba diff --git a/post-bundle-install.rb b/post-bundle-install.rb new file mode 100644 index 000000000..aef6ddd3c --- /dev/null +++ b/post-bundle-install.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby + +gem_home = Gem.paths.home + +puts "fixing bundle installed gems in #{gem_home}" + +# Install gems from git repos. This makes the assumption that there is a .gemspec and +# you can simply gem build + gem install the resulting gem, so nothing fancy. This does not use +# rake install since we need --conservative --minimal-deps in order to not install duplicate gems. +# +# +puts "gem path #{gem_home}" + +Dir["#{gem_home}/bundler/gems/*"].each do |gempath| + puts "#{gempath}" + matches = File.basename(gempath).match(/.*-[A-Fa-f0-9]{12}/) + next unless matches + gem_name = File.basename(Dir["#{gempath}/*.gemspec"].first, ".gemspec") + # FIXME: should strip any valid ruby platform off of the gem_name if it matches + + next unless gem_name + + puts "re-installing #{gem_name}..." + + Dir.chdir(gempath) do + system("gem build #{gem_name}.gemspec") or raise "gem build failed" + system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise "gem install failed" + end + +end