from-scratch 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Berksfile +1 -7
- data/Berksfile.lock +6 -0
- data/README.md +8 -3
- data/bin/scratchify +1 -1
- data/cookbooks/ruby_build/CHANGELOG.md +72 -0
- data/cookbooks/ruby_build/README.md +338 -0
- data/cookbooks/ruby_build/attributes/default.rb +67 -0
- data/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +40 -0
- data/cookbooks/ruby_build/metadata.json +39 -0
- data/cookbooks/ruby_build/providers/ruby.rb +88 -0
- data/cookbooks/ruby_build/recipes/default.rb +69 -0
- data/cookbooks/ruby_build/resources/ruby.rb +33 -0
- data/cookbooks/ruby_rbenv/CHANGELOG.md +221 -0
- data/cookbooks/ruby_rbenv/README.md +1059 -0
- data/cookbooks/ruby_rbenv/attributes/default.rb +73 -0
- data/cookbooks/ruby_rbenv/libraries/chef_provider_package_rbenvrubygems.rb +94 -0
- data/cookbooks/ruby_rbenv/libraries/chef_rbenv_mixin.rb +49 -0
- data/cookbooks/ruby_rbenv/libraries/chef_rbenv_recipe_helpers.rb +118 -0
- data/cookbooks/ruby_rbenv/libraries/chef_rbenv_script_helpers.rb +79 -0
- data/cookbooks/ruby_rbenv/libraries/matchers.rb +25 -0
- data/cookbooks/ruby_rbenv/metadata.json +1 -0
- data/cookbooks/ruby_rbenv/providers/global.rb +53 -0
- data/cookbooks/ruby_rbenv/providers/plugin.rb +55 -0
- data/cookbooks/ruby_rbenv/providers/rehash.rb +45 -0
- data/cookbooks/ruby_rbenv/providers/ruby.rb +123 -0
- data/cookbooks/ruby_rbenv/providers/script.rb +81 -0
- data/cookbooks/ruby_rbenv/recipes/default.rb +23 -0
- data/cookbooks/ruby_rbenv/recipes/system.rb +52 -0
- data/cookbooks/ruby_rbenv/recipes/system_install.rb +45 -0
- data/cookbooks/ruby_rbenv/recipes/user.rb +76 -0
- data/cookbooks/ruby_rbenv/recipes/user_install.rb +48 -0
- data/cookbooks/ruby_rbenv/resources/gem.rb +44 -0
- data/cookbooks/ruby_rbenv/resources/global.rb +33 -0
- data/cookbooks/ruby_rbenv/resources/plugin.rb +15 -0
- data/cookbooks/ruby_rbenv/resources/rehash.rb +29 -0
- data/cookbooks/ruby_rbenv/resources/ruby.rb +43 -0
- data/cookbooks/ruby_rbenv/resources/script.rb +39 -0
- data/cookbooks/ruby_rbenv/templates/default/rbenv.sh.erb +15 -0
- data/cookbooks/scratchify/Berksfile +1 -7
- data/cookbooks/scratchify/Berksfile.lock +6 -0
- data/cookbooks/scratchify/README.md +8 -3
- data/cookbooks/scratchify/bin/scratchify +1 -1
- data/cookbooks/scratchify/from-scratch.gemspec +1 -0
- data/cookbooks/scratchify/lib/from-scratch.rb +51 -9
- data/cookbooks/scratchify/lib/from-scratch/version.rb +2 -2
- data/cookbooks/scratchify/metadata.json +2 -1
- data/cookbooks/scratchify/spec/from/scratch_spec.rb +62 -5
- data/cookbooks/scratchify/spec/spec_helper.rb +8 -1
- data/cookbooks/scratchify/templates/node.json.erb +28 -7
- data/cookbooks/scratchify/templates/user.json.erb +1 -1
- data/from-scratch.gemspec +1 -0
- data/lib/from-scratch.rb +51 -9
- data/lib/from-scratch/version.rb +2 -2
- data/metadata.rb +1 -0
- data/templates/node.json.erb +28 -7
- data/templates/user.json.erb +1 -1
- metadata +50 -3
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: ruby_build
|
3
|
+
# Attributes:: default
|
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
|
+
# git repository containing the ruby-build framework
|
23
|
+
default['ruby_build']['git_url'] = "https://github.com/sstephenson/ruby-build.git"
|
24
|
+
default['ruby_build']['git_ref'] = "master"
|
25
|
+
|
26
|
+
# default base path for a system-wide installed Ruby
|
27
|
+
default['ruby_build']['default_ruby_base_path'] = "/usr/local/ruby"
|
28
|
+
|
29
|
+
# ruby-build upgrade action
|
30
|
+
default['ruby_build']['upgrade'] = "none"
|
31
|
+
|
32
|
+
case platform
|
33
|
+
when "redhat", "centos", "fedora", "amazon", "scientific"
|
34
|
+
node.set['ruby_build']['install_pkgs'] = %w{ tar bash curl }
|
35
|
+
node.set['ruby_build']['install_git_pkgs'] = %w{ git }
|
36
|
+
node.set['ruby_build']['install_pkgs_cruby'] =
|
37
|
+
%w{ gcc-c++ patch readline readline-devel zlib zlib-devel
|
38
|
+
libffi-devel openssl-devel
|
39
|
+
make bzip2 autoconf automake libtool bison
|
40
|
+
libxml2 libxml2-devel libxslt libxslt-devel
|
41
|
+
subversion autoconf }
|
42
|
+
node.set['ruby_build']['install_pkgs_jruby'] = []
|
43
|
+
|
44
|
+
when "debian", "ubuntu"
|
45
|
+
node.set['ruby_build']['install_pkgs'] = %w{ tar bash curl }
|
46
|
+
node.set['ruby_build']['install_git_pkgs'] = %w{ git-core }
|
47
|
+
node.set['ruby_build']['install_pkgs_cruby'] =
|
48
|
+
%w{ build-essential bison openssl libreadline6 libreadline6-dev
|
49
|
+
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0
|
50
|
+
libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf
|
51
|
+
libc6-dev ssl-cert subversion }
|
52
|
+
node.set['ruby_build']['install_pkgs_jruby'] = %w{ make g++ }
|
53
|
+
|
54
|
+
when "suse"
|
55
|
+
node.set['ruby_build']['install_pkgs'] = %w{ tar bash curl }
|
56
|
+
node.set['ruby_build']['install_git_pkgs'] = %w{ git-core }
|
57
|
+
node.set['ruby_build']['install_pkgs_cruby'] =
|
58
|
+
%w{ gcc-c++ patch zlib zlib-devel libffi-devel
|
59
|
+
sqlite3-devel libxml2-devel libxslt-devel subversion autoconf }
|
60
|
+
node.set['ruby_build']['install_pkgs_jruby'] = []
|
61
|
+
|
62
|
+
when "mac_os_x"
|
63
|
+
node.set['ruby_build']['install_pkgs'] = []
|
64
|
+
node.set['ruby_build']['install_git_pkgs'] = %w{ git-core }
|
65
|
+
node.set['ruby_build']['install_pkgs_cruby'] = []
|
66
|
+
node.set['ruby_build']['install_pkgs_jruby'] = []
|
67
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: ruby_build
|
3
|
+
# Library:: Chef::RubyBuild::RecipeHelpers
|
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
|
+
class Chef
|
23
|
+
module RubyBuild
|
24
|
+
module RecipeHelpers
|
25
|
+
def build_upgrade_strategy(strategy)
|
26
|
+
if strategy.nil? || strategy == false
|
27
|
+
"none"
|
28
|
+
else
|
29
|
+
strategy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def mac_with_no_homebrew
|
34
|
+
node['platform'] == 'mac_os_x' &&
|
35
|
+
Chef::Platform.find_provider_for_node(node, :package) !=
|
36
|
+
Chef::Provider::Package::Homebrew
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"name": "ruby_build",
|
3
|
+
"description": "Manages the ruby-build framework and its installed rubies. A LWRP is also defined.",
|
4
|
+
"long_description": "# <a name=\"title\"></a> chef-ruby_build\n\n[![Build Status](https://secure.travis-ci.org/fnichol/chef-ruby_build.png?branch=master)](http://travis-ci.org/fnichol/chef-ruby_build)\n\n## <a name=\"description\"></a> Description\n\nManages the [ruby-build][rb_site] framework and its installed Rubies.\nA lightweight resources and providers ([LWRP][lwrp]) is also defined.\n\n## <a name=\"usage\"></a> Usage\n\nSimply include `recipe[ruby_build]` in your run\\_list to have ruby-build\ninstalled. You will also have access to the `ruby_build_ruby` resource. See\nthe [Resources and Providers](#lwrps) section for more details.\n\n## <a name=\"requirements\"></a> Requirements\n\n### <a name=\"requirements-chef\"></a> Chef\n\nTested on 0.10.8 but newer and older version should work just\nfine. File an [issue][issues] if this isn't the case.\n\n### <a name=\"requirements-platform\"></a> Platform\n\nThe following platforms have been tested with this cookbook, meaning that\nthe recipes and LWRPs run on these platforms without error:\n\n* ubuntu (10.04/10.10/11.04/11.10/12.04)\n* mac\\_os\\_x (10.7/10.8)\n* debian\n* freebsd\n* redhat\n* centos\n* fedora\n* amazon\n* scientific\n* suse\n\nPlease [report][issues] any additional platforms so they can be added.\n\n### <a name=\"requirements-cookbooks\"></a> Cookbooks\n\nThere are **no** external cookbook dependencies. However, if you are\ninstalling [JRuby][jruby] then a Java runtime will need to be installed.\nThe Opscode [java cookbook][java_cb] can be used on supported platforms.\n\n## <a name=\"installation\"></a> Installation\n\nDepending on the situation and use case there are several ways to install\nthis cookbook. All the methods listed below assume a tagged version release\nis the target, but omit the tags to get the head of development. A valid\nChef repository structure like the [Opscode repo][chef_repo] is also assumed.\n\n### <a name=\"installation-platform\"></a> From the Opscode Community Platform\n\nTo install this cookbook from the Opscode platform, use the *knife* command:\n\n knife cookbook site install ruby_build\n\n### <a name=\"installation-berkshelf\"></a> Using Berkshelf\n\n[Berkshelf][berkshelf] is a cookbook dependency manager and development\nworkflow assistant. To install Berkshelf:\n\n cd chef-repo\n gem install berkshelf\n berks init\n\nTo use the Community Site version:\n\n echo \"cookbook 'ruby_build'\" >> Berksfile\n berks install\n\nOr to reference the Git version:\n\n repo=\"fnichol/chef-ruby_build\"\n latest_release=$(curl -s https://api.github.com/repos/$repo/git/refs/tags \\\n | ruby -rjson -e '\n j = JSON.parse(STDIN.read);\n puts j.map { |t| t[\"ref\"].split(\"/\").last }.sort.last\n ')\n cat >> Berksfile <<END_OF_BERKSFILE\n cookbook 'ruby_build',\n :git => 'git://github.com/$repo.git', :branch => '$latest_release'\n END_OF_BERKSFILE\n\n### <a name=\"installation-librarian\"></a> Using Librarian-Chef\n\n[Librarian-Chef][librarian] is a bundler for your Chef cookbooks.\nTo install Librarian-Chef:\n\n cd chef-repo\n gem install librarian\n librarian-chef init\n\nTo use the Opscode platform version:\n\n echo \"cookbook 'ruby_build'\" >> Cheffile\n librarian-chef install\n\nOr to reference the Git version:\n\n repo=\"fnichol/chef-ruby_build\"\n latest_release=$(curl -s https://api.github.com/repos/$repo/git/refs/tags \\\n | ruby -rjson -e '\n j = JSON.parse(STDIN.read);\n puts j.map { |t| t[\"ref\"].split(\"/\").last }.sort.last\n ')\n cat >> Cheffile <<END_OF_CHEFFILE\n cookbook 'ruby_build',\n :git => 'git://github.com/$repo.git', :ref => '$latest_release'\n END_OF_CHEFFILE\n librarian-chef install\n\n## <a name=\"recipes\"></a> Recipes\n\n### <a name=\"recipes-default\"></a> default\n\nInstalls the ruby-build codebase and initializes Chef to use the Lightweight\nResources and Providers ([LWRPs][lwrp]).\n\n## <a name=\"attributes\"></a> Attributes\n\n### <a name=\"attributes-git-url\"></a> git_url\n\nThe Git URL which is used to install ruby-build.\n\nThe default is `\"git://github.com/sstephenson/ruby-build.git\"`.\n\n### <a name=\"attributes-git-ref\"></a> git_ref\n\nA specific Git branch/tag/reference to use when installing ruby-build. For\nexample, to pin ruby-build to a specific release:\n\n node['ruby_build']['git_ref'] = \"v20111030\"\n\nThe default is `\"master\"`.\n\n### <a name=\"attributes-default-ruby-base-path\"></a> default_ruby_base_path\n\nThe default base path for a system-wide installed Ruby. For example, the\nfollowing resource:\n\n ruby_build_ruby \"1.9.3-p0\"\n\nwill be installed into\n`\"#{node['ruby_build']['default_ruby_base_path']}/1.9.3-p0\"` unless a\n`prefix_path` attribute is explicitly set.\n\nThe default is `\"/usr/local/ruby\"`.\n\n### <a name=\"attributes-upgrade\"></a> upgrade\n\nDetermines how to handle installing updates to the ruby-build framework.\nThere are currently 2 valid values:\n\n* `\"none\"`, `false`, or `nil`: will not update ruby-build and leave it in its\n current state.\n* `\"sync\"` or `true`: updates ruby-build to the version specified by the\n `git_ref` attribute or the head of the master branch by default.\n\nThe default is `\"none\"`.\n\n## <a name=\"lwrps\"></a> Resources and Providers\n\n### <a name=\"lwrps-rbr\"></a> ruby_build_ruby\n\n#### <a name=\"lwrps-rbr-actions\"></a> Actions\n\n<table>\n <thead>\n <tr>\n <th>Action</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>install</td>\n <td>\n Build and install a Ruby from a definition file. See the ruby-build\n readme<sup>(1)</sup> for more details.\n </td>\n <td>Yes</td>\n </tr>\n <tr>\n <td>reinstall</td>\n <td>\n Force a recompiliation of the Ruby from source. The :install action\n will skip a build if the target install directory already exists.\n </td>\n <td> </td>\n </tr>\n </tbody>\n</table>\n\n1. [ruby-build readme][rb_readme]\n\n#### <a name=\"lwrps-rbr-attributes\"></a> Attributes\n\n<table>\n <thead>\n <tr>\n <th>Attribute</th>\n <th>Description</th>\n <th>Default Value</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>definition</td>\n <td>\n <b>Name attribute:</b> the name of a built-in definition<sup>(1)</sup>\n or the path to a ruby-build definition file.\n </td>\n <td><code>nil</code></td>\n </tr>\n <tr>\n <td>prefix_path</td>\n <td>The path to which the Ruby will be installed.</td>\n <td><code>nil</code></td>\n </tr>\n <tr>\n <td>user</td>\n <td>\n A user which will own the installed Ruby. The default value of\n <code>nil</code> denotes a system-wide Ruby (root-owned) is being\n targeted. <b>Note:</b> if specified, the user must already exist.\n </td>\n <td><code>nil</code></td>\n </tr>\n <tr>\n <td>group</td>\n <td>\n A group which will own the installed Ruby. The default value of\n <code>nil</code> denotes a system-wide Ruby (root-owned) is being\n targeted. <b>Note:</b> if specified, the group must already exist.\n </td>\n <td><code>nil</code></td>\n </tr>\n <tr>\n <td>environment</td>\n <td>\n A Hash of additional environment variables<sup>(2)</sup>, such as\n <code>CONFIGURE_OPTS</code> or <code>RUBY_BUILD_MIRROR_URL</code>.\n </td>\n <td><code>nil</code></td>\n </tr>\n </tbody>\n</table>\n\n1. [built-in definition][rb_definitions]\n2. [special environment variables][rb_environment]\n\n#### <a name=\"lwrps-rbr-examples\"></a> Examples\n\n##### Install Ruby\n\n # See: https://github.com/sstephenson/ruby-build/issues/186\n ruby_build_ruby \"ree-1.8.7-2012.02\" do\n environment({ 'CONFIGURE_OPTS' => '--no-tcmalloc' })\n end\n\n ruby_build_ruby \"1.9.3-p0\" do\n prefix_path \"/usr/local/ruby/ruby-1.9.3-p0\"\n environment({\n 'RUBY_BUILD_MIRROR_URL' => 'http://local.example.com'\n })\n\n action :install\n end\n\n ruby_build_ruby \"jruby-1.6.5\"\n\n**Note:** the install action is default, so the second example is more common.\n\n##### Install A Ruby For A User\n\n ruby_build_ruby \"maglev-1.0.0\" do\n prefix_path \"/home/deploy/.rubies/maglev-1.0.0\"\n user \"deploy\"\n group \"deploy\"\n end\n\n##### Reinstall Ruby\n\n ruby_build_ruby \"rbx-1.2.4\" do\n prefix_path \"/opt/rbx-1.2.4\"\n\n action :reinstall\n end\n\n**Note:** the Ruby will be built whether or not the Ruby exists in the\n`prefix_path` directory.\n\n## <a name=\"development\"></a> Development\n\n* Source hosted at [GitHub][repo]\n* Report issues/Questions/Feature requests on [GitHub Issues][issues]\n\nPull requests are very welcome! Make sure your patches are well tested.\nIdeally create a topic branch for every separate change you make.\n\n## <a name=\"license\"></a> License and Author\n\nAuthor:: [Fletcher Nichol][fnichol] (<fnichol@nichol.ca>) [![endorse](http://api.coderwall.com/fnichol/endorsecount.png)](http://coderwall.com/fnichol)\n\nCopyright 2011, Fletcher Nichol\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[berkshelf]: http://berkshelf.com/\n[chef_repo]: https://github.com/opscode/chef-repo\n[cheffile]: https://github.com/applicationsonline/librarian/blob/master/lib/librarian/chef/templates/Cheffile\n[java_cb]: http://community.opscode.com/cookbooks/java\n[jruby]: http://jruby.org/\n[kgc]: https://github.com/websterclay/knife-github-cookbooks#readme\n[librarian]: https://github.com/applicationsonline/librarian#readme\n[lwrp]: http://wiki.opscode.com/display/chef/Lightweight+Resources+and+Providers+%28LWRP%29\n[rb_readme]: https://github.com/sstephenson/ruby-build#readme\n[rb_site]: https://github.com/sstephenson/ruby-build\n[rb_environment]: https://github.com/sstephenson/ruby-build#special-environment-variables\n[rb_definitions]: https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build\n\n[fnichol]: https://github.com/fnichol\n[repo]: https://github.com/fnichol/chef-ruby_build\n[issues]: https://github.com/fnichol/chef-ruby_build/issues\n",
|
5
|
+
"maintainer": "Fletcher Nichol",
|
6
|
+
"maintainer_email": "fnichol@nichol.ca",
|
7
|
+
"license": "Apache 2.0",
|
8
|
+
"platforms": {
|
9
|
+
"ubuntu": ">= 0.0.0",
|
10
|
+
"debian": ">= 0.0.0",
|
11
|
+
"freebsd": ">= 0.0.0",
|
12
|
+
"redhat": ">= 0.0.0",
|
13
|
+
"centos": ">= 0.0.0",
|
14
|
+
"fedora": ">= 0.0.0",
|
15
|
+
"amazon": ">= 0.0.0",
|
16
|
+
"scientific": ">= 0.0.0",
|
17
|
+
"suse": ">= 0.0.0",
|
18
|
+
"mac_os_x": ">= 0.0.0"
|
19
|
+
},
|
20
|
+
"dependencies": {
|
21
|
+
},
|
22
|
+
"recommendations": {
|
23
|
+
},
|
24
|
+
"suggestions": {
|
25
|
+
},
|
26
|
+
"conflicting": {
|
27
|
+
},
|
28
|
+
"providing": {
|
29
|
+
},
|
30
|
+
"replacing": {
|
31
|
+
},
|
32
|
+
"attributes": {
|
33
|
+
},
|
34
|
+
"groupings": {
|
35
|
+
},
|
36
|
+
"recipes": {
|
37
|
+
},
|
38
|
+
"version": "0.8.0"
|
39
|
+
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: ruby_build
|
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
|
+
def load_current_resource
|
23
|
+
@rubie = new_resource.definition
|
24
|
+
@prefix_path = new_resource.prefix_path ||
|
25
|
+
"#{node['ruby_build']['default_ruby_base_path']}/#{@rubie}"
|
26
|
+
end
|
27
|
+
|
28
|
+
action :install do
|
29
|
+
perform_install
|
30
|
+
end
|
31
|
+
|
32
|
+
action :reinstall do
|
33
|
+
perform_install
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def perform_install
|
39
|
+
if ruby_installed?
|
40
|
+
Chef::Log.debug(
|
41
|
+
"ruby_build_ruby[#{@rubie}] is already installed, so skipping")
|
42
|
+
else
|
43
|
+
install_start = Time.now
|
44
|
+
|
45
|
+
install_ruby_dependencies
|
46
|
+
|
47
|
+
Chef::Log.info(
|
48
|
+
"Building ruby_build_ruby[#{@rubie}], this could take a while...")
|
49
|
+
|
50
|
+
rubie = @rubie # bypass block scoping issue
|
51
|
+
prefix_path = @prefix_path # bypass block scoping issue
|
52
|
+
execute "ruby-build[#{rubie}]" do
|
53
|
+
command %{/usr/local/bin/ruby-build "#{rubie}" "#{prefix_path}"}
|
54
|
+
user new_resource.user if new_resource.user
|
55
|
+
group new_resource.group if new_resource.group
|
56
|
+
environment new_resource.environment if new_resource.environment
|
57
|
+
|
58
|
+
action :nothing
|
59
|
+
end.run_action(:run)
|
60
|
+
|
61
|
+
Chef::Log.info("ruby_build_ruby[#{@rubie}] build time was " +
|
62
|
+
"#{(Time.now - install_start)/60.0} minutes")
|
63
|
+
new_resource.updated_by_last_action(true)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def ruby_installed?
|
68
|
+
if Array(new_resource.action).include?(:reinstall)
|
69
|
+
false
|
70
|
+
else
|
71
|
+
::File.exists?("#{@prefix_path}/bin/ruby")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def install_ruby_dependencies
|
76
|
+
case ::File.basename(new_resource.definition)
|
77
|
+
when /^\d\.\d\.\d-/, /^rbx-/, /^ree-/
|
78
|
+
pkgs = node['ruby_build']['install_pkgs_cruby']
|
79
|
+
when /^jruby-/
|
80
|
+
pkgs = node['ruby_build']['install_pkgs_jruby']
|
81
|
+
end
|
82
|
+
|
83
|
+
Array(pkgs).each do |pkg|
|
84
|
+
package pkg do
|
85
|
+
action :nothing
|
86
|
+
end.run_action(:install)
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: ruby_build
|
3
|
+
# Recipe:: default
|
4
|
+
#
|
5
|
+
# Copyright 2011, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
class Chef::Recipe
|
21
|
+
# mix in recipe helpers
|
22
|
+
include Chef::RubyBuild::RecipeHelpers
|
23
|
+
end
|
24
|
+
|
25
|
+
git_url = node['ruby_build']['git_url']
|
26
|
+
git_ref = node['ruby_build']['git_ref']
|
27
|
+
upgrade_strategy = build_upgrade_strategy(node['ruby_build']['upgrade'])
|
28
|
+
|
29
|
+
cache_path = Chef::Config['file_cache_path']
|
30
|
+
src_path = "#{cache_path}/ruby-build"
|
31
|
+
|
32
|
+
unless mac_with_no_homebrew
|
33
|
+
Array(node['ruby_build']['install_pkgs']).each do |pkg|
|
34
|
+
package pkg
|
35
|
+
end
|
36
|
+
|
37
|
+
Array(node['ruby_build']['install_git_pkgs']).each do |pkg|
|
38
|
+
package pkg do
|
39
|
+
not_if "git --version >/dev/null"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
execute "Install ruby-build" do
|
45
|
+
cwd src_path
|
46
|
+
command %{./install.sh}
|
47
|
+
|
48
|
+
action :nothing
|
49
|
+
not_if do
|
50
|
+
::File.exists?("/usr/local/bin/ruby-build") && upgrade_strategy == "none"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
directory ::File.dirname(src_path) do
|
55
|
+
recursive true
|
56
|
+
end
|
57
|
+
|
58
|
+
git src_path do #~FC043 exception to support AWS OpsWorks using an older Chef
|
59
|
+
repository git_url
|
60
|
+
reference git_ref
|
61
|
+
|
62
|
+
if upgrade_strategy == "none"
|
63
|
+
action :checkout
|
64
|
+
else
|
65
|
+
action :sync
|
66
|
+
end
|
67
|
+
|
68
|
+
notifies :run, resources(:execute => "Install ruby-build"), :immediately
|
69
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: ruby_build
|
3
|
+
# Resource:: 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
|
+
actions :install, :reinstall
|
23
|
+
|
24
|
+
attribute :definition, :kind_of => String, :name_attribute => true
|
25
|
+
attribute :prefix_path, :kind_of => String
|
26
|
+
attribute :user, :kind_of => String
|
27
|
+
attribute :group, :kind_of => String
|
28
|
+
attribute :environment, :kind_of => Hash
|
29
|
+
|
30
|
+
def initialize(*args)
|
31
|
+
super
|
32
|
+
@action = :install
|
33
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
## 1.0.1 (October 24, 2015)
|
2
|
+
* Fixed failure with rehashing after the cookbook was renamed
|
3
|
+
|
4
|
+
## 1.0.0 (October 12, 2015)
|
5
|
+
|
6
|
+
### WARNING: Cookbook has been renamed
|
7
|
+
* Renamed to ruby_rbenv and uploaded to Supermarket (all attributes rename in the rbenv cookbook). If you wrap this cookbook you're going to need to update the recipes you include. All providers have been updated to keep their existing rbenv_xyz names for backwards compatibility and attributes still maintain the rbenv namespace.
|
8
|
+
* Updated Travis config to run integration tests in Travis using kitchen-docker
|
9
|
+
|
10
|
+
## 0.9.0 (October 12, 2015)
|
11
|
+
* Fixed base platform case statement in the cookbook that set install_pkgs and user_home_root attributes. This has been converted to a platform_family statement to better support derivitive operating systems and the attributes are set at default levels so they can be overwritten in wrapper cookbooks
|
12
|
+
* Updated Travis to test using Chef DK vs. Gem installs
|
13
|
+
* Fixed Chefspecs and Test Kitchen bats tests to all pass
|
14
|
+
* Added the Apache 2.0 license file
|
15
|
+
* Updated and added new development dependencies to the Gemfile
|
16
|
+
* Use Chef 12.1+ multi-package installs for the dependency packages to speed up installs
|
17
|
+
* Removed the empty Vagrant recipe
|
18
|
+
* Actually depend on ruby_version vs. suggests since suggests isn't implemented in Chef
|
19
|
+
|
20
|
+
## 0.8.1 (August 28, 2015)
|
21
|
+
* Add rbenv_action attribute to rbenv_ruby LWRP so to allow using rvm-download rbenv plugin to download ruby vs. installing ruby
|
22
|
+
* Fix the ability to install gems to a specific version of ruby
|
23
|
+
* Remove Chef version checks around use_inline_resources since we require Chef 12
|
24
|
+
* Use default_action method in the LWRPs
|
25
|
+
* Fix various rubocop warnings
|
26
|
+
|
27
|
+
## 0.8.0 (July 27, 2015)
|
28
|
+
* Drop support for Chef versions prior to 12
|
29
|
+
* Add Arch linux support
|
30
|
+
* Add Linux mint support
|
31
|
+
|
32
|
+
## 0.7.3 (July 8, 2015)
|
33
|
+
|
34
|
+
### Bug Fixes
|
35
|
+
|
36
|
+
* Issue [#91](https://github.com/fnichol/chef-rbenv/issues/91) [#79](https://github.com/fnichol/chef-rbenv/issues/79) [#92](https://github.com/fnichol/chef-rbenv/pull/92):
|
37
|
+
Add matchers for rbenv_gem and rbenv_ruby.
|
38
|
+
([@tduffield](https://github.com/tduffield) and many others)
|
39
|
+
* Issue [#107](https://github.com/fnichol/chef-rbenv/issues/107):
|
40
|
+
"Option name must be a kind of String!" when installing gems.
|
41
|
+
* Issue [#101](https://github.com/fnichol/chef-rbenv/issues/101):
|
42
|
+
Use full class name for rbenv_rehash resource
|
43
|
+
* Fix undefined method `timeout' for LWRP resource rbenv_gem.
|
44
|
+
([@nathantsoi](https://github.com/nathantsoi) and others)
|
45
|
+
* Issue [#110](https://github.com/fnichol/chef-rbenv/issues/110):
|
46
|
+
Chef 12.3.0 - undefined method `clear_sources' for Chef::Resource::RbenvGem.
|
47
|
+
([@tatat](https://github.com/tatat) and others)
|
48
|
+
|
49
|
+
### Improvements
|
50
|
+
|
51
|
+
* Fork from https://github.com/fnichol/chef-rbenv
|
52
|
+
|
53
|
+
|
54
|
+
## 0.7.2 (December 31, 2012)
|
55
|
+
|
56
|
+
### Bug Fixes
|
57
|
+
|
58
|
+
* Pull request [#26](https://github.com/fnichol/chef-rbenv/pull/26): Don't
|
59
|
+
call libexec commands directly. ([@mhoran][])
|
60
|
+
|
61
|
+
### Improvements
|
62
|
+
|
63
|
+
* Add integration tests for a system Ruby version. ([@fnichol][])
|
64
|
+
|
65
|
+
## 0.7.1 (unreleased)
|
66
|
+
|
67
|
+
### Bug Fixes
|
68
|
+
|
69
|
+
* Pull request [#36](https://github.com/fnichol/chef-rbenv/pull/36):
|
70
|
+
Use the ruby name as the definition to install
|
71
|
+
([@gsandie][])
|
72
|
+
* Pull request [#55](https://github.com/fnichol/chef-rbenv/pull/55):
|
73
|
+
Fix some CHEF-3694 warnings when using with ruby_build
|
74
|
+
([@trinitronx][])
|
75
|
+
|
76
|
+
### New features
|
77
|
+
|
78
|
+
* Pull request [#26](https://github.com/fnichol/chef-rbenv/pull/26):
|
79
|
+
Allow setting environment vars per ruby install
|
80
|
+
([@jasherai][])
|
81
|
+
* Pull request [#37](https://github.com/fnichol/chef-rbenv/pull/37):
|
82
|
+
Allows use `include_recipe("ruby_build")` instead of having to put it in the `run_list`
|
83
|
+
([@tjwallace][])
|
84
|
+
* Pull request [#42](https://github.com/fnichol/chef-rbenv/pull/42):
|
85
|
+
Load rbenv environment after install
|
86
|
+
([@msaffitz][])
|
87
|
+
* Pull request [#62](https://github.com/fnichol/chef-rbenv/pull/62):
|
88
|
+
Add Gentoo as supported platform
|
89
|
+
([@gentooboontoo][])
|
90
|
+
|
91
|
+
### Improvements
|
92
|
+
|
93
|
+
* Pull request [#46](https://github.com/fnichol/chef-rbenv/pull/46):
|
94
|
+
Add a `definition_file` attribute to the `rbenv_ruby` resource to prevent
|
95
|
+
continually trying to build a custom ruby when passed a build file name instead of a built-in definition
|
96
|
+
([@jf647][])
|
97
|
+
* Pull request [#60](https://github.com/fnichol/chef-rbenv/pull/60):
|
98
|
+
Support `definition_file` in rubies definition
|
99
|
+
([@cyu][])
|
100
|
+
* Pull request [#75](https://github.com/fnichol/chef-rbenv/pull/75):
|
101
|
+
Update testing support and add unit tests for existing resources
|
102
|
+
([@fnichol][])
|
103
|
+
* Pull request [#70](https://github.com/fnichol/chef-rbenv/pull/70):
|
104
|
+
Support ruby 2.1.0
|
105
|
+
([@WhyEee][])
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
## 0.7.0 (November 21, 2012)
|
110
|
+
|
111
|
+
### Bug Fixes
|
112
|
+
|
113
|
+
* Issue [#14](https://github.com/fnichol/chef-rbenv/pull/14): Create
|
114
|
+
/etc/profile.d on system-wide and add note for Mac. ([@fnichol][])
|
115
|
+
|
116
|
+
### New features
|
117
|
+
|
118
|
+
* Pull request [#20](https://github.com/fnichol/chef-rbenv/pull/20): Set an
|
119
|
+
attribute to create profile.d for user install. ([@jtimberman][])
|
120
|
+
|
121
|
+
### Improvements
|
122
|
+
|
123
|
+
* Pull request [#12](https://github.com/fnichol/chef-rbenv/pull/12): Add name
|
124
|
+
attribute to metadata. ([@jtimberman][])
|
125
|
+
* Update foodcritic configuration and update .travis.yml. ([@fnichol][])
|
126
|
+
* Update Installation section of README (welcome Berkshelf). ([@fnichol][])
|
127
|
+
|
128
|
+
|
129
|
+
## 0.6.10 (May 18, 2012)
|
130
|
+
|
131
|
+
### New features
|
132
|
+
|
133
|
+
* Pull request [#11](https://github.com/fnichol/chef-rbenv/pull/11): Add
|
134
|
+
FreeBSD support. ([@jssjr][])
|
135
|
+
|
136
|
+
### Improvements
|
137
|
+
|
138
|
+
* Add other platform supports in metadata.rb and README. ([@fnichol][])
|
139
|
+
|
140
|
+
|
141
|
+
## 0.6.8 (May 6, 2012)
|
142
|
+
|
143
|
+
### Improvements
|
144
|
+
|
145
|
+
* Add official hook resource log[rbenv-post-init-\*] for inter-cookbook
|
146
|
+
integration. ([@fnichol][])
|
147
|
+
|
148
|
+
|
149
|
+
## 0.6.6 (May 4, 2012)
|
150
|
+
|
151
|
+
### Bug Fixes
|
152
|
+
|
153
|
+
* Fix FC022: Resource condition within loop may not behave as expected.
|
154
|
+
([@fnichol][])
|
155
|
+
* Add plaform equivalents in default attrs (FC024). ([@fnichol][])
|
156
|
+
* Ensure update-java-alternatives is called before JRuby is built.
|
157
|
+
([@fnichol][])
|
158
|
+
* Pull request [#8](https://github.com/fnichol/chef-rbenv/pull/8): Add
|
159
|
+
/etc/profile.d/rbenv.sh support for user installs. ([@thoughtless][])
|
160
|
+
|
161
|
+
### Improvements
|
162
|
+
|
163
|
+
* Add TravisCI to run Foodcritic linter. ([@fnichol][])
|
164
|
+
* Pull request [#10](https://github.com/fnichol/chef-rbenv/pull/10): README
|
165
|
+
proofreading. ([@jdsiegel][])
|
166
|
+
* README updates. ([@fnichol][])
|
167
|
+
* Confirm debian platform support. ([@fnichol][])
|
168
|
+
|
169
|
+
|
170
|
+
## 0.6.4 (February 23, 2012)
|
171
|
+
|
172
|
+
### Bug Fixes
|
173
|
+
|
174
|
+
* Set `root_path` on rbenv\_rehash in rbenv\_gem provider. ([@fnichol][])
|
175
|
+
|
176
|
+
### Improvements
|
177
|
+
|
178
|
+
* Foodcritic lint-driven code updates. ([@fnichol][])
|
179
|
+
* Update Git URL in README. ([@hedgehog][])
|
180
|
+
|
181
|
+
|
182
|
+
## 0.6.2 (February 22, 2012)
|
183
|
+
|
184
|
+
### Bug Fixes
|
185
|
+
|
186
|
+
* Issues [#1](https://github.com/fnichol/chef-rbenv/issues/1),
|
187
|
+
[#2](https://github.com/fnichol/chef-rbenv/issues/2): Stub mixins in
|
188
|
+
RbenvRubygems to avoid libraries load ordering issues. ([@fnichol][])
|
189
|
+
* Pull request [#5](https://github.com/fnichol/chef-rbenv/pull/5): Include
|
190
|
+
user setting in rehash calls. ([@magnetised][])
|
191
|
+
* Issue [#4](https://github.com/fnichol/chef-rbenv/issues/4): Fix rbenv/gems
|
192
|
+
hash parsing. ([@fnichol][])
|
193
|
+
|
194
|
+
### Improvements
|
195
|
+
|
196
|
+
* Large formatting updates to README. ([@fnichol][])
|
197
|
+
* Add gh-pages branch for sectioned README at
|
198
|
+
https://fnichol.github.com/chef-rbenv
|
199
|
+
|
200
|
+
|
201
|
+
## 0.6.0 (December 21, 2011)
|
202
|
+
|
203
|
+
The initial release.
|
204
|
+
|
205
|
+
[@fnichol]: https://github.com/fnichol
|
206
|
+
[@jdsiegel]: https://github.com/jdsiegel
|
207
|
+
[@jssjr]: https://github.com/jssjr
|
208
|
+
[@jtimberman]: https://github.com/jtimberman
|
209
|
+
[@hedgehog]: https://github.com/hedgehog
|
210
|
+
[@magnetised]: https://github.com/magnetised
|
211
|
+
[@mhoran]: https://github.com/mhoran
|
212
|
+
[@thoughtless]: https://github.com/thoughtless
|
213
|
+
[@jasherai]: https://github.com/jasherai
|
214
|
+
[@tjwallace]: https://github.com/tjwallace
|
215
|
+
[@jf647]: https://github.com/jf647
|
216
|
+
[@gsandie]: https://github.com/gsandie
|
217
|
+
[@msaffitz]: https://github.com/msaffitz
|
218
|
+
[@trinitronx]: https://github.com/trinitronx
|
219
|
+
[@gentooboontoo]: https://github.com/gentooboontoo
|
220
|
+
[@cyu]: https://github.com/cyu
|
221
|
+
[@WhyEee]: https://github.com/WhyEee
|