bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

Building with Bundler and custom gem path #90

Closed mlafeldt closed 10 years ago

mlafeldt commented 10 years ago

When installing fpm-cookery using bundle install --path PATH, Ruby packages build with that version will also be installed to PATH.

e.g.

$ cat Gemfile
source 'https://rubygems.org'
gem 'fpm-cookery'
$ bundle install --path /tmp/gems
$ bundle exec fpm-cook

results in:

$ dpkg -c /home/vagrant/hiera-aws/pkg/rubygem-hiera-aws_0.5.0-0_all.deb
drwx------ 0/0               0 2014-06-14 10:17 ./
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/cache/
-rw-r--r-- 0/0           16896 2014-06-14 10:17 ./tmp/gems/ruby/1.8/cache/hiera-aws-0.5.0.gem
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/doc/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/specifications/
-rw-r--r-- 0/0            1827 2014-06-14 10:17 ./tmp/gems/ruby/1.8/specifications/hiera-aws-0.5.0.gemspec
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/
-rw-rw-r-- 0/0            5317 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/README.md
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/spec/
-rw-rw-r-- 0/0            2271 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/spec/aws_base_spec.rb
-rw-rw-r-- 0/0            5270 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/spec/aws_rds_spec.rb
-rw-rw-r-- 0/0             100 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/spec/spec_helper.rb
-rw-rw-r-- 0/0            2590 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/spec/aws_backend_spec.rb
-rw-rw-r-- 0/0           10860 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/spec/aws_elasticache_spec.rb
-rw-rw-r-- 0/0            1159 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/hiera-aws.gemspec
-rw-rw-r-- 0/0             886 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/CHANGELOG.md
-rw-rw-r-- 0/0           11358 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/LICENSE
-rw-rw-r-- 0/0             288 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/.rubocop.yml
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/
-rw-rw-r-- 0/0            2181 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/aws_backend.rb
drwxr-xr-x 0/0               0 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/aws/
-rw-rw-r-- 0/0            4163 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/aws/elasticache.rb
-rw-rw-r-- 0/0             118 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/aws/version.rb
-rw-rw-r-- 0/0            2206 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/aws/rds.rb
-rw-rw-r-- 0/0            1401 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/lib/hiera/backend/aws/base.rb
-rw-rw-r-- 0/0             154 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/.gitignore
-rw-rw-r-- 0/0             410 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/Rakefile
-rw-rw-r-- 0/0             120 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/Gemfile
-rw-rw-r-- 0/0             129 2014-06-14 10:17 ./tmp/gems/ruby/1.8/gems/hiera-aws-0.5.0/.travis.yml

Any way I can fix this to still install to e.g. /var/lib/gems/1.8?

PS: I'm installing gems to /tmp to work around a problem with bundler + sudo + git-based gems.

bernd commented 10 years ago

Thanks for the report. The problem should be fixed by 91b09ea. Can you please test again if it works for you?

mlafeldt commented 10 years ago

I can confirm that your change fixes the issue. Thanks!

As always, I'm looking forward to a new release. :)

mlafeldt commented 10 years ago

@bernd Just noticed that your change also removes the ability to "fix" the gem path.

For example, we're doing something like this so that gems can be found under Debian:

# Make sure gem path matches target system so that system Ruby finds our gems.
ENV["GEM_HOME"] = "/var/lib/gems/1.8"

class HieraAwsGem < FPM::Cookery::RubyGemRecipe
  name       "hiera-aws"
  version    "0.5.0"
  revision   0
  maintainer "Mathias Lafeldt <mathias.lafeldt@jimdo.com>"

  chain_package true
  chain_recipes %w(aws-sdk json nokogiri uuidtools)
end

Is there a different way to do this now? I hope so; otherwise, we've got a problem.

bernd commented 10 years ago

Can you try with b9fb6c1 and the following recipe again?

class HieraAwsGem < FPM::Cookery::RubyGemRecipe
  name       "hiera-aws"
  version    "0.5.0"
  revision   0
  maintainer "Mathias Lafeldt <mathias.lafeldt@jimdo.com>"

  # Make sure gem path matches target system so that system Ruby finds our gems.
  environment['GEM_HOME'] = '/var/lib/gems/1.8'

  chain_package true
  chain_recipes %w(aws-sdk json nokogiri uuidtools)
end
mlafeldt commented 10 years ago

Yes, that appears to work. Chained recipes also inherit the correct environment. Awesome!

bernd commented 10 years ago

Cool! Thanks for testing! :)

I'm going to cut a release soon.

bernd commented 10 years ago

Version 0.25.0 has been released to rubygems.

mlafeldt commented 10 years ago

:shipit: