From 5e4c8fd8351159ba0b3da4d5e07a7d8b2521f6ee 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 c8a96269abb496a86dc78b248f0765b598c6440f 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 11a3d6f73f1b59d7ac8a103377fa9dcaa3bab100 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 5c1265aa295aabc674d57c36f1509590b5140410 Mon Sep 17 00:00:00 2001 From: Chris Aumann Date: Wed, 14 Jan 2015 15:55:59 +0100 Subject: [PATCH 4/4] Use version attribute when installing chruby --- recipes/default.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/default.rb b/recipes/default.rb index 24ab8d7..2b2a2b2 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -20,13 +20,14 @@ ark "chruby" do url "https://github.com/postmodern/chruby/archive/v#{node['chruby']['version']}.tar.gz" + version node['chruby']['version'] action :install_with_make end # Workaround for Github issue 5 https://github.com/Atalanta/chef-chruby/issues/5 link "/usr/local/chruby" do - to "/usr/local/chruby-1" + to "/usr/local/chruby-#{node['chruby']['version']}" end sh_owner = node['chruby']['sh_owner']