Permalink
Browse files

Merge remote-tracking branch 'substantial/support-ruby-patches' into …

…ruby-patches
  • Loading branch information...
2 parents 7422107 + fd908f3 commit 91835bf244babf92a5c82284ced2705363b47f0e @fnichol fnichol committed Apr 15, 2012
View
@@ -244,9 +244,17 @@ set, use an empty string (`""`) or a value of `"system"`.
A list of additional RVM system-wide Rubies to be built and installed. This
list does not need to necessarily contain your default Ruby as the
-`rvm_default_ruby` resource will take care of installing itself. For example:
-
- node['rvm']['rubies'] = [ "ree-1.8.7", "jruby" ]
+`rvm_default_ruby` resource will take care of installing itself. You may also
+include patch info. For example:
+
+ node['rvm']['rubies'] = [
+ "ree-1.8.7",
+ "jruby",
+ {
+ :version => '1.9.3-p125-perf',
+ :patch => "falcon"
+ }
+ ]
The default is an empty array: `[]`.
@@ -363,7 +371,14 @@ The hash keys correspond to the default/system equivalents. For example:
{ 'user' => 'jenkins',
'version' => '1.7.0',
'default_ruby' => 'jruby-1.6.3',
- 'rubies' => ['1.8.7', '1.9.2', 'ree', 'rbx'],
+ 'rubies' => [
+ "ree-1.8.7",
+ "jruby",
+ {
+ :version => '1.9.3-p125-perf',
+ :patch => "falcon"
+ }
+ ],
'rvmrc' => {
'rvm_project_rvmrc' => 1,
'rvm_gemset_create_on_use_flag' => 1,
@@ -152,7 +152,16 @@ def rvmrc_template(opts = {})
def install_rubies(opts = {})
# install additional rubies
opts[:rubies].each do |rubie|
- rvm_ruby rubie do
+ if rubie.is_a?(Hash)
+ ruby = rubie.fetch("version")
+ ruby_patch = rubie.fetch("patch")
+ else
+ ruby = rubie
+ ruby_patch = nil
+ end
+
+ rvm_ruby ruby do
+ patch ruby_patch
user opts[:user]
end
end
@@ -48,7 +48,7 @@ def update_installed_rubies
# @param [String, #to_s] the RVM Ruby string
# @return [Boolean] is this Ruby installed?
def ruby_installed?(rubie)
- ! installed_rubies.select { |r| r.start_with?(rubie) }.empty?
+ ! installed_rubies.select { |r| r.end_with?(rubie) }.empty?
end
##
@@ -50,9 +50,11 @@ def select_gemset(ruby_string)
# @param [String, #to_s] an RVM Ruby string
# @param [String] a specific user RVM or nil for system-wide
# @return [String] a fully qualified RVM Ruby string
- def normalize_ruby_string(ruby_string, user = new_resource.user)
+ def normalize_ruby_string(ruby_string, user = new_resource.user, patch = new_resource.patch)
return "system" if ruby_string == "system"
- StringCache.fetch(ruby_string, user)
+ fetched_ruby_string = StringCache.fetch(ruby_string, user)
+ return "#{fetched_ruby_string} --patch #{patch}" if patch
+ fetched_ruby_string
end
end
end
View
@@ -9,7 +9,7 @@
recipe "rvm::system_install", "Installs the RVM codebase system-wide (that is, into /usr/local/rvm). This recipe includes *default*. Use this recipe by itself if you want RVM installed system-wide but want to handle installing Rubies, invoking LWRPs, etc.."
recipe "rvm::system", "Installs the RVM codebase system-wide (that is, into /usr/local/rvm) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *system_install*. Use this recipe by itself if you want RVM system-wide with Rubies installed, etc."
recipe "rvm::user_install", "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash). This recipe includes *default*. Use this recipe by itself if you want RVM installed for specific users in isolation but want each user to handle installing Rubies, invoking LWRPs, etc."
-recipe "rvm:user", "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *user_install*. Use this recipe by itself if you want RVM installed for specific users in isolation with Rubies installed, etc."
+recipe "rvm::user", "Installs the RVM codebase for a list of users (selected from the node['rvm']['user_installs'] hash) and installs Rubies, global gems, and specific gems driven off attribute metadata. This recipe includes *default* and *user_install*. Use this recipe by itself if you want RVM installed for specific users in isolation with Rubies installed, etc."
recipe "rvm::vagrant", "An optional recipe to help if running in a Vagrant virtual machine"
recipe "rvm::gem_package", "An experimental recipe that patches the gem_package resource"
View
@@ -24,14 +24,14 @@
def load_current_resource
@rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string))
- @ruby_string = @rubie
+ @ruby_string = new_resource.ruby_string
@rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user)
end
action :install do
next if skip_ruby?
- if ruby_installed?(@rubie)
+ if ruby_installed?(@ruby_string)
Chef::Log.debug("rvm_ruby[#{@rubie}] is already installed, so skipping")
else
install_start = Time.now
View
@@ -19,42 +19,14 @@
include_recipe "rvm::system_install"
-install_rubies = node['rvm']['install_rubies'] == true ||
+perform_install_rubies = node['rvm']['install_rubies'] == true ||
node['rvm']['install_rubies'] == "true"
-if install_rubies
- # install additional rubies
- node['rvm']['rubies'].each do |rubie|
- rvm_ruby rubie
- end
-
- # set a default ruby
- rvm_default_ruby node['rvm']['default_ruby']
-
- # install global gems
- node['rvm']['global_gems'].each do |gem|
- rvm_global_gem gem[:name] do
- version gem[:version] if gem[:version]
- action gem[:action] if gem[:action]
- options gem[:options] if gem[:options]
- source gem[:source] if gem[:source]
- end
- end
-
- # install additional gems
- node['rvm']['gems'].each_pair do |rstring, gems|
- rvm_environment rstring
-
- gems.each do |gem|
- rvm_gem gem[:name] do
- ruby_string rstring
- version gem[:version] if gem[:version]
- action gem[:action] if gem[:action]
- options gem[:options] if gem[:options]
- source gem[:source] if gem[:source]
- end
- end
- end
+if perform_install_rubies
+ install_rubies :rubies => node['rvm']['rubies'],
+ :default_ruby => node['rvm']['default_ruby'],
+ :global_gems => node['rvm']['global_gems'],
+ :gems => node['rvm']['gems']
end
# add users to rvm group
@@ -23,6 +23,7 @@
attribute :ruby_string, :kind_of => String, :name_attribute => true
attribute :user, :kind_of => String
+attribute :patch, :kind_of => String
def initialize(*args)
super
@@ -23,6 +23,7 @@
attribute :ruby_string, :kind_of => String, :name_attribute => true
attribute :user, :kind_of => String
+attribute :patch, :kind_of => String
def initialize(*args)
super
View
@@ -23,6 +23,7 @@
attribute :ruby_string, :kind_of => String, :name_attribute => true
attribute :user, :kind_of => String
+attribute :patch, :kind_of => String
def initialize(*args)
super

0 comments on commit 91835bf

Please sign in to comment.