From 77bf0f2a8b11c08371f6b812eacd41d1bb19e8e0 Mon Sep 17 00:00:00 2001 From: Jean Rouge Date: Wed, 4 Nov 2015 08:46:26 -0800 Subject: [PATCH] Make it possible to specify a checksum for the `ark` resource Which allows to avoid re-downloading the chruby archive from Github at every single Chef-client run; which, besides being nice to Github, avoids stalling Chef on nodes running this cookbook when Github is down. By default though, the `checksum` attribute is set to `nil` (and hence not used) to maintain backward compatibility with existing wrapper cookbooks. Also properly setting the `version` attribute of the `ark` resource, mainly for cosmetic reasons. Updated the README. --- README.md | 1 + attributes/default.rb | 1 + recipes/default.rb | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b42782..3a77ddd 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Ensure you set an explicit dependency on the `chruby` cookbook if you are using # Attributes - `node['chruby']['version']` - the version of Chruby to install. Default is 0.3.4. +- `node['chruby']['checksum']` - the SHA256 checksum of the archive downloaded from github; allows to avoid downloading from Github at every Chef run. Default is `nil` (mainly for backward compatibility with existing wrapper cookbooks) - TODO: `node['chruby']['gpg_check']` - run the GPG check to verify the release was not tampered with. - `node['chruby']['use_rvm_rubies']` - make Rubies installed using RVM available to chruby. - `node['chruby']['use_rbenv_rubies']` - make Rubies installed using Rbenv available to chruby. diff --git a/attributes/default.rb b/attributes/default.rb index 6f751ba..3159edb 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,4 +1,5 @@ default['chruby']['version'] = '0.3.4' +default['chruby']['checksum'] = nil default['chruby']['gpg_check'] = false default['chruby']['use_rvm_rubies'] = false default['chruby']['use_rbenv_rubies'] = false diff --git a/recipes/default.rb b/recipes/default.rb index 24ab8d7..9e3c7e3 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -20,13 +20,15 @@ ark "chruby" do url "https://github.com/postmodern/chruby/archive/v#{node['chruby']['version']}.tar.gz" + version node['chruby']['version'] + checksum node['chruby']['checksum'] 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']