File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Author:: Fletcher Nichol (<fnichol@nichol.ca>)
2121Contributors:: Bram Swenson (<bram@craniumisajar.com>)
2222Contributors:: Phil Cohen (http://phlippers.net/)
2323
24- Copyright:: 2010, Fletcher Nichol
24+ Copyright:: 2010, 2011, Fletcher Nichol
2525
2626Licensed under the Apache License, Version 2.0 (the "License");
2727you may not use this file except in compliance with the License.
Original file line number Diff line number Diff line change 1+ #
2+ # Cookbook Name:: rvm
3+ # Attributes:: default
4+ #
5+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6+ #
7+ # Copyright 2010, 2011, Fletcher Nichol
8+ #
9+ # Licensed under the Apache License, Version 2.0 (the "License");
10+ # you may not use this file except in compliance with the License.
11+ # You may obtain a copy of the License at
12+ #
13+ # http://www.apache.org/licenses/LICENSE-2.0
14+ #
15+ # Unless required by applicable law or agreed to in writing, software
16+ # distributed under the License is distributed on an "AS IS" BASIS,
17+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+ # See the License for the specific language governing permissions and
19+ # limitations under the License.
20+ #
21+
122default [ :rvm ] [ :root_path ] = "/usr/local/rvm"
223default [ :rvm ] [ :group_users ] = [ ]
324default [ :rvm ] [ :rvmrc ] = Hash . new
Original file line number Diff line number Diff line change 1212# Licensed under the Apache License, Version 2.0 (the "License");
1313# you may not use this file except in compliance with the License.
1414# You may obtain a copy of the License at
15- #
15+ #
1616# http://www.apache.org/licenses/LICENSE-2.0
17- #
17+ #
1818# Unless required by applicable law or agreed to in writing, software
1919# distributed under the License is distributed on an "AS IS" BASIS,
2020# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Original file line number Diff line number Diff line change 1+ #
2+ # Cookbook Name:: rvm
3+ # Library:: ruby
4+ #
5+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6+ #
7+ # Copyright 2011, Fletcher Nichol
8+ #
9+ # Licensed under the Apache License, Version 2.0 (the "License");
10+ # you may not use this file except in compliance with the License.
11+ # You may obtain a copy of the License at
12+ #
13+ # http://www.apache.org/licenses/LICENSE-2.0
14+ #
15+ # Unless required by applicable law or agreed to in writing, software
16+ # distributed under the License is distributed on an "AS IS" BASIS,
17+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+ # See the License for the specific language governing permissions and
19+ # limitations under the License.
20+ #
21+
22+ begin
23+ require 'rvm'
24+ rescue LoadError
25+ Chef ::Log . warn ( "Missing gem 'rvm'" )
26+ end
27+
28+ ##
29+ # Determines whether or not the given ruby is already installed
30+ #
31+ # @param [String, #to_s] the fully qualified RVM ruby string
32+ # @return [Boolean] is this ruby installed?
33+ def ruby_installed? ( rubie )
34+ RVM . list_strings . include? ( rubie )
35+ end
Original file line number Diff line number Diff line change 1+ #
2+ # Cookbook Name:: rvm
3+ # Provider:: ruby
4+ #
5+ # Author:: Fletcher Nichol <fnichol@nichol.ca>
6+ #
7+ # Copyright 2011, Fletcher Nichol
8+ #
9+ # Licensed under the Apache License, Version 2.0 (the "License");
10+ # you may not use this file except in compliance with the License.
11+ # You may obtain a copy of the License at
12+ #
13+ # http://www.apache.org/licenses/LICENSE-2.0
14+ #
15+ # Unless required by applicable law or agreed to in writing, software
16+ # distributed under the License is distributed on an "AS IS" BASIS,
17+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+ # See the License for the specific language governing permissions and
19+ # limitations under the License.
20+ #
21+
22+ action :install do
23+ rubie = new_resource . ruby_string
24+
25+ if ruby_installed? ( rubie )
26+ Chef ::Log . debug ( "RVM ruby #{ rubie } is already installed, so skipping" )
27+ else
28+ Chef ::Log . info ( "RVM ruby #{ rubie } installation in progress. " +
29+ "This could take awhile..." )
30+
31+ if RVM . install ( rubie )
32+ Chef ::Log . info ( "Successful installation of RVM ruby #{ rubie } " )
33+ else
34+ Chef ::Log . warn ( "Failed to install RVM ruby #{ rubie } . " +
35+ "Check RVM logs here: #{ RVM . path } /log/#{ rubie } " )
36+ end
37+ end
38+ end
Original file line number Diff line number Diff line change 77# Licensed under the Apache License, Version 2.0 (the "License");
88# you may not use this file except in compliance with the License.
99# You may obtain a copy of the License at
10- #
10+ #
1111# http://www.apache.org/licenses/LICENSE-2.0
12- #
12+ #
1313# Unless required by applicable law or agreed to in writing, software
1414# distributed under the License is distributed on an "AS IS" BASIS,
1515# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1616# See the License for the specific language governing permissions and
1717# limitations under the License.
1818#
1919
20+ require 'rubygems/dependency_installer'
21+
22+ # install rvm api gem during chef compile phase
23+ if Gem . source_index . find_name ( "rvm" ) . empty?
24+ Chef ::Log . info ( "Installing RVM gem" )
25+ Gem ::DependencyInstaller . new . install ( "rvm" )
26+ begin
27+ Gem . activate ( "rvm" )
28+ require 'rvm'
29+ rescue LoadError
30+ Chef ::Application . fatal! (
31+ "There was a problem installing and loading the 'rvm' gem." )
32+ end
33+ else
34+ Chef ::Log . debug ( "RVM gem was installed, so installation skipped" )
35+ end
36+
2037include_recipe "rvm::system"
2138include_recipe "rvm::rubies"
2239include_recipe "rvm::default_ruby"
Original file line number Diff line number Diff line change 77# Licensed under the Apache License, Version 2.0 (the "License");
88# you may not use this file except in compliance with the License.
99# You may obtain a copy of the License at
10- #
10+ #
1111# http://www.apache.org/licenses/LICENSE-2.0
12- #
12+ #
1313# Unless required by applicable law or agreed to in writing, software
1414# distributed under the License is distributed on an "AS IS" BASIS,
1515# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Original file line number Diff line number Diff line change 77# Licensed under the Apache License, Version 2.0 (the "License");
88# you may not use this file except in compliance with the License.
99# You may obtain a copy of the License at
10- #
10+ #
1111# http://www.apache.org/licenses/LICENSE-2.0
12- #
12+ #
1313# Unless required by applicable law or agreed to in writing, software
1414# distributed under the License is distributed on an "AS IS" BASIS,
1515# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Original file line number Diff line number Diff line change 22# Cookbook Name:: rvm
33# Recipe:: rubies
44#
5- # Copyright 2010, Fletcher Nichol
5+ # Copyright 2010, 2011, Fletcher Nichol
66#
77# Licensed under the Apache License, Version 2.0 (the "License");
88# you may not use this file except in compliance with the License.
99# You may obtain a copy of the License at
10- #
10+ #
1111# http://www.apache.org/licenses/LICENSE-2.0
12- #
12+ #
1313# Unless required by applicable law or agreed to in writing, software
1414# distributed under the License is distributed on an "AS IS" BASIS,
1515# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4848 package pkg
4949 end
5050
51- bash "install RVM ruby: #{ ruby } " do
52- user "root"
53- code %{source /etc/profile.d/rvm.sh && rvm install #{ ruby } }
54- not_if %{bash -c "source /etc/profile.d/rvm.sh && rvm list strings | grep -q '^#{ ruby } ' >/dev/null"}
55- end
51+ rvm_ruby ruby
5652end
5753
Original file line number Diff line number Diff line change 77# Licensed under the Apache License, Version 2.0 (the "License");
88# you may not use this file except in compliance with the License.
99# You may obtain a copy of the License at
10- #
10+ #
1111# http://www.apache.org/licenses/LICENSE-2.0
12- #
12+ #
1313# Unless required by applicable law or agreed to in writing, software
1414# distributed under the License is distributed on an "AS IS" BASIS,
1515# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
You can’t perform that action at this time.
0 commit comments