vault-tree 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. data/.gitignore +26 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +43 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +118 -0
  6. data/Rakefile +17 -0
  7. data/VagrantFile +30 -0
  8. data/features/core.feature +44 -0
  9. data/features/exceptions.feature +41 -0
  10. data/features/steps/core.steps.rb +168 -0
  11. data/features/steps/exceptions.steps.rb +103 -0
  12. data/features/support/env.rb +1 -0
  13. data/features/world.rb +3 -0
  14. data/lib/vault-tree.rb +7 -0
  15. data/lib/vault-tree/config/dependencies.rb +4 -0
  16. data/lib/vault-tree/config/lib.rb +2 -0
  17. data/lib/vault-tree/config/path_helpers.rb +49 -0
  18. data/lib/vault-tree/config/string.rb +25 -0
  19. data/lib/vault-tree/contract/close_validator.rb +35 -0
  20. data/lib/vault-tree/contract/contract.rb +85 -0
  21. data/lib/vault-tree/contract/contract_presenter.rb +27 -0
  22. data/lib/vault-tree/contract/doorman.rb +112 -0
  23. data/lib/vault-tree/contract/null_vault.rb +16 -0
  24. data/lib/vault-tree/contract/open_validator.rb +20 -0
  25. data/lib/vault-tree/contract/vault.rb +96 -0
  26. data/lib/vault-tree/exceptions/empty_vault.rb +8 -0
  27. data/lib/vault-tree/exceptions/fill_attempt_master_password.rb +6 -0
  28. data/lib/vault-tree/exceptions/invalid_signature.rb +0 -0
  29. data/lib/vault-tree/exceptions/malformed_json.rb +0 -0
  30. data/lib/vault-tree/exceptions/missing_external_data.rb +6 -0
  31. data/lib/vault-tree/exceptions/missing_partner_decryption_key.rb +6 -0
  32. data/lib/vault-tree/exceptions/missing_passphrase.rb +6 -0
  33. data/lib/vault-tree/exceptions/non_unique_vault_id.rb +0 -0
  34. data/lib/vault-tree/exceptions/unsupported_keyword.rb +6 -0
  35. data/lib/vault-tree/exceptions/vault_does_not_exist.rb +6 -0
  36. data/lib/vault-tree/exceptions/vault_tree_exception.rb +6 -0
  37. data/lib/vault-tree/keywords/decryption_key.rb +14 -0
  38. data/lib/vault-tree/keywords/external_data.rb +13 -0
  39. data/lib/vault-tree/keywords/keyword.rb +19 -0
  40. data/lib/vault-tree/keywords/keyword_interpreter.rb +45 -0
  41. data/lib/vault-tree/keywords/master_passphrase.rb +9 -0
  42. data/lib/vault-tree/keywords/public_encryption_key.rb +27 -0
  43. data/lib/vault-tree/keywords/random_number.rb +9 -0
  44. data/lib/vault-tree/keywords/shared_key.rb +24 -0
  45. data/lib/vault-tree/keywords/unlocked.rb +9 -0
  46. data/lib/vault-tree/keywords/vault_contents.rb +13 -0
  47. data/lib/vault-tree/lock_smith/asymmetric_cipher.rb +31 -0
  48. data/lib/vault-tree/lock_smith/crypto_hash.rb +11 -0
  49. data/lib/vault-tree/lock_smith/digital_signature.rb +32 -0
  50. data/lib/vault-tree/lock_smith/encryption_key_pair.rb +25 -0
  51. data/lib/vault-tree/lock_smith/null_vault.rb +4 -0
  52. data/lib/vault-tree/lock_smith/random_number.rb +11 -0
  53. data/lib/vault-tree/lock_smith/shared_key_pair.rb +12 -0
  54. data/lib/vault-tree/lock_smith/signing_key_pair.rb +25 -0
  55. data/lib/vault-tree/lock_smith/symmetric_cipher.rb +25 -0
  56. data/lib/vault-tree/util/json.rb +16 -0
  57. data/lib/vault-tree/version.rb +3 -0
  58. data/spec/app/locksmith/asymmetric_cipher_spec.rb +25 -0
  59. data/spec/app/locksmith/signing_key_pair_spec.rb +22 -0
  60. data/spec/spec_helper.rb +5 -0
  61. data/spec/support/fixtures/blank_simple_test_contract.json +14 -0
  62. data/spec/support/fixtures/broken_contract.json +55 -0
  63. data/spec/support/fixtures/one_two_three-0.5.0.EXP.json +105 -0
  64. data/spec/support/fixtures/reference_contract.1.0.0.json +227 -0
  65. data/spec/support/fixtures/simple_test_contract.json +14 -0
  66. data/support/cookbooks/ark/.gitignore +12 -0
  67. data/support/cookbooks/ark/.kitchen.yml +34 -0
  68. data/support/cookbooks/ark/.travis.yml +6 -0
  69. data/support/cookbooks/ark/Berksfile +9 -0
  70. data/support/cookbooks/ark/CHANGELOG.md +87 -0
  71. data/support/cookbooks/ark/CONTRIBUTING.md +257 -0
  72. data/support/cookbooks/ark/README.md +301 -0
  73. data/support/cookbooks/ark/Rakefile +36 -0
  74. data/support/cookbooks/ark/TESTING.md +25 -0
  75. data/support/cookbooks/ark/Toftfile +15 -0
  76. data/support/cookbooks/ark/attributes/default.rb +6 -0
  77. data/support/cookbooks/ark/chefignore +96 -0
  78. data/support/cookbooks/ark/files/default/foo.tar.gz +0 -0
  79. data/support/cookbooks/ark/files/default/foo.tbz +0 -0
  80. data/support/cookbooks/ark/files/default/foo.tgz +0 -0
  81. data/support/cookbooks/ark/files/default/foo.zip +0 -0
  82. data/support/cookbooks/ark/files/default/tests/minitest/default_test.rb +0 -0
  83. data/support/cookbooks/ark/files/default/tests/minitest/support/helpers.rb +0 -0
  84. data/support/cookbooks/ark/files/default/tests/minitest/test_test.rb +94 -0
  85. data/support/cookbooks/ark/libraries/default.rb +167 -0
  86. data/support/cookbooks/ark/metadata.rb +13 -0
  87. data/support/cookbooks/ark/providers/default.rb +370 -0
  88. data/support/cookbooks/ark/recipes/default.rb +31 -0
  89. data/support/cookbooks/ark/recipes/test.rb +138 -0
  90. data/support/cookbooks/ark/resources/default.rb +54 -0
  91. data/support/cookbooks/ark/templates/default/add_to_path.sh.erb +1 -0
  92. data/support/cookbooks/ark/test/support/Gemfile +4 -0
  93. data/support/cookbooks/build-essential/README.md +24 -0
  94. data/support/cookbooks/build-essential/metadata.rb +10 -0
  95. data/support/cookbooks/build-essential/recipes/default.rb +45 -0
  96. data/support/cookbooks/chruby/.gitignore +15 -0
  97. data/support/cookbooks/chruby/.kitchen.yml +26 -0
  98. data/support/cookbooks/chruby/.ruby_version +1 -0
  99. data/support/cookbooks/chruby/Berksfile +3 -0
  100. data/support/cookbooks/chruby/Gemfile +7 -0
  101. data/support/cookbooks/chruby/LICENSE +14 -0
  102. data/support/cookbooks/chruby/README.md +92 -0
  103. data/support/cookbooks/chruby/Rakefile +7 -0
  104. data/support/cookbooks/chruby/Thorfile +6 -0
  105. data/support/cookbooks/chruby/Vagrantfile +86 -0
  106. data/support/cookbooks/chruby/attributes/default.rb +10 -0
  107. data/support/cookbooks/chruby/chefignore +96 -0
  108. data/support/cookbooks/chruby/metadata.rb +11 -0
  109. data/support/cookbooks/chruby/recipes/default.rb +43 -0
  110. data/support/cookbooks/chruby/recipes/system.rb +25 -0
  111. data/support/cookbooks/chruby/templates/default/chruby.sh.erb +22 -0
  112. data/support/cookbooks/chruby/test/integration/default/bash/embedded_test.sh +1 -0
  113. data/support/cookbooks/git/.gitignore +14 -0
  114. data/support/cookbooks/git/.kitchen.yml +46 -0
  115. data/support/cookbooks/git/Berksfile +8 -0
  116. data/support/cookbooks/git/CHANGELOG.md +87 -0
  117. data/support/cookbooks/git/CONTRIBUTING +29 -0
  118. data/support/cookbooks/git/Gemfile +3 -0
  119. data/support/cookbooks/git/LICENSE +201 -0
  120. data/support/cookbooks/git/README.md +115 -0
  121. data/support/cookbooks/git/TESTING.md +25 -0
  122. data/support/cookbooks/git/attributes/default.rb +40 -0
  123. data/support/cookbooks/git/metadata.rb +35 -0
  124. data/support/cookbooks/git/recipes/default.rb +53 -0
  125. data/support/cookbooks/git/recipes/server.rb +58 -0
  126. data/support/cookbooks/git/recipes/source.rb +49 -0
  127. data/support/cookbooks/git/recipes/windows.rb +37 -0
  128. data/support/cookbooks/git/templates/default/git-xinetd.d.erb +10 -0
  129. data/support/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +2 -0
  130. data/support/cookbooks/git/templates/default/sv-git-daemon-run.erb +3 -0
  131. data/support/cookbooks/install_ruby/README.md +3 -0
  132. data/support/cookbooks/install_ruby/metadata.rb +10 -0
  133. data/support/cookbooks/install_ruby/recipes/default.rb +14 -0
  134. data/support/cookbooks/ruby_build/.gitignore +6 -0
  135. data/support/cookbooks/ruby_build/.kitchen.yml +31 -0
  136. data/support/cookbooks/ruby_build/.travis.yml +4 -0
  137. data/support/cookbooks/ruby_build/Berksfile +10 -0
  138. data/support/cookbooks/ruby_build/CHANGELOG.md +72 -0
  139. data/support/cookbooks/ruby_build/Gemfile +14 -0
  140. data/support/cookbooks/ruby_build/README.md +338 -0
  141. data/support/cookbooks/ruby_build/Rakefile +21 -0
  142. data/support/cookbooks/ruby_build/attributes/default.rb +67 -0
  143. data/support/cookbooks/ruby_build/chefignore +53 -0
  144. data/support/cookbooks/ruby_build/libraries/ruby_build_recipe_helpers.rb +40 -0
  145. data/support/cookbooks/ruby_build/metadata.rb +18 -0
  146. data/support/cookbooks/ruby_build/providers/ruby.rb +88 -0
  147. data/support/cookbooks/ruby_build/recipes/default.rb +69 -0
  148. data/support/cookbooks/ruby_build/resources/ruby.rb +33 -0
  149. data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/metadata.rb +10 -0
  150. data/support/cookbooks/ruby_build/test/cookbooks/alltherubies/recipes/default.rb +59 -0
  151. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/_verify_tests.bash +33 -0
  152. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.8.7.bats +29 -0
  153. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.2.bats +18 -0
  154. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_1.9.3.bats +18 -0
  155. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_2.0.0.bats +18 -0
  156. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_jruby.bats +20 -0
  157. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_rbx.bats +18 -0
  158. data/support/cookbooks/ruby_build/test/integration/alltherubies/bats/verify_ree.bats +19 -0
  159. data/support/cookbooks/ruby_build/test/integration/installation/bats/installation.bats +6 -0
  160. data/support/scripts/libsodium_ubuntu.sh +80 -0
  161. data/support/tasks/.gitkeep +0 -0
  162. data/support/tasks/libsodium_install.rb +57 -0
  163. data/vault-tree.gemspec +26 -0
  164. metadata +305 -0
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env rake
2
+ require 'foodcritic'
3
+
4
+ begin
5
+ require 'emeril/rake'
6
+ rescue LoadError
7
+ puts ">>>>> Emeril gem not loaded, omitting tasks" unless ENV['CI']
8
+ end
9
+
10
+ FoodCritic::Rake::LintTask.new do |t|
11
+ t.options = { :fail_tags => ['any'] }
12
+ end
13
+
14
+ begin
15
+ require 'kitchen/rake_tasks'
16
+ Kitchen::RakeTasks.new
17
+ rescue LoadError
18
+ puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
19
+ end
20
+
21
+ task :default => [:foodcritic]
@@ -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,53 @@
1
+ # Put files/directories that should be ignored in this file.
2
+ # Lines that start with '# ' are comments.
3
+
4
+ ## OS
5
+ .DS_Store
6
+ Icon?
7
+ nohup.out
8
+
9
+ ## EDITORS
10
+ \#*
11
+ .#*
12
+ *~
13
+ *.sw[a-z]
14
+ *.bak
15
+ REVISION
16
+ TAGS*
17
+ tmtags
18
+ *_flymake.*
19
+ *_flymake
20
+ *.tmproj
21
+ .project
22
+ .settings
23
+ mkmf.log
24
+
25
+ ## COMPILED
26
+ a.out
27
+ *.o
28
+ *.pyc
29
+ *.so
30
+
31
+ ## OTHER SCM
32
+ */.bzr/*
33
+ */.hg/*
34
+ */.svn/*
35
+
36
+ ## Don't send rspecs up in cookbook
37
+ .watchr
38
+ .rspec
39
+ spec/*
40
+ spec/fixtures/*
41
+ test/*
42
+ features/*
43
+
44
+ ## SCM
45
+ .gitignore
46
+
47
+ # Berkshelf
48
+ Berksfile
49
+ Berksfile.lock
50
+ cookbooks/*
51
+
52
+ # Vagrant
53
+ .vagrant
@@ -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,18 @@
1
+ name "ruby_build"
2
+ maintainer "Fletcher Nichol"
3
+ maintainer_email "fnichol@nichol.ca"
4
+ license "Apache 2.0"
5
+ description "Manages the ruby-build framework and its installed rubies. A LWRP is also defined."
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version "0.8.1"
8
+
9
+ supports "ubuntu"
10
+ supports "debian"
11
+ supports "freebsd"
12
+ supports "redhat"
13
+ supports "centos"
14
+ supports "fedora"
15
+ supports "amazon"
16
+ supports "scientific"
17
+ supports "suse"
18
+ supports "mac_os_x"
@@ -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,10 @@
1
+ name "alltherubies"
2
+ maintainer "Fletcher Nichol"
3
+ maintainer_email "fnichol@nichol.ca"
4
+ license "Apache 2.0"
5
+ description "Installs all-the-rubies via ruby_build cookbook"
6
+ long_description "Everything must be installed"
7
+ version "0.1.0"
8
+
9
+ depends "java"
10
+ depends "user"
@@ -0,0 +1,59 @@
1
+ #
2
+ # Cookbook Name:: alltherubies
3
+ # Recipe:: default
4
+ #
5
+ # Copyright 2012, 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
+ cores = node['cpu']['total'].to_i
21
+ system_rubies = %w{ 1.9.2-p320 1.9.3-p362 2.0.0-preview2
22
+ jruby-1.7.1 rbx-2.0.0-rc1 }
23
+
24
+ include_recipe "java"
25
+
26
+ if %{ubuntu debian}.include?(node['platform'])
27
+ package "default-jre-headless"
28
+ end
29
+
30
+ log "Forcing update of java alternatives" do
31
+ notifies :create, "ruby_block[update-java-alternatives]", :immediately
32
+ end
33
+
34
+ system_rubies.each do |rubie|
35
+ ruby_build_ruby rubie do
36
+ environment({ 'MAKE_OPTS' => "-j #{cores + 1}" })
37
+ end
38
+ end
39
+
40
+ # Woah, REE, crazy bananas! For more details see:
41
+ # * https://github.com/sstephenson/rbenv/issues/297
42
+ # * https://github.com/sstephenson/ruby-build/issues/186
43
+ ruby_build_ruby "ree-1.8.7-2012.02" do
44
+ environment({
45
+ 'MAKE_OPTS' => "-j #{cores + 1}",
46
+ 'CONFIGURE_OPTS' => "--no-tcmalloc",
47
+ })
48
+ end
49
+
50
+ user_account "app" do
51
+ home "/home/app"
52
+ end
53
+
54
+ ruby_build_ruby "1.8.7-p371" do
55
+ prefix_path "/home/app/.rubies/ruby-1.8.7-p371"
56
+ user "app"
57
+ group "app"
58
+ environment({ 'MAKE_OPTS' => "-j #{cores + 1}" })
59
+ end