diff --git a/README.md b/README.md index cc1d5b4..a15da9b 100644 --- a/README.md +++ b/README.md @@ -1,115 +1,98 @@ -# Description +Homebrew Cookbook +================= +This cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) and replaces MacPorts as the *default package provider* for the package resource on OS X systems. -This cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) -and replaces MacPorts as the *default package provider* for the -package resource on OS X systems. - -This cookbook is now maintained by Opscode. The original author, -maintainer and copyright holder is Graeme Mathieson. The cookbook -remains licensed under the Apache License version 2. +This cookbook is now maintained by Opscode. The original author, maintainer and copyright holder is Graeme Mathieson. The cookbook remains licensed under the Apache License version 2. [Original blog post by Graeme](http://woss.name/2011/01/23/converging-your-home-directory-with-chef/) -# Requirements -## Prerequisites +Requirements +------------ +### Prerequisites -In order for this recipe to work, your userid must own `/usr/local`. -This is outside the scope of the cookbook because it's anticipated -that you'll run the cookbook as your own user, not root and you'd have -to be root to take ownership of the directory. Easiest way to get -started: +In order for this recipe to work, your userid must own `/usr/local`. This is outside the scope of the cookbook because it's anticipated that you'll run the cookbook as your own user, not root and you'd have to be root to take ownership of the directory. Easiest way to get started: - sudo chown -R `whoami`:staff /usr/local +```bash +sudo chown -R `whoami`:staff /usr/local +``` -Bear in mind that this will take ownership of the entire folder and its -contents, so if you've already got stuff in there (eg MySQL owned by a -`mysql` user) you'll need to be a touch more careful. This is a -recommendation from the Homebrew +Bear in mind that this will take ownership of the entire folder and its contents, so if you've already got stuff in there (eg MySQL owned by a `mysql` user) you'll need to be a touch more careful. This is a recommendation from Homebrew. -## Platform +### Platform -* Mac OS X (10.6+) +- Mac OS X (10.6+) -The only platform supported by Homebrew itself at the time of this -writing is Mac OS X. It should work fine on Server edition as well, -and on platforms that Homebrew supports in the future. +The only platform supported by Homebrew itself at the time of this writing is Mac OS X. It should work fine on Server edition as well, and on platforms that Homebrew supports in the future. -# 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`. +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`. -# Resources and Providers -## package / homebrew\_package +Resources and Providers +----------------------- +### package / homebrew\_package -This cookbook provides a package provider called `homebrew_package` -which will install/remove packages using Homebrew. This becomes the -default provider for `package` if your platform is Mac OS X. +This cookbook provides a package provider called `homebrew_package` which will install/remove packages using Homebrew. This becomes the default provider for `package` if your platform is Mac OS X. -As this extends the built-in package resource/provider in Chef, it has -all the resource attributes and actions available to the package -resource. However, a couple notes: +As this extends the built-in package resource/provider in Chef, it has all the resource attributes and actions available to the package resource. However, a couple notes: -* Homebrew itself doesn't have a notion of "upgrade" per se. The - "upgrade" action will simply perform an install, and if the Homebrew - Formula for the package is newer, it will upgrade. -* Likewise, Homebrew doesn't have a purge, but the "purge" action will - act like "remove". +- Homebrew itself doesn't have a notion of "upgrade" per se. The "upgrade" action will simply perform an install, and if the Homebrew Formula for the package is newer, it will upgrade. +- Likewise, Homebrew doesn't have a purge, but the "purge" action will act like "remove". -### Examples +#### Examples - package "mysql" do - action :install - end +```ruby +package 'mysql' do + action :install +end - homebrew_package "mysql" +homebrew_package 'mysql' - package "mysql" do - provider Chef::Provider::Package::Homebrew - end +package 'mysql' do + provider Chef::Provider::Package::Homebrew +end +``` -## homebrew\_tap +### homebrew\_tap -LWRP for `brew tap`, a Homebrew command used to add additional formula -repositories. From the `brew` man page: +LWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page: - tap [tap] - Tap a new formula repository from GitHub, or list existing taps. +```text +tap [tap] + Tap a new formula repository from GitHub, or list existing taps. - tap is of the form user/repo, e.g. brew tap homebrew/dupes. + tap is of the form user/repo, e.g. brew tap homebrew/dupes. +``` -Default action is `:tap` which enables the repository. Use `:untap` to -disable a tapped repository. +Default action is `:tap` which enables the repository. Use `:untap` to disable a tapped repository. -### Examples +#### Examples - homebrew_tap "homebrew/dupes" +```ruby +homebrew_tap 'homebrew/dupes' - homebrew_tap "homebrew/dupes" do - action :untap - end +homebrew_tap 'homebrew/dupes' do + action :untap +end +``` -# Usage -We strongly recommend that you put "recipe[homebrew]" in your node's -run list, to ensure that it is available on the system and that -Homebrew itself gets installed. Putting an explicit dependency in the -metadata will cause the cookbook to be downloaded and the library -loaded, thus resulting in changing the package provider on Mac OS X, -so if you have systems you want to use the default (Mac Ports), they -would be changed to Homebrew. +Usage +----- +We strongly recommend that you put "recipe[homebrew]" in your node's run list, to ensure that it is available on the system and that Homebrew itself gets installed. Putting an explicit dependency in the metadata will cause the cookbook to be downloaded and the library loaded, thus resulting in changing the package provider on Mac OS X, so if you have systems you want to use the default (Mac Ports), they would be changed to Homebrew. The default itself ensures that Homebrew is installed and up to date. -# License and Author -Author:: Graeme Mathieson () -Author:: Joshua Timberman () +License and Authors +------------------- +- Author:: Graeme Mathieson () +- Author:: Joshua Timberman () +```text Copyright:: 2011, Graeme Mathieson Copyright:: 2012, Opscode, Inc @@ -124,3 +107,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +``` diff --git a/attributes/default.rb b/attributes/default.rb index 4f0cf7b..084e2d9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1 +1,22 @@ +# +# Author:: Joshua Timberman () +# Author:: Graeme Mathieson () +# Cookbook Name:: homebrew +# Attributes:: default +# +# Copyright 2011-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + default['homebrew']['owner'] = nil diff --git a/libraries/homebrew_mixin.rb b/libraries/homebrew_mixin.rb index 536cb5e..211b25b 100644 --- a/libraries/homebrew_mixin.rb +++ b/libraries/homebrew_mixin.rb @@ -1,3 +1,24 @@ +# +# Author:: Joshua Timberman () +# Author:: Graeme Mathieson () +# Cookbook Name:: homebrew +# Libraries:: homebrew_mixin +# +# Copyright 2011-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + module Homebrew module Mixin diff --git a/libraries/homebrew_package.rb b/libraries/homebrew_package.rb index 99e5b6c..b46bed8 100644 --- a/libraries/homebrew_package.rb +++ b/libraries/homebrew_package.rb @@ -1,4 +1,23 @@ -# Chef package provider for Homebrew +# +# Author:: Joshua Timberman () +# Author:: Graeme Mathieson () +# Cookbook Name:: homebrew +# Libraries:: homebrew_package +# +# Copyright 2011-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# require 'chef/provider/package' require 'chef/resource/package' diff --git a/providers/tap.rb b/providers/tap.rb index 31369e4..b5d6ea2 100644 --- a/providers/tap.rb +++ b/providers/tap.rb @@ -1,3 +1,24 @@ +# +# Author:: Joshua Timberman () +# Author:: Graeme Mathieson () +# Cookbook Name:: homebrew +# Providers:: tap +# +# Copyright 2011-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + def load_current_resource @tap = Chef::Resource::HomebrewTap.new(new_resource.name) tap_dir = @tap.name.gsub('/', '-') diff --git a/recipes/default.rb b/recipes/default.rb index b7b2e61..8f27134 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,3 +1,24 @@ +# +# Author:: Joshua Timberman () +# Author:: Graeme Mathieson () +# Cookbook Name:: homebrew +# Recipes:: default +# +# Copyright 2011-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + self.extend(Homebrew::Mixin) homebrew_go = "#{Chef::Config[:file_cache_path]}/homebrew_go" diff --git a/resources/tap.rb b/resources/tap.rb index 4f74691..2f85a56 100644 --- a/resources/tap.rb +++ b/resources/tap.rb @@ -1,3 +1,24 @@ +# +# Author:: Joshua Timberman () +# Author:: Graeme Mathieson () +# Cookbook Name:: homebrew +# Resources:: tap +# +# Copyright 2011-2013, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + actions :tap, :untap attribute :name, :name_attribute => true,