Skip to content

Commit

Permalink
Install git gem into gems dir in hab
Browse files Browse the repository at this point in the history
Signed-off-by: nitin sanghi <[email protected]>
  • Loading branch information
sanghinitin committed Nov 6, 2024
1 parent c57c55c commit fa118b5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions post-bundle-install.rb
Original file line number Diff line number Diff line change
@@ -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 <gem_name>.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

Check failure on line 17 in post-bundle-install.rb

View workflow job for this annotation

GitHub Actions / Chefstyle on Ruby (3.3)

[Correctable] Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
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

Check failure on line 29 in post-bundle-install.rb

View workflow job for this annotation

GitHub Actions / Chefstyle on Ruby (3.3)

[Correctable] Layout/TrailingWhitespace: Trailing whitespace detected.
end

0 comments on commit fa118b5

Please sign in to comment.