From 23d9e1424ab694e05b22af23fdfd049e0be8efef Mon Sep 17 00:00:00 2001 From: Joshua Timberman Date: Thu, 26 Jun 2014 12:43:54 -0400 Subject: [PATCH] #39 - Implement attribute to control auto-update Signed-off-by: Sean OMeara --- README.md | 2 +- attributes/default.rb | 1 + recipes/default.rb | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cc70d1b..82ad79b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The only platform supported by Homebrew itself at the time of this writing is Ma Attributes ---------- - `node['homebrew']['owner']` - The user that will own the Homebrew installation and packages. Setting this will override the default behavior which is to use the non-privileged user that has invoked the Chef run (or the `SUDO_USER` if invoked with sudo). The default is `nil`. - +- `node['homebrew']['auto-update']` - Whether the default recipe should automatically update homebrew each run or not. The default is `true` to maintain compatibility. Set to false or nil to disable. Note that disabling this feature may cause formula to not work. Resources and Providers ----------------------- diff --git a/attributes/default.rb b/attributes/default.rb index 084e2d9..4defadd 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -20,3 +20,4 @@ # default['homebrew']['owner'] = nil +default['homebrew']['auto-update'] = true diff --git a/recipes/default.rb b/recipes/default.rb index d9d4717..fc4cf97 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -36,11 +36,13 @@ not_if { ::File.exist? '/usr/local/bin/brew' } end -package 'git' do - not_if 'which git' -end +if node['homebrew']['auto-update'] + package 'git' do + not_if 'which git' + end -execute 'update homebrew from github' do - user owner - command '/usr/local/bin/brew update || true' + execute 'update homebrew from github' do + user owner + command '/usr/local/bin/brew update || true' + end end