Skip to content

Commit

Permalink
Merge branch 'master' into phlipper/master
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed Mar 29, 2011
2 parents 97b6f7f + 3462160 commit 6606102
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 99 deletions.
30 changes: 15 additions & 15 deletions README.md
Expand Up @@ -83,26 +83,26 @@ An example used on a build box might be:

The default is an empty hash.

## `revision`
## `branch`

A specific git SHA hash to use when installing system-wide. You may want to
use a specific git SHA hash version of RVM to prevent differences in
deployment from one day to the next (RVM head moves pretty darn quickly):
A specific git branch to use when installing system-wide. For example:

node[:rvm][:revision] = "38535b53b4b5727946e75c6bb10ea074a431db81"
node[:rvm][:branch] = "crazy"

The default is `HEAD`.
The default is `nil` which corresponds to the master branch.

## `version`

A specific tagged version to use when installing system-wide. You may want to
use a specific git SHA hash version of RVM to prevent differences in
deployment from one day to the next (RVM head moves pretty darn quickly):
A specific tagged version to use when installing system-wide. This value is
passed directly to the `rvm-installer` script and current valid values are:
`head` (the default, last git commit), `latest` (last tagged release version)
and a specific tagged version of the form `1.2.3`. You may want to use a
specific version of RVM to prevent differences in deployment from one day
to the next (RVM head moves pretty darn quickly):

node[:rvm][:version] = "1.2.5"
node[:rvm][:version] = "1.5.3"

The default is `nil`. **Note:** setting this attribute will win over any value
set in the `revision` attribute.
The default is `nil`, which corresponds to RVM `head`.

## `upgrade`

Expand All @@ -121,10 +121,10 @@ currently 3 valid values:
The path prefix to RVM in a system-wide installation. The default is
`/usr/local/rvm`.

## `system_installer_url`
## `installer_url`

The URL to install RVM system-wide. The default is
`http://bit.ly/rvm-install-system-wide`.
The URL that provides the RVM installer. The default is
`http://rvm.beginrescueend.com/install/rvm`.

## `group_users`

Expand Down
6 changes: 3 additions & 3 deletions attributes/default.rb
Expand Up @@ -23,10 +23,10 @@
default[:rvm][:group_users] = []
default[:rvm][:rvmrc] = Hash.new

default[:rvm][:system_installer_url] = "http://bit.ly/rvm-install-system-wide"
default[:rvm][:installer_url] = "http://rvm.beginrescueend.com/install/rvm"

default[:rvm][:revision] = "HEAD"
default[:rvm][:version] = nil
default[:rvm][:branch] = nil
default[:rvm][:version] = nil

default[:rvm][:upgrade] = "none"

Expand Down
24 changes: 16 additions & 8 deletions libraries/helpers.rb
Expand Up @@ -253,9 +253,13 @@ def normalize_ruby_string(ruby_string)
# @param [String, #to_s] the shell command to be wrapped
# @return [String] the command wrapped in RVM-initialized bash command
def rvm_wrap_cmd(cmd)
profile = if ::File.directory?("/etc/profile.d")
"/etc/profile.d/rvm.sh"
else
"/etc/profile"
end
return <<-WRAP.sub(/^ {4}/, '')
bash -c "source #{::File.dirname(node[:rvm][:root_path])}/lib/rvm && \
#{cmd.gsub(/"/, '\"')}"
bash -c "source #{profile} && #{cmd.gsub(/"/, '\"')}"
WRAP
end

