Vendor the external cookbooks
Knife-Zero doesn't include Berkshelf support, so vendoring everything in the repo is convenient again
This commit is contained in:
200
cookbooks/homebrew/CHANGELOG.md
Normal file
200
cookbooks/homebrew/CHANGELOG.md
Normal file
@@ -0,0 +1,200 @@
|
||||
# homebrew Cookbook CHANGELOG
|
||||
|
||||
This file is used to list changes made in each version of the homebrew cookbook.
|
||||
|
||||
## 3.0.0 (2016-12-19)
|
||||
|
||||
- The homebrew package provider has been removed from this cookbook. It ships with Chef 12.0+. This cookbook now requires a minimum of Chef 12.1 or later.
|
||||
- This cookbook no longer depends on build-essential as it wasn't using it directly
|
||||
- Properly define the chefspec matchers
|
||||
- Add chef_version metadata and remove OS X server which isn't an actual platform from ohai
|
||||
- Don't grab homebrew_go script if homebrew is already installed.
|
||||
- Add ability to disable sending analytics data via a new attribute
|
||||
- Move testing to a test cookbook to make it easier to expand in the future. Also convert integration tests to InSpec from ServerSpec
|
||||
|
||||
## 2.1.2 (2016-09-07)
|
||||
|
||||
- Allow passing custom options to brew packages
|
||||
|
||||
## 2.1.1 (2016-09-06)
|
||||
|
||||
- Run chefspecs as OS X
|
||||
- Update cask recipe to not create /opt/homebrew-cask and /opt/homebrew-cask/Caskroom
|
||||
- Update tests
|
||||
|
||||
## v2.1.0 (2016-03-29)
|
||||
|
||||
- Make homebrew install script url configurable
|
||||
- Make package_info more efficient
|
||||
|
||||
## v2.0.5 (2016-01-25)
|
||||
|
||||
- Updated execute resources to pass in the HOME/USER environmental variables so homebrew commands are properly executed
|
||||
- Removed redundant code from recipes and providers
|
||||
- Removed brew-cask installation and the upgade execute that are no longer necessary
|
||||
- Added directory creation of /Library/Caches/Homebrew/Casks in case it's not present
|
||||
- Updated creation of /opt/homebrew-cask to be recursive in case /opt hasn't been created yet
|
||||
|
||||
## v2.0.4 (2016-01-20)
|
||||
|
||||
- Use the officially supported method of querying homebrew data vs. unsupported internal APIs
|
||||
- Fixed environmental variables in the homebrew command execution
|
||||
|
||||
## v2.0.3 (2015-12-09)
|
||||
|
||||
- Fixed poor name matching in determining if a cask had been installed already, which prevented some casks from installing
|
||||
|
||||
## v2.0.2 (2015-12-04)
|
||||
|
||||
- Prevents casks from installing on every chef run
|
||||
|
||||
## v2.0.1 (2015-12-03)
|
||||
|
||||
- Fixed already-installed casks breaking builds
|
||||
|
||||
## v2.0.0 (2015-12-01)
|
||||
|
||||
- Removed all Chef 10 compatibility code
|
||||
- 77 Update the tap provider to properly notify on changes
|
||||
- 73 Allow specifying versions (or HEAD) of formulas (see readme for usage)
|
||||
- Updated contributing, testing, and maintainers docs
|
||||
- Updated contents of chefignore and .gitignore files
|
||||
- Updated development dependencies in the Gemfile
|
||||
- Added Travis CI and supermarket version badges to the readme
|
||||
- Added Chef standard rubocop file and resolved all warnings
|
||||
- Added super metadata for Supermarket
|
||||
- Added testing in Travis CI
|
||||
- 75 Fix Chefspecs to properly run on Linux hosts (like Travis)
|
||||
- Add Rakefile for simplified testing
|
||||
- Resolved all foodcritic warnings
|
||||
|
||||
## v1.13.0 (2015-06-23)
|
||||
|
||||
- 72 Massage Chef12HomebrewUser.find_homebrew_uid into username
|
||||
- 69 Add options to cask
|
||||
|
||||
## v1.12.0 (2015-01-29)
|
||||
|
||||
- 67 Add attribute and recipe for installing homebrew taps
|
||||
|
||||
## v1.11.0 (2015-01-12)
|
||||
|
||||
- 59 Update Homebrew Cask if auto-update attribute is true
|
||||
- 52 Manage Homebrew Cask's install directories
|
||||
- 56 Fix check for existing casks
|
||||
- 61 Fix owner class for Chef 12
|
||||
- Depend on build-essential cookbook 2.1.2+ to support OS X 10.10
|
||||
- 64, #66 add and fix ChefSpec tests for default recipe
|
||||
|
||||
## v1.10.0 (2014-12-09)
|
||||
|
||||
- 55 This cookbook no longer sets its `homebrew_package` as the
|
||||
- `package` provider for OS X when running under Chef 12
|
||||
- List CHEF as the maintainer instead of Chef.
|
||||
|
||||
## v1.9.2 (2014-10-09)
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- 57 Update url per homebrew error: Upstream, the homebrew project
|
||||
- has changed the URL for the installation script. All users of this
|
||||
- cookbook are advised to update to this version.
|
||||
|
||||
## v1.9.0 (2014-07-29)
|
||||
|
||||
Improvements:
|
||||
|
||||
- 35 Modernize the cask provider (use why run mode, inline resources)
|
||||
- 43 Use `brew cask list` to determine if casks are installed
|
||||
- 45 Add `default_action` and print warning messages on earlier
|
||||
- versions of Chef (10.10)
|
||||
|
||||
New Features:
|
||||
|
||||
- 44 Add `:install` and `:uninstall` actions and alias previous `:cask`,
|
||||
- `:uncask` actions to them
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
- 27 Fix name for taps adding the `/homebrew` prefix
|
||||
- 28 Set `RUBYOPT` to `nil` so Chef can execute in a bundle (bundler
|
||||
- sets `RUBYOPT` and this can cause issues when running the
|
||||
- underlying `brew` commands)
|
||||
- 40 Fix regex for cask to match current homebrew conventions
|
||||
- 42 Fix attribute for list of formulas to match the README and
|
||||
- maintain backward compat for 6 day old version
|
||||
|
||||
## v1.8.0 (2014-07-23)
|
||||
|
||||
- Add recipes to install an array of formulas/casks
|
||||
|
||||
## v1.7.2 (2014-06-26)
|
||||
|
||||
- Implement attribute to control auto-update
|
||||
|
||||
## v1.7.0 (2014-06-26)
|
||||
|
||||
# 38 - Add homebrew::cask recipe
|
||||
|
||||
## v1.6.6 (2014-05-29)
|
||||
|
||||
- [COOK-3283] Use homebrew_owner for cask and tap
|
||||
- [COOK-4670] homebrew_tap provider is not idempotent
|
||||
- [COOK-4671] Syntax Error in README
|
||||
|
||||
## v1.6.4 (2014-05-08)
|
||||
|
||||
- Fixing cask provider correctly this time. "brew cask list"
|
||||
|
||||
## v1.6.2 (2014-05-08)
|
||||
|
||||
- Fixing typo in cask provider: 's/brew brew/brew/'
|
||||
|
||||
## v1.6.0 (2014-04-23)
|
||||
|
||||
- [COOK-3960] Added LWRP for brew cask
|
||||
- [COOK-4508] Add ChefSpec matchers for homebrew_tap
|
||||
- [COOK-4566] Guard against "HEAD only" formulae
|
||||
|
||||
## v1.5.4
|
||||
|
||||
- [COOK-4023] Fix installer script's URL.
|
||||
- Fixing up style for rubocop
|
||||
|
||||
## v1.5.2
|
||||
|
||||
- [COOK-3825] setting $HOME on homebrew_package
|
||||
|
||||
## v1.5.0
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3589](https://tickets.chef.io/browse/COOK-3589)** - Add homebrew as the default package manager on OS X Server
|
||||
|
||||
## v1.4.0
|
||||
|
||||
### Bug
|
||||
|
||||
- **[COOK-3283](https://tickets.chef.io/browse/COOK-3283)** - Support running homebrew cookbook as root user, with sudo, or a non-privileged user
|
||||
|
||||
## v1.3.2
|
||||
|
||||
- [COOK-1793] - use homebrew "go" script to install homebrew
|
||||
- [COOK-1821] - Discovered version using Homebrew Formula factory fails check that verifies that version is a String
|
||||
- [COOK-1843] - Homebrew README.md contains non-ASCII characters, triggering same issue as COOK-522
|
||||
|
||||
## v1.3.0
|
||||
|
||||
- [COOK-1425] - use new json output format for formula
|
||||
- [COOK-1578] - Use shell_out! instead of popen4
|
||||
|
||||
## v1.2.0
|
||||
|
||||
Chef Software has taken maintenance of this cookbook as the original author has other commitments. This is the initial release with Chef Software as maintainer.
|
||||
|
||||
Changes in this release:
|
||||
|
||||
- [pull/2] - support for option passing to brew
|
||||
- [pull/3] - add brew upgrade and control return value from command
|
||||
- [pull/9] - added LWRP for "brew tap"
|
||||
- README is now markdown, not rdoc.
|
||||
2
cookbooks/homebrew/CONTRIBUTING.md
Normal file
2
cookbooks/homebrew/CONTRIBUTING.md
Normal file
@@ -0,0 +1,2 @@
|
||||
Please refer to
|
||||
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
|
||||
15
cookbooks/homebrew/MAINTAINERS.md
Normal file
15
cookbooks/homebrew/MAINTAINERS.md
Normal file
@@ -0,0 +1,15 @@
|
||||
<!-- This is a generated file. Please do not edit directly -->
|
||||
|
||||
# Maintainers
|
||||
|
||||
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
|
||||
|
||||
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
|
||||
|
||||
# Project Maintainer
|
||||
* [Tim Smith](https://github.com/tas50)
|
||||
|
||||
# Maintainers
|
||||
* [Jennifer Davis](https://github.com/sigje)
|
||||
* [Tim Smith](https://github.com/tas50)
|
||||
* [Thom May](https://github.com/thommay)
|
||||
147
cookbooks/homebrew/README.md
Normal file
147
cookbooks/homebrew/README.md
Normal file
@@ -0,0 +1,147 @@
|
||||
# Homebrew Cookbook
|
||||
|
||||
[](http://travis-ci.org/chef-cookbooks/homebrew) [](https://supermarket.chef.io/cookbooks/homebrew)
|
||||
|
||||
This cookbook installs [Homebrew](http://brew.sh/) and provides resources for working with taps and casks
|
||||
|
||||
## Requirements
|
||||
|
||||
### Platforms
|
||||
|
||||
- macOS
|
||||
|
||||
### Chef
|
||||
|
||||
- Chef 12.1+
|
||||
|
||||
### Cookbooks
|
||||
|
||||
- none
|
||||
|
||||
## 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.
|
||||
- `node['homebrew']['formulas']` - An Array of formula that should be installed using Homebrew by default, used only in the `homebrew::install_formulas` recipe.
|
||||
|
||||
- To install the most recent version, include just the recipe name: `- simple_formula`
|
||||
- To install a specific version, specify both its name and version:
|
||||
|
||||
```
|
||||
- name: special-version-formula
|
||||
version: 1.2.3
|
||||
```
|
||||
|
||||
- To install the HEAD of a formula, specify both its name and `head: true`:
|
||||
|
||||
```
|
||||
- name: head-tracking-formula
|
||||
head: true
|
||||
```
|
||||
|
||||
- To provide other options, specify both its name and options
|
||||
|
||||
```
|
||||
- name: formula-with-options
|
||||
options: --with-option-1 --with-other-option
|
||||
```
|
||||
|
||||
- `node['homebrew']['casks']` - An Array of casks that should be installed using brew cask by default, used only in the `homebrew::install_casks` recipe.
|
||||
|
||||
- `node['homebrew']['taps']` - An Array of taps that should be installed using brew tap by default, used only in the `homebrew::install_taps` recipe.
|
||||
|
||||
## Resources (provider)
|
||||
|
||||
### homebrew_tap
|
||||
|
||||
LWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page:
|
||||
|
||||
```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.
|
||||
```
|
||||
|
||||
Default action is `:tap` which enables the repository. Use `:untap` to disable a tapped repository.
|
||||
|
||||
#### Examples
|
||||
|
||||
```ruby
|
||||
homebrew_tap 'homebrew/dupes'
|
||||
|
||||
homebrew_tap 'homebrew/dupes' do
|
||||
action :untap
|
||||
end
|
||||
```
|
||||
|
||||
### homebrew_cask
|
||||
|
||||
LWRP for `brew cask`, a Homebrew-style CLI workflow for the administration of Mac applications distributed as binaries. It's implemented as a homebrew "external command" called cask.
|
||||
|
||||
[homebrew-cask on GitHub](https://github.com/caskroom/homebrew-cask)
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
You must have the homebrew-cask repository tapped.
|
||||
|
||||
```ruby
|
||||
homebrew_tap 'caskroom/cask'
|
||||
```
|
||||
|
||||
And then install the homebrew cask package before using this LWRP.
|
||||
|
||||
```ruby
|
||||
package "brew-cask" do
|
||||
action :install
|
||||
end
|
||||
```
|
||||
|
||||
You can include the `homebrew::cask` recipe to do this.
|
||||
|
||||
### Examples
|
||||
|
||||
```ruby
|
||||
homebrew_cask "google-chrome"
|
||||
|
||||
homebrew_cask "google-chrome" do
|
||||
action :uncask
|
||||
end
|
||||
```
|
||||
|
||||
Default action is `:cask` which installs the Application binary . Use `:uncask` to uninstall a an Application.
|
||||
|
||||
[View the list of available Casks](https://github.com/caskroom/homebrew-cask/tree/master/Casks)
|
||||
|
||||
# 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 recipe also ensures that Homebrew is installed and up to date if the auto update attribute (above) is true (default).
|
||||
|
||||
## License and Authors
|
||||
|
||||
This cookbook is maintained by CHEF. 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](https://woss.name/articles/converging-your-home-directory-with-chef/)
|
||||
|
||||
Author:: Graeme Mathieson ([mathie@woss.name](mailto:mathie@woss.name))
|
||||
|
||||
Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))
|
||||
|
||||
```text
|
||||
Copyright:: 2011, Graeme Mathieson
|
||||
Copyright:: 2012-2016, Chef Software, Inc. <legal@chef.io>
|
||||
|
||||
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.
|
||||
```
|
||||
29
cookbooks/homebrew/attributes/default.rb
Normal file
29
cookbooks/homebrew/attributes/default.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
||||
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
||||
# Cookbook:: homebrew
|
||||
# Attributes:: default
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, 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.
|
||||
#
|
||||
# only used if auto detection fails
|
||||
default['homebrew']['owner'] = nil # only used if auto detection fails
|
||||
default['homebrew']['auto-update'] = true
|
||||
default['homebrew']['casks'] = []
|
||||
default['homebrew']['formulas'] = node['homebrew']['formula'] || []
|
||||
default['homebrew']['taps'] = []
|
||||
default['homebrew']['installer']['url'] = 'https://raw.githubusercontent.com/Homebrew/install/master/install'
|
||||
default['homebrew']['installer']['checksum'] = nil
|
||||
default['homebrew']['enable-analytics'] = true
|
||||
63
cookbooks/homebrew/libraries/homebrew_mixin.rb
Normal file
63
cookbooks/homebrew/libraries/homebrew_mixin.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
#
|
||||
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
||||
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
||||
# Cookbook:: homebrew
|
||||
# Libraries:: homebrew_mixin
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, 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.
|
||||
#
|
||||
|
||||
class Chef12HomebrewUser
|
||||
include Chef::Mixin::HomebrewUser
|
||||
end
|
||||
|
||||
module Homebrew
|
||||
# Homebrew
|
||||
module Mixin
|
||||
def homebrew_owner
|
||||
require 'etc'
|
||||
@homebrew_owner ||= ::Etc.getpwuid(Chef12HomebrewUser.new.find_homebrew_uid).name
|
||||
rescue Chef::Exceptions::CannotDetermineHomebrewOwner
|
||||
@homebrew_owner ||= calculate_owner
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def calculate_owner
|
||||
owner = homebrew_owner_attr || sudo_user || current_user
|
||||
if owner == 'root'
|
||||
raise Chef::Exceptions::User,
|
||||
"Homebrew owner is 'root' which is not supported. " \
|
||||
"To set an explicit owner, please set node['homebrew']['owner']."
|
||||
end
|
||||
owner
|
||||
end
|
||||
|
||||
def homebrew_owner_attr
|
||||
node['homebrew']['owner']
|
||||
end
|
||||
|
||||
def sudo_user
|
||||
ENV['SUDO_USER']
|
||||
end
|
||||
|
||||
def current_user
|
||||
ENV['USER']
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Chef::Resource.send(:include, Homebrew::Mixin)
|
||||
Chef::Recipe.send(:include, Homebrew::Mixin)
|
||||
28
cookbooks/homebrew/libraries/matchers.rb
Normal file
28
cookbooks/homebrew/libraries/matchers.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
if defined?(ChefSpec)
|
||||
ChefSpec.define_matcher :homebrew_package
|
||||
|
||||
def tap_homebrew_tap(tap)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_tap, :tap, tap)
|
||||
end
|
||||
|
||||
def untap_homebrew_tap(tap)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_tap, :untap, tap)
|
||||
end
|
||||
|
||||
def cask_homebrew_cask(cask)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_cask, :cask, cask)
|
||||
end
|
||||
|
||||
def uncask_homebrew_cask(cask)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_cask, :uncask, cask)
|
||||
end
|
||||
|
||||
def install_homebrew_cask(cask)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_cask, :install, cask)
|
||||
end
|
||||
|
||||
def uninstall_homebrew_cask(cask)
|
||||
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_cask, :uninstall, cask)
|
||||
end
|
||||
|
||||
end
|
||||
1
cookbooks/homebrew/metadata.json
Normal file
1
cookbooks/homebrew/metadata.json
Normal file
File diff suppressed because one or more lines are too long
47
cookbooks/homebrew/providers/cask.rb
Normal file
47
cookbooks/homebrew/providers/cask.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Cookbook:: homebrew
|
||||
# Providers:: cask
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, 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.
|
||||
#
|
||||
|
||||
include ::Homebrew::Mixin
|
||||
|
||||
use_inline_resources
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
action :install do
|
||||
execute "installing cask #{new_resource.name}" do
|
||||
command "/usr/local/bin/brew cask install #{new_resource.name} #{new_resource.options}"
|
||||
user homebrew_owner
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
not_if { new_resource.casked? }
|
||||
end
|
||||
end
|
||||
|
||||
action :uninstall do
|
||||
execute "uninstalling cask #{new_resource.name}" do
|
||||
command "/usr/local/bin/brew cask uninstall #{new_resource.name}"
|
||||
user homebrew_owner
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
only_if { new_resource.casked? }
|
||||
end
|
||||
end
|
||||
|
||||
alias_method :action_cask, :action_install
|
||||
alias_method :action_uncask, :action_uninstall
|
||||
58
cookbooks/homebrew/providers/tap.rb
Normal file
58
cookbooks/homebrew/providers/tap.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
#
|
||||
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
||||
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
||||
# Cookbook:: homebrew
|
||||
# Providers:: tap
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, 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.
|
||||
#
|
||||
|
||||
include ::Homebrew::Mixin
|
||||
|
||||
use_inline_resources
|
||||
|
||||
def load_current_resource
|
||||
@tap = Chef::Resource::HomebrewTap.new(new_resource.name)
|
||||
tap_dir = @tap.name.gsub('/', '/homebrew-')
|
||||
|
||||
Chef::Log.debug("Checking whether we've already tapped #{new_resource.name}")
|
||||
if ::File.directory?("/usr/local/Library/Taps/#{tap_dir}")
|
||||
@tap.tapped true
|
||||
else
|
||||
@tap.tapped false
|
||||
end
|
||||
end
|
||||
|
||||
action :tap do
|
||||
unless @tap.tapped
|
||||
execute "tapping #{new_resource.name}" do
|
||||
command "/usr/local/bin/brew tap #{new_resource.name}"
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
not_if "/usr/local/bin/brew tap | grep #{new_resource.name}"
|
||||
user homebrew_owner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
action :untap do
|
||||
if @tap.tapped
|
||||
execute "untapping #{new_resource.name}" do
|
||||
command "/usr/local/bin/brew untap #{new_resource.name}"
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
only_if "/usr/local/bin/brew tap | grep #{new_resource.name}"
|
||||
user homebrew_owner
|
||||
end
|
||||
end
|
||||
end
|
||||
26
cookbooks/homebrew/recipes/cask.rb
Normal file
26
cookbooks/homebrew/recipes/cask.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Cookbook:: homebrew
|
||||
# Recipes:: cask
|
||||
#
|
||||
# Copyright:: 2014-2016, Chef Software, Inc <legal@chef.io>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
homebrew_tap 'caskroom/cask'
|
||||
|
||||
directory '/Library/Caches/Homebrew/Casks' do
|
||||
owner homebrew_owner
|
||||
mode '775'
|
||||
only_if { ::Dir.exist?('/Library/Caches/Homebrew') }
|
||||
end
|
||||
57
cookbooks/homebrew/recipes/default.rb
Normal file
57
cookbooks/homebrew/recipes/default.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
||||
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
||||
# Cookbook:: homebrew
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, 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.
|
||||
#
|
||||
|
||||
homebrew_go = "#{Chef::Config[:file_cache_path]}/homebrew_go"
|
||||
|
||||
Chef::Log.debug("Homebrew owner is '#{homebrew_owner}'")
|
||||
|
||||
remote_file homebrew_go do
|
||||
source node['homebrew']['installer']['url']
|
||||
checksum node['homebrew']['installer']['checksum'] unless node['homebrew']['installer']['checksum'].nil?
|
||||
mode '755'
|
||||
not_if { ::File.exist? '/usr/local/bin/brew' }
|
||||
end
|
||||
|
||||
execute 'install homebrew' do
|
||||
command homebrew_go
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
user homebrew_owner
|
||||
not_if { ::File.exist? '/usr/local/bin/brew' }
|
||||
end
|
||||
|
||||
execute 'set analytics' do
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
user homebrew_owner
|
||||
command "/usr/local/bin/brew analytics #{node['homebrew']['enable-analytics'] ? 'on' : 'off'}"
|
||||
only_if { shell_out('/usr/local/bin/brew analytics state', user: homebrew_owner).stdout.include?('enabled') != node['homebrew']['enable-analytics'] }
|
||||
end
|
||||
|
||||
if node['homebrew']['auto-update']
|
||||
package 'git' do
|
||||
not_if 'which git'
|
||||
end
|
||||
|
||||
execute 'update homebrew from github' do
|
||||
environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
|
||||
user homebrew_owner
|
||||
command '/usr/local/bin/brew update || true'
|
||||
end
|
||||
end
|
||||
24
cookbooks/homebrew/recipes/install_casks.rb
Normal file
24
cookbooks/homebrew/recipes/install_casks.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Cookbook:: homebrew
|
||||
# Recipe:: install_casks
|
||||
#
|
||||
# Copyright:: 2014-2016, Chef Software, Inc <legal@chef.io>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
include_recipe 'homebrew::cask'
|
||||
|
||||
node['homebrew']['casks'].each do |cask|
|
||||
homebrew_cask cask
|
||||
end
|
||||
33
cookbooks/homebrew/recipes/install_formulas.rb
Normal file
33
cookbooks/homebrew/recipes/install_formulas.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Cookbook:: homebrew
|
||||
# Recipes:: install_casks
|
||||
#
|
||||
# Copyright:: 2014-2016, Chef Software, Inc <legal@chef.io>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
include_recipe 'homebrew'
|
||||
|
||||
node['homebrew']['formulas'].each do |formula|
|
||||
if formula.class == Chef::Node::ImmutableMash
|
||||
formula_options = formula.fetch(:options, '')
|
||||
formula_options += ' --HEAD' if formula.fetch(:head, false)
|
||||
package formula.fetch(:name) do
|
||||
options formula_options.strip
|
||||
version formula['version'] if formula.fetch(:version, false)
|
||||
end
|
||||
else
|
||||
package formula
|
||||
end
|
||||
end
|
||||
24
cookbooks/homebrew/recipes/install_taps.rb
Normal file
24
cookbooks/homebrew/recipes/install_taps.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Cookbook:: homebrew
|
||||
# Recipes:: install_taps
|
||||
#
|
||||
# Copyright:: 2015-2016, Chef Software, Inc <legal@chef.io>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
include_recipe 'homebrew'
|
||||
|
||||
node['homebrew']['taps'].each do |tap|
|
||||
homebrew_tap tap
|
||||
end
|
||||
14
cookbooks/homebrew/resources/cask.rb
Normal file
14
cookbooks/homebrew/resources/cask.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
actions :cask, :uncask, :install, :uninstall
|
||||
default_action :install
|
||||
|
||||
attribute :name,
|
||||
name_attribute: true,
|
||||
kind_of: String,
|
||||
regex: /^[\w-]+$/
|
||||
|
||||
attribute :options,
|
||||
kind_of: String
|
||||
|
||||
def casked?
|
||||
shell_out('/usr/local/bin/brew cask list 2>/dev/null').stdout.split.include?(name)
|
||||
end
|
||||
31
cookbooks/homebrew/resources/tap.rb
Normal file
31
cookbooks/homebrew/resources/tap.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Author:: Joshua Timberman (<jtimberman@chef.io>)
|
||||
# Author:: Graeme Mathieson (<mathie@woss.name>)
|
||||
# Cookbook:: homebrew
|
||||
# Resources:: tap
|
||||
#
|
||||
# Copyright:: 2011-2016, Chef Software, 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
|
||||
default_action :tap
|
||||
|
||||
attribute :name,
|
||||
name_attribute: true,
|
||||
kind_of: String,
|
||||
regex: %r{^[\w-]+(?:\/[\w-]+)+$}
|
||||
|
||||
attribute :tapped,
|
||||
kind_of: [TrueClass, FalseClass]
|
||||
Reference in New Issue
Block a user