From c00e87669721c40c888123609a9269d20012a18e Mon Sep 17 00:00:00 2001 From: Myles Megyesi Date: Fri, 20 Sep 2013 19:06:31 -0500 Subject: [PATCH 1/4] adds the option to specifiy the location and owner the generated chruby.sh file --- attributes/default.rb | 2 ++ recipes/default.rb | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 1b68123..c1b96d3 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -6,3 +6,5 @@ default['chruby']['rubies'] = {'1.9.3-p392' => true} default['chruby']['default'] = 'embedded' default['chruby']['user_rubies'] = {} +default['chruby']['sh_dir'] = "/etc/profile.d" +default['chruby']['sh_name'] = 'chruby.sh' diff --git a/recipes/default.rb b/recipes/default.rb index 7c46ee1..24ab8d7 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -26,14 +26,18 @@ # Workaround for Github issue 5 https://github.com/Atalanta/chef-chruby/issues/5 link "/usr/local/chruby" do - to "/usr/local/chruby-1" -end + to "/usr/local/chruby-1" +end + +sh_owner = node['chruby']['sh_owner'] -directory "/etc/profile.d" do +directory node['chruby']['sh_dir'] do recursive true + owner sh_owner if sh_owner end -template "/etc/profile.d/chruby.sh" do +template File.join(node['chruby']['sh_dir'], node['chruby']['sh_name']) do source "chruby.sh.erb" mode "0644" + owner sh_owner if sh_owner end From 1719652784e19d87dc165fb9d4b503ab3cafb873 Mon Sep 17 00:00:00 2001 From: pseudomuto Date: Tue, 14 Jan 2014 15:18:13 -0500 Subject: [PATCH 2/4] adding user_rubies attribute for custom paths --- README.md | 5 +++-- attributes/default.rb | 2 +- templates/default/chruby.sh.erb | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9d673c..7b42782 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ Ensure you set an explicit dependency on the `chruby` cookbook if you are using - `node['chruby']['auto_switch']` - enable automatic switching between Ruby versions per https://github.com/postmodern/chruby#auto-switching - `node['chruby']['rubies']` - an hash of Rubies / Booleans values to install using the `ruby-build` LWRP, and make available to chruby. - `node['chruby']['default']` - specify the default Ruby version for every shell. - +- `node['chruby']['user_rubies']` - an array of directories containing custom rubies + # Recipes ## Default @@ -77,7 +78,7 @@ Builds and makes available the Ruby versions listed in the `node['chruby']['rubi - Author: Stephen Nelson-Smith (LordCope) - Atalanta Systems Ltd () -Copyright 2013, Atalanta Systems Ltd +Copyright 2013, Atalanta Systems Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/attributes/default.rb b/attributes/default.rb index c1b96d3..6f751ba 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -5,6 +5,6 @@ default['chruby']['auto_switch'] = true default['chruby']['rubies'] = {'1.9.3-p392' => true} default['chruby']['default'] = 'embedded' -default['chruby']['user_rubies'] = {} +default['chruby']['user_rubies'] = [] default['chruby']['sh_dir'] = "/etc/profile.d" default['chruby']['sh_name'] = 'chruby.sh' diff --git a/templates/default/chruby.sh.erb b/templates/default/chruby.sh.erb index b71cd55..3447461 100644 --- a/templates/default/chruby.sh.erb +++ b/templates/default/chruby.sh.erb @@ -12,6 +12,10 @@ RUBIES+=($HOME/.rvm/rubies/*) RUBIES+=($HOME/.rbenv/rubies/*) <% end -%> +<% node['chruby']['user_rubies'].each do |directory| -%> +RUBIES+=(<%= directory.sub(/\/\z/, '') %>/*) +<% end -%> + <% if ::File.exists?("/opt/chef/embedded") and node['chruby']['default'] == "embedded" -%> chruby embedded <% elsif node['chruby']['default'] -%> From e3eee03d0a775a12aa4a555d25b67a3aa3cd3c48 Mon Sep 17 00:00:00 2001 From: jtimberman Date: Thu, 17 Apr 2014 15:19:34 -0700 Subject: [PATCH 3/4] support chefdk's ruby Support the embedded Ruby in ChefDK if it is present. http://www.getchef.com/downloads/chef-dk/ --- templates/default/chruby.sh.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/default/chruby.sh.erb b/templates/default/chruby.sh.erb index 3447461..d92f775 100644 --- a/templates/default/chruby.sh.erb +++ b/templates/default/chruby.sh.erb @@ -1,5 +1,9 @@ source /usr/local/chruby/share/chruby/chruby.sh +<% if ::File.exists?("/opt/chefdk/embedded") -%> +RUBIES+=(/opt/chefdk/embedded) +<% end -%> + <% if ::File.exists?("/opt/chef/embedded") -%> RUBIES+=(/opt/chef/embedded) <% end -%> @@ -16,7 +20,7 @@ RUBIES+=($HOME/.rbenv/rubies/*) RUBIES+=(<%= directory.sub(/\/\z/, '') %>/*) <% end -%> -<% if ::File.exists?("/opt/chef/embedded") and node['chruby']['default'] == "embedded" -%> +<% if (::File.exists?("/opt/chef/embedded") or ::File.exists?("/opt/chefdk/embedded")) and node['chruby']['default'] == "embedded" -%> chruby embedded <% elsif node['chruby']['default'] -%> chruby <%= node['chruby']['default'] %> From 313886c139e34de5fcee089834af64023d44c96a Mon Sep 17 00:00:00 2001 From: Chris Aumann Date: Wed, 14 Jan 2015 15:56:10 +0100 Subject: [PATCH 4/4] Update default chruby version to 0.3.9 This fixes some nasty bugs --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 6f751ba..2a37079 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,4 +1,4 @@ -default['chruby']['version'] = '0.3.4' +default['chruby']['version'] = '0.3.9' default['chruby']['gpg_check'] = false default['chruby']['use_rvm_rubies'] = false default['chruby']['use_rbenv_rubies'] = false