Expand All @@ -271,16 +275,20 @@ def install_ruby_dependencies(rubie)
pkgs = %w{ build-essential bison openssl libreadline6 libreadline6-dev
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0
libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev ssl-cert }
pkgs << %w{ git-core subversion autoconf } if rubie =~ /^ruby-head$/
pkgs += %w{ git-core subversion autoconf } if rubie =~ /^ruby-head$/
when "suse"
pkgs = %w{ gcc-c++ patch readline readline-devel zlib zlib-devel
libffi-devel openssl-devel sqlite3-devel libxml2-devel
libxslt-devel }
pkgs << %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
pkgs = %w{ gcc-c++ patch zlib zlib-devel libffi-devel
sqlite3-devel libxml2-devel libxslt-devel }
if node.platform_version.to_f >= 11.0
pkgs += %w{ libreadline5 readline-devel libopenssl-devel }
else
pkgs += %w{ readline readline-devel openssl-devel }
end
pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
when "centos","redhat","fedora"
pkgs = %w{ gcc-c++ patch readline readline-devel zlib zlib-devel
libyaml-devel libffi-devel openssl-devel }
pkgs << %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
pkgs += %w{ git subversion autoconf } if rubie =~ /^ruby-head$/
end
elsif rubie =~ /^jruby/
# TODO: need to figure out how to pull in java recipe only when needed. For
Expand Down
20 changes: 11 additions & 9 deletions metadata.rb
Expand Up @@ -26,6 +26,7 @@
attribute "rvm/global_gems",
:display_name => "Global gems to be installed in all RVM rubies",
:description => "A list of gem hashes to be installed into the *global* gemset in each installed RVM ruby. The RVM global.gems files will be added to and all installed rubies will be iterated over to ensure full installation coverage.",
:type => "array",
:default => [ { :name => "bundler" } ]

attribute "rvm/gems",
Expand All @@ -40,14 +41,14 @@
:type => "hash",
:default => Hash.new

attribute "rvm/revision",
:display_name => "A specific git SHA hash to use when installing system-wide.",
:description => "A specific git SHA hash to use when installing system-wide. You may want to use a specific git SHA hash version of RVM to prevent differences in deployment from one day to the next (RVM head moves pretty darn quickly)",
:default => "HEAD"
attribute "rvm/branch",
:display_name => "A specific git branch to use when installing system-wide.",
:description => "A specific git branch to use when installing system-wide.",
:default => "nil"

attribute "rvm/version",
:display_name => "A specific tagged version to use when installing system-wide.",
:description => "A specific tagged version to use when installing system-wide. You may want to use a specific git SHA hash version of RVM to prevent differences in deployment from one day to the next (RVM head moves pretty darn quickly)",
:description => "A specific tagged version to use when installing system-wide. This value is passed directly to the `rvm-installer` script and current valid values are: `head` (the default, last git commit), `latest` (last tagged release version) and a specific tagged version of the form `1.2.3`. You may want to use a specific version of RVM to prevent differences in deployment from one day to the next (RVM head moves pretty darn quickly).",
:default => "nil"

attribute "rvm/upgrade",
Expand All @@ -60,12 +61,13 @@
:description => "Root path for system-wide RVM installation",
:default => "/usr/local/rvm"

attribute "rvm/system_installer_url",
:display_name => "The URL to install RVM system-wide.",
:description => "The URL to install RVM system-wide.",
:default => "http://bit.ly/rvm-install-system-wide"
attribute "rvm/installer_url",
:display_name => "The URL that provides the RVM installer.",
:description => "The URL that provides the RVM installer.",
:default => "http://rvm.beginrescueend.com/install/rvm"

attribute "rvm/group_users",
:display_name => "Additional users in rvm group",
:description => "Additional users in rvm group that can manage rvm in a system-wide installation.",
:type => "array",
:default => []
10 changes: 8 additions & 2 deletions providers/shell.rb
Expand Up @@ -36,11 +36,17 @@
# @param [Symbol] action to be performed with gem_package provider
# @param [optional, String, #to_s] the fully qualifed rvm string
def script_wrapper(exec_action, ruby_string=new_resource.ruby_string)
profile = if ::File.directory?("/etc/profile.d")
"/etc/profile.d/rvm.sh"
else
"/etc/profile"
end

script_code = <<-CODE
if [ -s "${HOME}/.rvm/scripts/rvm" ]; then
source "${HOME}/.rvm/scripts/rvm"
elif [ -s "#{::File.dirname(node[:rvm][:root_path])}/lib/rvm" ]; then
source "#{::File.dirname(node[:rvm][:root_path])}/lib/rvm"
elif [ -s "#{profile}" ]; then
source "#{profile}"
fi
rvm use #{ruby_string}
Expand Down
46 changes: 15 additions & 31 deletions recipes/system.rb
Expand Up @@ -2,7 +2,7 @@
# Cookbook Name:: rvm
# Recipe:: system
#
# Copyright 2010, Fletcher Nichol
# Copyright 2010, 2011 Fletcher Nichol
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,23 +21,12 @@
# - http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby/
# - http://github.com/denimboy/xprdev/blob/master/rvm/recipes/default.rb

if node[:rvm][:version] && node[:rvm][:revision] == "HEAD"
# rvm/version overrides the rvm/revision default
install_command = <<-CODE
bash -c "bash <( curl -L #{node[:rvm][:system_installer_url]} ) \
--version '#{node[:rvm][:version]}'"
CODE
elsif node[:rvm][:revision] == "HEAD"
# rvm/version == HEAD runs the default installer
install_command = <<-CODE
bash -c "bash < <( curl -L #{node[:rvm][:system_installer_url]} )"
CODE
else
# rvm/revision gets used
install_command = <<-CODE
bash -c "bash <( curl -L #{node[:rvm][:system_installer_url]} ) \
--revision '#{node[:rvm][:revision]}'"
CODE
script_flags = ""
if node[:rvm][:version]
script_flags += " --version #{node[:rvm][:version]}"
end
if node[:rvm][:branch]
script_flags += " --branch #{node[:rvm][:branch]}"
end

pkgs = %w{ sed grep tar gzip bzip2 bash curl }
Expand All @@ -52,28 +41,23 @@
package pkg
end

template "/etc/profile.d/rvm.sh" do
source "rvm.sh.erb"
owner "root"
group "root"
mode "0644"
end

group "rvm" do
members node[:rvm][:group_users]
append true
end
#group "rvm" do
# members node[:rvm][:group_users]
# append true
#end

execute "install system-wide RVM" do
user "root"
command install_command
command <<-CODE
bash -c "bash <( curl -LB #{node[:rvm][:installer_url]} )#{script_flags}"
CODE
not_if rvm_wrap_cmd(%{type rvm | head -1 | grep -q '^rvm is a function$'})
end

template "/etc/rvmrc" do
source "rvmrc.erb"
owner "root"
group "root"
group "rvm"
mode "0644"
end

Expand Down
3 changes: 1 addition & 2 deletions resources/default_ruby.rb
Expand Up @@ -23,8 +23,7 @@

attribute :ruby_string, :kind_of => String, :name_attribute => true

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :create
@command = name
end
3 changes: 1 addition & 2 deletions resources/environment.rb
Expand Up @@ -23,8 +23,7 @@

attribute :ruby_string, :kind_of => String, :name_attribute => true

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :create
@command = name
end
3 changes: 1 addition & 2 deletions resources/gem.rb
Expand Up @@ -28,8 +28,7 @@
attribute :options, :kind_of => Hash
attribute :version, :kind_of => String

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :install
@command = name
end
3 changes: 1 addition & 2 deletions resources/gemset.rb
Expand Up @@ -24,8 +24,7 @@
attribute :gemset, :kind_of => String, :name_attribute => true
attribute :ruby_string, :kind_of => String, :regex => /^[^@]+$/

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :create
@command = name
end
3 changes: 1 addition & 2 deletions resources/ruby.rb
Expand Up @@ -23,8 +23,7 @@

attribute :ruby_string, :kind_of => String, :name_attribute => true

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :install
@command = name
end
3 changes: 1 addition & 2 deletions resources/shell.rb
Expand Up @@ -34,8 +34,7 @@
attribute :user, :kind_of => String
attribute :umask, :kind_of => String

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :run
@command = name
end
3 changes: 1 addition & 2 deletions resources/wrapper.rb
Expand Up @@ -26,8 +26,7 @@
attribute :binary, :kind_of => String
attribute :binaries, :kind_of => Array

def initialize(name, run_context=nil)
def initialize(*args)
super
@action = :create
@command = name
end
10 changes: 0 additions & 10 deletions templates/default/rvm.sh.erb

This file was deleted.

9 changes: 2 additions & 7 deletions templates/default/rvmrc.erb
Expand Up @@ -3,13 +3,8 @@
# Generated by Chef for <%= node[:fqdn] %>
# Local modifications will be overwritten.
#
# Setup default configuration for rvm.
# If an rvm install exists in the home directory, don't load this.'
if [[ ! -s "$HOME/.rvm/scripts/rvm" ]]; then
umask g+w
export rvm_selfcontained=0
export rvm_prefix="/usr/local/"
fi
umask g+w
export rvm_path="<%= node[:rvm][:root_path] %>"

<% node[:rvm][:rvmrc].each_pair do |k,v| -%>
<%= k %>=<%= v %>
Expand Down

0 comments on commit 6606102

Please sign in to comment.