Use ruby-build for Mastodon, update cookbooks

This uses the ruby_build provider for Mastodon, installing Ruby 2.4.1
currently. It also updates some other cookbooks and the runlists.
This commit is contained in:
Basti 2017-04-17 11:40:31 +02:00
parent 4530190df6
commit 54332db8de
96 changed files with 2830 additions and 903 deletions

2
Batali
View File

@ -14,6 +14,7 @@ Batali.define do
ref: 'relax_dependencies'
cookbook 'postfix'
cookbook 'unattended-upgrades'
cookbook 'poise-ruby-build', '~> 1.1.0'
cookbook 'application'
cookbook 'application_javascript'
cookbook 'application_ruby'
@ -39,4 +40,3 @@ Batali.define do
cookbook 'logrotate'
cookbook 'openssl', '~> 7.0.1'
end

View File

@ -100,11 +100,11 @@
">= 1.1"
]
],
"version": "8.0.0",
"version": "8.0.1",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/8.0.0/download",
"version": "8.0.0"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/build-essential/versions/8.0.1/download",
"version": "8.0.1"
}
},
{
@ -115,11 +115,11 @@
">= 1.2.2"
]
],
"version": "1.0.4",
"version": "2.0.2",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/seven_zip/versions/1.0.4/download",
"version": "1.0.4"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/seven_zip/versions/2.0.2/download",
"version": "2.0.2"
}
},
{
@ -1103,16 +1103,13 @@
{
"name": "homebrew",
"dependencies": [
[
"build-essential",
">= 2.1.2"
]
],
"version": "2.0.5",
"version": "3.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/2.0.5/download",
"version": "2.0.5"
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download",
"version": "3.0.0"
}
},
{
@ -1126,6 +1123,67 @@
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/logrotate/versions/1.9.2/download",
"version": "1.9.2"
}
},
{
"name": "poise-ruby-build",
"dependencies": [
[
"poise",
"~> 2.0"
],
[
"poise-build-essential",
"~> 1.0"
],
[
"poise-git",
"~> 1.0"
],
[
"poise-ruby",
"~> 2.1"
]
],
"version": "1.1.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-ruby-build/versions/1.1.0/download",
"version": "1.1.0"
}
},
{
"name": "poise-build-essential",
"dependencies": [
[
"poise",
"~> 2.6"
]
],
"version": "1.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-build-essential/versions/1.0.0/download",
"version": "1.0.0"
}
},
{
"name": "poise-git",
"dependencies": [
[
"poise",
"~> 2.6"
],
[
"poise-languages",
"~> 2.1"
]
],
"version": "1.0.0",
"source": {
"type": "Batali::Source::Site",
"url": "https://supermarket.chef.io:443/api/v1/cookbooks/poise-git/versions/1.0.0/download",
"version": "1.0.0"
}
}
]
}

View File

@ -1,16 +1,13 @@
<!-- 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 simple majority of maintainers
for the relevant subsystems 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.
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
* [Jennifer Davis](https://github.com/sigje)
* [Tim Smith](https://github.com/tas50)
# Maintainers
* [Jennifer Davis](https://github.com/sigje)

View File

@ -1,37 +1,45 @@
# build-essential Cookbook
[![Cookbook Version](http://img.shields.io/cookbook/v/build-essential.svg)][cookbook] [![Build Status](http://img.shields.io/travis/chef-cookbooks/build-essential.svg)][travis]
Installs packages required for compiling C software from source. Use this cookbook if you wish to compile C programs, or install RubyGems with native extensions.
[![Cookbook Version](http://img.shields.io/cookbook/v/build-essential.svg)][cookbook] [![Build Status](https://travis-ci.org/chef-cookbooks/build-essential.svg?branch=master)](https://travis-ci.org/chef-cookbooks/build-essential)
Installs packages required for compiling C software from source. Use this cookbook if you wish to compile C programs, or install RubyGems with native extensions. Contains a resource, 'build_essential', as as well as a default recipe that simply calls that same resource.
## Requirements
### Platforms
- Debian/Ubuntu
- RHEL/CentOS/Scientific/Amazon/Oracle
- openSUSE
- openSUSE / SUSE Enterprise Linux
- SmartOS
- Fedora
- Mac OS X
- Mac OS X 10.9+
- FreeBSD
### Chef
- Chef 11+
- Chef 12.5+
### Cookbooks
- Suggests pkgutil for Solaris based platforms
- seven_zip
- mingw
**Note for Debian platform family:** On Debian platform-family systems, it is recommended that `apt-get update` be run, to ensure that the package cache is updated. It's not in the scope of this cookbook to do that, as it can [create a duplicate resource](https://tickets.chef.io/browse/CHEF-3694). We recommend using the [apt](https://supermarket.chef.io/cookbooks/apt) cookbook to do this.
**Note for OmniOS**: Currently, OmniOS's Ruby package is built with GCC 4.6.3, and the path is hardcoded, as the gcc binaries are not installed in the default $PATH. This means that in order to install RubyGems into the "system" Ruby, one must install `developer/gcc46`. [An issue](https://github.com/omniti-labs/omnios-build/issues/19) is open upstream w/ OmniOS to rebuild the Ruby package with GCC 4.7.2.
## Attributes
Attribute | Default | Description
----------------------------------------- | :--------------------------: | ---------------------------------
`node['build-essential']['compile_time']` | `false` | Execute resources at compile time
`node['build-essential']['msys']['path']` | `#{ENV['SYSTEMDRIVE']\\msys` | Destination for msys (Windows only)
Attribute | Default | Description
------------------------------------------ | :---------------------------: | -----------------------------------------------------
`node['build-essential']['compile_time']` | `false` | Execute resources at compile time
`node['build-essential']['msys2']['path']` | `#{ENV['SYSTEMDRIVE']\\msys2` | Destination for msys2 build tool chain (Windows only)
## Usage
### Recipe Usage
The recipe simply calls the build_essential resource, but it ideal for adding to roles or node run lists.
Include the build-essential recipe in your run list:
```sh
@ -45,7 +53,9 @@ include_recipe 'build-essential::default'
```
### Gems with C extensions
For RubyGems that include native C extensions you wish to use with Chef, you should do the following.
- Set the `compile_time` attribute to true in your wrapper cookbook or role:
```ruby
@ -82,10 +92,29 @@ For RubyGems that include native C extensions you wish to use with Chef, you sho
chef_gem 'gem-with-native-extension'
```
### Resource Usage
The cookbook includes a resource 'build_essential' that can be included in your cookbook to install the necessary build-essential packages
Simple package installation during the client run:
```ruby
build_essential 'some name you choose'
```
Package installation during the compile phase:
```ruby
build_essential 'some name you choose' do
compile_time false
end
```
## License & Authors
**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))
**Copyright:** 2009-2015, Chef Software, Inc.
**Copyright:** 2009-2016, Chef Software, Inc.
```
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: build-essential
# Recipe:: _mingw
# Cookbook:: build-essential
# Recipe:: _windows
#
# Copyright 2016, Chef Software, Inc.
# Copyright:: 2016-2017, 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.
@ -16,97 +16,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'ostruct'
include_recipe '7-zip::default'
node.default['seven_zip']['syspath'] = true
include_recipe 'seven_zip::default'
[
msys_p('http://downloads.sourceforge.net/mingw/msysCORE-1.0.17-1-msys-1.0.17-bin.tar.lzma',
'2d707ae394f5797a0718a1ffd886d4be1a83ed1f68a4ee4a5b19efd3208b037f'),
msys_p('http://downloads.sourceforge.net/mingw/msysCORE-1.0.17-1-msys-1.0.17-ext.tar.lzma',
'2c68f68cb2caa27aa014461133cf578433e62c823cdac3350be62b9c3e6460a0'),
msys_p('http://downloads.sourceforge.net/mingw/coreutils-5.97-3-msys-1.0.13-bin.tar.lzma',
'f8c7990416ea16a74ac336dcfe0f596bc46b8724b2d58cf8a3509414220b2366'),
msys_p('http://downloads.sourceforge.net/mingw/coreutils-5.97-3-msys-1.0.13-ext.tar.lzma',
'3f525aa6c94ff79ffd656ddf0a56d3244f982ea4a0d274674d9875afc1e04579'),
msys_p('http://downloads.sourceforge.net/mingw/libiconv-1.14-1-msys-1.0.17-dll-2.tar.lzma',
'196921e8c232259c8e6a6852b9ee8d9ab2d29a91419f0c8dc27ba6f034231683'),
msys_p('http://downloads.sourceforge.net/mingw/libintl-0.18.1.1-1-msys-1.0.17-dll-8.tar.lzma',
'29db8c969661c511fbe2a341ab25c993c5f9c555842a75d6ddbcfa70dec16910'),
msys_p('http://downloads.sourceforge.net/mingw/libtermcap-0.20050421_1-2-msys-1.0.13-dll-0.tar.lzma',
'62b58fe0880f0972fcc84a819265989b02439c1c5185870227bd25f870f7adb6'),
msys_p('http://downloads.sourceforge.net/mingw/make-3.81-3-msys-1.0.13-bin.tar.lzma',
'847f0cbbf07135801c8e67bf692d29b1821e816ad828753c997fa869a9b89988'),
msys_p('http://downloads.sourceforge.net/mingw/perl-5.8.8-1-msys-1.0.17-bin.tar.lzma',
'987b939ce00172dd034105d2a908cee5704f67027de98f4dcc69a1006a327a99'),
msys_p('http://downloads.sourceforge.net/mingw/zlib-1.2.3-2-msys-1.0.13-dll.tar.lzma',
'4178940828b928b2d5a33042cc83fbb992b4bfb9ffeaef6dc3e555f2a6a8c0d1'),
msys_p('http://downloads.sourceforge.net/mingw/libgdbm-1.8.3-3-msys-1.0.13-dll-3.tar.lzma',
'7412f874487652e70022ab8601655ee359ed537b017b7dba360b69237c9093c6'),
msys_p('http://downloads.sourceforge.net/mingw/libcrypt-1.1_1-3-msys-1.0.13-dll-0.tar.lzma',
'31f157b6993509849407672503b8b89e09e9e37e8833b6678b9cbbcbf597f918'),
msys_p('http://downloads.sourceforge.net/mingw/bash-3.1.23-1-msys-1.0.18-bin.tar.xz',
'38da5419969ab883058a96322bb0f51434dd4e9f71de09cd4f75b96750944533'),
msys_p('http://downloads.sourceforge.net/mingw/mksh-40.0.0c-1-msys-1.0.17-bin.tar.lzma',
'8311342acf0b9f0264fd0d8384a826537973d798ca5904349fea1e0c9d909e54'),
msys_p('http://downloads.sourceforge.net/mingw/termcap-0.20050421_1-2-msys-1.0.13-bin.tar.lzma',
'906e756332b5fd6c10eeb4b6362f5957dd8cafa5679f89d9adbae59dff7f2ff2'),
msys_p('http://downloads.sourceforge.net/mingw/libregex-1.20090805-2-msys-1.0.13-dll-1.tar.lzma',
'85dd8c1e27a90675c5f867be57ba7ae2bb55dde8cd2d19f284c896be134bd3d1'),
msys_p('http://downloads.sourceforge.net/mingw/crypt-1.1_1-3-msys-1.0.13-bin.tar.lzma',
'58369b42c38144d3aa5a337ebf1e182a66e88db30ccc42796f2074f251ee1fed'),
msys_p('http://downloads.sourceforge.net/mingw/m4-1.4.14-1-msys-1.0.13-bin.tar.lzma',
'41058bc9a691ad01fdd979f1a4ac4ee071bd5ce93f660db5c0b3cfad4487e33e'),
msys_p('http://downloads.sourceforge.net/mingw/bison-2.4.2-1-msys-1.0.13-bin.tar.lzma',
'349f3e312bf71f8a2ac68a7bd2f86b03dacc565b0fd27eef5d604e8be402390e'),
msys_p('http://downloads.sourceforge.net/mingw/flex-2.5.35-2-msys-1.0.13-bin.tar.lzma',
'9715511a2eafb7e2402029059d4b9db96bd40d8b72908db2571c009745c47a63'),
msys_p('http://downloads.sourceforge.net/mingw/findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma',
'779e819b7942dc070c45f4cba633e6a9ae4bfe8b506a3541f4ce86ad0595726d'),
msys_p('http://downloads.sourceforge.net/mingw/sed-4.2.1-2-msys-1.0.13-bin.tar.lzma',
'f73059204cecb691e7840108b7c0cbbfcebf50c0e5c6e3a2326e0eedce5d1b94'),
msys_p('http://downloads.sourceforge.net/mingw/gawk-3.1.7-2-msys-1.0.13-bin.tar.lzma',
'eb15478ea76e75b666ad7fc7049de21b9f487e0e1ea0e96d40953a477e91c3dd'),
msys_p('http://downloads.sourceforge.net/mingw/grep-2.5.4-2-msys-1.0.13-bin.tar.lzma',
'4842a1754df98db994622e8ffab3bea7fbce77e05778cd5d3831e76ac90440ba'),
msys_p('http://downloads.sourceforge.net/mingw/less-436-2-msys-1.0.13-bin.tar.lzma',
'1bbd114846026f9ca4fcc4e18ba20f060384f623f1ef22b326df8c55419c0b84'),
msys_p('http://downloads.sourceforge.net/mingw/diffutils-2.8.7.20071206cvs-3-msys-1.0.13-bin.tar.lzma',
'522889b044492dd2337c4752ba6262995a11f352ca5fb8a8660349413ea9b864'),
msys_p('http://downloads.sourceforge.net/mingw/texinfo-4.13a-2-msys-1.0.13-bin.tar.lzma',
'241eb8e376bf69588d0e02aede35771503c5dcb15c440f97e15e30da79fea864'),
msys_p('http://downloads.sourceforge.net/mingw/libmagic-5.04-1-msys-1.0.13-dll-1.tar.lzma',
'65117008598675823b3fb25296d0d6c332ce56b72950e0f90f9063ac098afac3'),
msys_p('http://downloads.sourceforge.net/mingw/file-5.04-1-msys-1.0.13-bin.tar.lzma',
'e9ceffa49629524c84d07da77c1a5f37837f68a09e56cad30bea1df0a21e5fc2'),
msys_p('http://downloads.sourceforge.net/mingw/mintty-1.0.3-1-msys-1.0.17-bin.tar.lzma',
'0b3e7b57c81646eccaff3ca0310abe8367ace69992640be87199ecf5d9443085'),
msys_p('http://downloads.sourceforge.net/mingw/patch-2.6.1-1-msys-1.0.13-bin.tar.lzma',
'c8b7771304fb5e9fc33d8fca9045402f2e1bca055bf0b28127f3c3e85a254f67')
].each do |package|
potentially_at_compile_time do
build_essential_msys_archive package.url do
checksum package.checksum
root_dir node['build-essential']['msys']['path']
end
end
tool_path = node['build-essential']['msys2']['path']
directory tool_path do
action :create
recursive true
end
[
msys_p('http://iweb.dl.sourceforge.net/project/tdm-gcc/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-core.tar.lzma',
'29393aac890847089ad1e93f81a28f6744b1609c00b25afca818f3903e42e4bd'),
msys_p('http://iweb.dl.sourceforge.net/project/tdm-gcc/MinGW-w64%20runtime/GCC%205%20series/mingw64runtime-v4-git20150618-gcc5-tdm64-1.tar.lzma',
'29186e0bb36824b10026d78bdcf238d631d8fc1d90718d2ebbd9ec239b6f94dd'),
msys_p('http://sourceforge.net/projects/tdm-gcc/files/GNU%20binutils/binutils-2.25-tdm64-1.tar.lzma',
'4722bb7b4d46cef714234109e25e5d1cfd29f4e53365b6d615c8a00735f60e40'),
msys_p('http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%205%20series/5.1.0-tdm64-1/gcc-5.1.0-tdm64-1-c++.tar.lzma',
'17fd497318d1ac187a113e8665330d746ad9607a0406ab2374db0d8e6f4094d1')
'base-devel', # Brings down msys based bash/make/awk/patch/stuff..
'mingw-w64-x86_64-toolchain', # Puts 64-bit SEH mingw toolchain in msys2\mingw64
'mingw-w64-i686-toolchain' # Puts 32-bit DW2 mingw toolchain in msys2\ming32
].each do |package|
potentially_at_compile_time do
build_essential_msys_archive package.url do
root_dir node['build-essential']['msys']['path']
checksum package.checksum
mingw true
end
msys2_package package do
root tool_path
end
end
# Certain build steps assume that a tar command is available on the
# system path. The default tar present in msys2\usr\bin is an msys GNU tar
# that expects forward slashes and consider ':' to be a remote tape separator
# or something weird like that. We therefore drop bat file in msys2\bin that
# redirect to the underlying executables without mucking around with
# msys2's /usr/bin itself.
{
'bsdtar.exe' => 'tar.bat',
'patch.exe' => 'patch.bat',
}.each do |reference, link|
file "#{tool_path}\\bin\\#{link}" do
content "@%~dp0..\\usr\\bin\\#{reference} %*"
end
end

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: build-essential
# Cookbook:: build-essential
# Recipe:: default
#
# Copyright 2008-2016, Chef Software, Inc.
# Copyright:: 2008-2017, 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.
@ -17,13 +17,8 @@
# limitations under the License.
#
begin
include_recipe "build-essential::_#{node['platform_family']}"
rescue Chef::Exceptions::RecipeNotFound
Chef::Log.warn <<-EOH
A build-essential recipe does not exist for '#{node['platform_family']}'. This
means the build-essential cookbook does not have support for the
#{node['platform_family']} family. If you are not compiling gems with native
extensions or building packages from source, this will likely not affect you.
EOH
# Call the build-essential custom resource
# This can also be called directly in your cookbooks anywhere you want
build_essential 'install_packages' do
compile_time node['build-essential']['compile_time']
end

View File

@ -2,7 +2,7 @@
# Cookbook:: build-essential
# resource:: build_essential
#
# Copyright:: 2008-2016, Chef Software, Inc.
# Copyright:: 2008-2017, 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.
@ -26,7 +26,7 @@ action :install do
case node['platform_family']
when 'debian'
package %w( autoconf binutils-doc bison build-essential flex gettext ncurses-dev )
when 'fedora', 'rhel'
when 'amazon', 'fedora', 'rhel'
package %w( autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch )
# Ensure GCC 4 is available on older pre-6 EL

View File

@ -2,7 +2,7 @@
# Cookbook:: build-essential
# Resource:: xcode_command_line_tools
#
# Copyright:: 2014-2016, Chef Software, Inc.
# Copyright:: 2014-2017, 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.
@ -44,7 +44,7 @@ action :install do
end
end
action_class do
action_class.class_eval do
#
# Determine if the XCode Command Line Tools are installed
#

View File

@ -1,7 +1,34 @@
# 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
@ -9,22 +36,27 @@ This file is used to list changes made in each version of the homebrew cookbook.
- 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)
- 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
@ -32,109 +64,136 @@ This file is used to list changes made in each version of the homebrew cookbook.
- 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)
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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`,
- 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
- 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
- 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
# 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"

View File

@ -1,19 +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 simple majority of maintainers
for the relevant subsystems 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.
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)
* [Sean OMeara](https://github.com/someara)
* [Tim Smith](https://github.com/tas50)
* [Thom May](https://github.com/thommay)

View File

@ -1,36 +1,29 @@
# Homebrew Cookbook
[![Build Status](https://travis-ci.org/chef-cookbooks/homebrew.svg?branch=master)](http://travis-ci.org/chef-cookbooks/homebrew) [![Cookbook Version](https://img.shields.io/cookbook/v/homebrew.svg)](https://supermarket.chef.io/cookbooks/homebrew)
This cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) and under Chef 11 and earlier versions, its package provider replaces MacPorts as the _default package provider_ for the package resource on OS X systems.
This cookbook installs [Homebrew](http://brew.sh/) and provides resources for working with taps and casks
# Requirements
Chef 12: The package provider is not necessary on Chef 12, as the default [OS X package provider](https://github.com/chef/chef-rfc/blob/master/rfc016-homebrew-osx-package-provider.md) is homebrew.
## Requirements
Chef <= 11: The package provider will be set as the default provider for OS X.
### Platforms
## 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 possible 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:
- macOS
```bash
sudo chown -R `whoami`:staff /usr/local
```
### Chef
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 project.
- Chef 12.1+
**Note** This cookbook _only_ supports installing in `/usr/local`. While the Homebrew project itself allows for alternative installations, this cookbook doesn't.
### Cookbooks
## Platform
- Mac OS X (10.6+)
- none
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
## Cookbooks
- build-essential: homebrew itself doesn't work well if XCode is not installed.
# 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.
- `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:
@ -46,38 +39,21 @@ The only platform supported by Homebrew itself at the time of this writing is Ma
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 and Providers
This cookbook includes a package resource provider to use homebrew. Under Chef 12+, this is not necessary, and the code doesn't actually get used on Chef 12+. This was preserved to maintain backwards compatiblity with older versions of Chef.
## Resources (provider)
## 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.
### homebrew_tap
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".
### Examples
```ruby
package 'mysql' do
action :install
end
homebrew_package 'mysql'
package 'mysql' do
provider Chef::Provider::Package::Homebrew
end
package 'wireshark' do
options '--with-qt --devel'
end
```
### homebrew\_tap
LWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page:
```text
@ -99,12 +75,14 @@ homebrew_tap 'homebrew/dupes' do
end
```
## homebrew\_cask
### 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
#### Prerequisites
You must have the homebrew-cask repository tapped.
```ruby
@ -136,11 +114,13 @@ Default action is `:cask` which installs the Application binary . Use `:uncask`
[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
## 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/)
@ -151,7 +131,7 @@ Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))
```text
Copyright:: 2011, Graeme Mathieson
Copyright:: 2012-2015, Chef Software, Inc. <legal@chef.io>
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.

View File

@ -1,10 +1,10 @@
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Author:: Graeme Mathieson (<mathie@woss.name>)
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Attributes:: default
#
# Copyright 2011-2013, Chef Software, Inc.
# 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.
@ -18,9 +18,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['homebrew']['owner'] = nil
# 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

View File

@ -1,10 +1,10 @@
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Author:: Graeme Mathieson (<mathie@woss.name>)
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Libraries:: homebrew_mixin
#
# Copyright 2011-2013, Chef Software, Inc.
# 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.
@ -18,26 +18,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Include the mixin from Chef 12 if its defined, when we get to the
# #homebrew_owner method below...
class Chef12HomebrewUser
include Chef::Mixin::HomebrewUser if defined?(Chef::Mixin::HomebrewUser)
include Chef::Mixin::HomebrewUser
end
module Homebrew
# Homebrew
module Mixin
def homebrew_owner
if defined?(Chef::Mixin::HomebrewUser)
begin
require 'etc'
@homebrew_owner ||= ::Etc.getpwuid(Chef12HomebrewUser.new.find_homebrew_uid).name
rescue Chef::Exceptions::CannotDetermineHomebrewOwner
@homebrew_owner ||= calculate_owner
end
else
@homebrew_owner ||= calculate_owner
end
require 'etc'
@homebrew_owner ||= ::Etc.getpwuid(Chef12HomebrewUser.new.find_homebrew_uid).name
rescue Chef::Exceptions::CannotDetermineHomebrewOwner
@homebrew_owner ||= calculate_owner
end
private
@ -45,7 +38,7 @@ module Homebrew
def calculate_owner
owner = homebrew_owner_attr || sudo_user || current_user
if owner == 'root'
fail Chef::Exceptions::User,
raise Chef::Exceptions::User,
"Homebrew owner is 'root' which is not supported. " \
"To set an explicit owner, please set node['homebrew']['owner']."
end
@ -65,3 +58,6 @@ module Homebrew
end
end
end
Chef::Resource.send(:include, Homebrew::Mixin)
Chef::Recipe.send(:include, Homebrew::Mixin)

View File

@ -1,102 +0,0 @@
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Author:: Graeme Mathieson (<mathie@woss.name>)
# Cookbook Name:: homebrew
# Libraries:: homebrew_package
#
# Copyright 2011-2013, 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.
#
# cookbook libraries are unconditionally included if the cookbook is
# present on a node. This approach should avoid creating this class if
# the node already has Chef::Provider::Package::Homebrew, such as with
# Chef 12.
# https://github.com/chef/chef-rfc/blob/master/rfc016-homebrew-osx-package-provider.md
unless defined?(Chef::Provider::Package::Homebrew) && Chef::Platform.find('mac_os_x', nil)[:package] == Chef::Provider::Package::Homebrew
require 'chef/provider/package'
require 'chef/resource/package'
require 'chef/platform'
require 'chef/mixin/shell_out'
class Chef
class Provider
class Package
# Package
class Homebrew < Package
# Homebrew packagex
include Chef::Mixin::ShellOut
include ::Homebrew::Mixin
def load_current_resource
@current_resource = Chef::Resource::Package.new(@new_resource.name)
@current_resource.package_name(@new_resource.package_name)
@current_resource.version(current_installed_version)
@current_resource
end
def install_package(name, _version)
brew('install', @new_resource.options, name)
end
def upgrade_package(name, _version)
brew('upgrade', name)
end
def remove_package(name, _version)
brew('uninstall', @new_resource.options, name)
end
# Homebrew doesn't really have a notion of purging, so just remove.
def purge_package(name, version)
@new_resource.options = ((@new_resource.options || '') << ' --force').strip
remove_package(name, version)
end
protected
def brew(*args)
get_response_from_command("brew #{args.join(' ')}")
end
def current_installed_version
versions = package_info['installed'].map { |v| v['version'] }
versions.join(' ') unless versions.empty?
end
def candidate_version
package_info['versions']['stable'] ? package_info['versions']['stable'].to_s : package_info['versions'].find { |_k, v| v if v.is_a?(String) }
end
def package_info
require 'json'
JSON.parse(brew('info', @new_resource.package_name, '--json=v1'))[0]
end
def get_response_from_command(command)
require 'etc'
home_dir = Etc.getpwnam(homebrew_owner).dir
Chef::Log.debug "Executing '#{command}' as #{homebrew_owner}"
output = shell_out!(command, user: homebrew_owner, environment: { 'USER' => homebrew_owner, 'HOME' => home_dir, 'RUBYOPT' => nil })
output.stdout
end
end
end
end
end
Chef::Platform.set platform: :mac_os_x_server, resource: :package, provider: Chef::Provider::Package::Homebrew
Chef::Platform.set platform: :mac_os_x, resource: :package, provider: Chef::Provider::Package::Homebrew
end

View File

@ -1,20 +1,5 @@
if defined?(ChefSpec)
def install_homebrew_package(pkg)
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :install, pkg)
end
def upgrade_homebrew_package(pkg)
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :upgrade, pkg)
end
def remove_homebrew_package(pkg)
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :remove, pkg)
end
def purge_homebrew_package(pkg)
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_package, :purge, pkg)
end
ChefSpec.define_matcher :homebrew_package
def tap_homebrew_tap(tap)
ChefSpec::Matchers::ResourceMatcher.new(:homebrew_tap, :tap, tap)

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Providers:: cask
#
# Copyright 2011-2015, Chef Software, Inc.
# 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.

View File

@ -1,10 +1,10 @@
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Author:: Graeme Mathieson (<mathie@woss.name>)
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Providers:: tap
#
# Copyright 2011-2015, Chef Software, Inc.
# 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.

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Recipes:: cask
#
# Copyright 2014-2015, Chef Software, Inc <legal@chef.io>
# 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.
@ -16,23 +16,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
Chef::Resource.send(:include, Homebrew::Mixin)
homebrew_tap 'caskroom/cask'
directory '/Library/Caches/Homebrew/Casks' do
owner homebrew_owner
mode 00775
mode '775'
only_if { ::Dir.exist?('/Library/Caches/Homebrew') }
end
directory '/opt/homebrew-cask' do
owner homebrew_owner
mode 00775
recursive true
end
directory '/opt/homebrew-cask/Caskroom' do
owner homebrew_owner
mode 00775
end

View File

@ -1,10 +1,10 @@
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Author:: Graeme Mathieson (<mathie@woss.name>)
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Recipe:: default
#
# Copyright 2011-2015, Chef Software, Inc.
# 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.
@ -19,16 +19,15 @@
# limitations under the License.
#
Chef::Resource.send(:include, Homebrew::Mixin)
Chef::Recipe.send(:include, Homebrew::Mixin)
homebrew_go = "#{Chef::Config[:file_cache_path]}/homebrew_go"
Chef::Log.debug("Homebrew owner is '#{homebrew_owner}'")
remote_file homebrew_go do
source 'https://raw.githubusercontent.com/Homebrew/install/master/install'
mode 00755
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
@ -38,6 +37,13 @@ execute 'install homebrew' do
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'

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Recipe:: install_casks
#
# Copyright 2014-2015, Chef Software, Inc <legal@chef.io>
# 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.

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Recipes:: install_casks
#
# Copyright 2014-2015, Chef Software, Inc <legal@chef.io>
# 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.
@ -21,8 +21,10 @@ 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 '--HEAD' if formula.fetch(:head, false)
options formula_options.strip
version formula['version'] if formula.fetch(:version, false)
end
else

View File

@ -1,8 +1,8 @@
#
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Recipes:: install_taps
#
# Copyright 2015, Chef Software, Inc <legal@chef.io>
# 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.

View File

@ -1,10 +1,10 @@
#
# Author:: Joshua Timberman (<jtimberman@chef.io>)
# Author:: Graeme Mathieson (<mathie@woss.name>)
# Cookbook Name:: homebrew
# Cookbook:: homebrew
# Resources:: tap
#
# Copyright 2011-2013, Chef Software, Inc.
# 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.

View File

@ -0,0 +1,5 @@
# Poise-Build-Essential Changelog
## v1.0.0
* Initial release!

View File

@ -0,0 +1,85 @@
# Poise-Build-Essential Cookbook
[![Build Status](https://img.shields.io/travis/poise/poise-build-essential.svg)](https://travis-ci.org/poise/poise-build-essential)
[![Gem Version](https://img.shields.io/gem/v/poise-build-essential.svg)](https://rubygems.org/gems/poise-build-essential)
[![Cookbook Version](https://img.shields.io/cookbook/v/poise-build-essential.svg)](https://supermarket.chef.io/cookbooks/poise-build-essential)
[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-build-essential.svg)](https://codecov.io/github/poise/poise-build-essential)
[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-build-essential.svg)](https://gemnasium.com/poise/poise-build-essential)
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
A [Chef](https://www.chef.io/) cookbook to install a C compiler and build tools..
## Quick Start
To install a C compiler:
```ruby
include_recipe 'poise-build-essential'
```
Or to install using a resource and at compile time:
```ruby
poise_build_essential 'build_essential' do
action :nothing
end.run_action(:install)
```
## Recipes
* `poise-build-essential::default` Install a C compiler and build tools.
## Attributes
* `node['poise-build-essential']['action']` Action to use. One of install,
upgrade, or remove. *(default: install)*
* `node['poise-build-essential']['allow_unsupported_platform']` Whether or not
to raise an error on unsupported platforms. *(default: false)*
## Resources
### `poise_build_essential`
The `poise_build_essential` resource installs a C compiler and build tools.
```ruby
poise_build_essential 'build_essential' do
allow_unsupported_platform true
end
```
#### Actions
* `:install` Install a C compiler. *(default)*
* `:upgrade` Install a C compiler using `package action :ugprade` rules.
* `:remove` Remove a C compiler.
#### Properties
* `allow_unsupported_platform` Whether or not to raise an error on unsupported
platforms. *(default: false)*
## Sponsors
Development sponsored by [SAP](https://www.sap.com/).
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
## License
Some code copyright 2008-2017, Chef Software, Inc. Used under the terms of the
Apache License, Version 2.0.
Copyright 2017, Noah Kantrowitz
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.

View File

@ -0,0 +1,21 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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.
#
# Action to use. One of install, upgrade, or remove.
default['poise-build-essential']['action'] = 'install'
# Whether or not to raise an error on unsupported platforms.
default['poise-build-essential']['allow_unsupported_platform'] = false

View File

@ -0,0 +1,22 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 PoiseBuildEssential
autoload :BuildEssentialProviders, 'poise_build_essential/build_essential_providers'
autoload :Resources, 'poise_build_essential/resources'
autoload :VERSION, 'poise_build_essential/version'
end

View File

@ -0,0 +1,49 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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/platform/provider_priority_map'
require 'poise_build_essential/build_essential_providers/debian'
require 'poise_build_essential/build_essential_providers/freebsd'
require 'poise_build_essential/build_essential_providers/mac_os_x'
require 'poise_build_essential/build_essential_providers/omnios'
require 'poise_build_essential/build_essential_providers/rhel'
require 'poise_build_essential/build_essential_providers/smartos'
require 'poise_build_essential/build_essential_providers/solaris'
require 'poise_build_essential/build_essential_providers/suse'
# require 'poise_build_essential/build_essential_providers/windows'
module PoiseBuildEssential
# Inversion providers for the poise_build_essential resource.
#
# @since 1.0.0
module BuildEssentialProviders
# Set up priority maps
Chef::Platform::ProviderPriorityMap.instance.priority(:poise_build_essential, [
PoiseBuildEssential::BuildEssentialProviders::Debian,
PoiseBuildEssential::BuildEssentialProviders::FreeBSD,
PoiseBuildEssential::BuildEssentialProviders::MacOSX,
PoiseBuildEssential::BuildEssentialProviders::OmniOS,
PoiseBuildEssential::BuildEssentialProviders::RHEL,
PoiseBuildEssential::BuildEssentialProviders::SmartOS,
PoiseBuildEssential::BuildEssentialProviders::Solaris,
PoiseBuildEssential::BuildEssentialProviders::SUSE,
# PoiseBuildEssential::BuildEssentialProviders::Windows,
PoiseBuildEssential::BuildEssentialProviders::Base,
])
end
end

View File

@ -0,0 +1,103 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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'
require 'poise'
module PoiseBuildEssential
module BuildEssentialProviders
# The provider base class for `poise_build_essential`.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class Base < Chef::Provider
include Poise
provides(:poise_build_essential)
# The `install` action for the `poise_build_essential` resource.
#
# @return [void]
def action_install
notifying_block do
install_build_essential
end
end
# The `upgrade` action for the `poise_build_essential` resource.
#
# @return [void]
def action_upgrade
notifying_block do
upgrade_build_essential
end
end
# The `remove` action for the `poise_build_essential` resource.
#
# @return [void]
def action_remove
notifying_block do
remove_build_essential
end
end
private
# Install C compiler and build tools. Must be implemented by subclasses.
#
# @abstract
def install_build_essential
unsupported_platform("Unknown platform for poise_build_eseential: #{node['platform']} (#{node['platform_family']})")
# Return an array so upgrade/remove also work.
[]
end
# Upgrade C compiler and build tools. Must be implemented by subclasses.
#
# @abstract
def upgrade_build_essential
install_build_essential.tap do |installed|
Array(installed).each {|r| r.action(:upgrade) }
end
end
# Uninstall C compiler and build tools. Must be implemented by subclasses.
#
# @abstract
def remove_build_essential
install_build_essential.tap do |installed|
Array(installed).each {|r| r.action(:remove) }
end
end
# Helper method for either warning about an unsupported platform or raising
# an exception.
#
# @api private
# @param msg [String] Error message to display.
# @return [void]
def unsupported_platform(msg)
if new_resource.allow_unsupported_platform
Chef::Log.warn(msg)
else
raise RuntimeError.new(msg)
end
end
end
end
end

View File

@ -0,0 +1,41 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on Debian platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class Debian < Base
provides(:poise_build_essential, platform_family: 'debian')
private
# (see Base#install_build_essential)
def install_build_essential
package %w{autoconf binutils-doc bison build-essential flex gettext ncurses-dev}
end
end
end
end

View File

@ -0,0 +1,46 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on FreeBSD platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class FreeBSD < Base
provides(:poise_build_essential, platform_family: 'freebsd')
private
# (see Base#install_build_essential)
def install_build_essential
pkgs = %w{devel/gmake devel/autoconf devel/m4 devel/gettext}
# Only install gcc on freebsd 9.x - 10 uses clang.
if node['platform_version'].to_i <= 9
pkgs << 'lang/gcc49'
end
pkgs.map {|name| package name }
end
end
end
end

View File

@ -0,0 +1,66 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on macOS platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class MacOSX < Base
provides(:poise_build_essential, platform_family: 'mac_os_x')
private
# (see Base#install_build_essential)
def install_build_essential
# This script was graciously borrowed and modified from Tim Sutton's
# osx-vm-templates at https://github.com/timsutton/osx-vm-templates/blob/b001475df54a9808d3d56d06e71b8fa3001fff42/scripts/xcode-cli-tools.sh
execute 'install XCode Command Line tools' do
command <<-EOH
# create the placeholder file that's checked by CLI updates' .dist code
# in Apple's SUS catalog
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
# find the CLI Tools update
PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n')
# install it
softwareupdate -i "$PROD" --verbose
# Remove the placeholder to prevent perpetual appearance in the update utility
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
EOH
not_if 'pkgutil --pkgs=com.apple.pkg.CLTools_Executables'
end
end
# (see Base#upgrade_build_essential)
def upgrade_build_essential
# Make upgrade the same as install on Mac.
install_build_essential
end
# (see Base#remove_build_essential)
def remove_build_essential
# Not sure how to do this, ignoring for now.
raise NotImplementedError
end
end
end
end

View File

@ -0,0 +1,46 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on OmniOS platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class OmniOS < Base
provides(:poise_build_essential, platform_family: 'omnios')
private
# (see Base#install_build_essential)
def install_build_essential
# Per OmniOS documentation, the gcc bin dir isn't in the default
# $PATH, so add it to the running process environment.
# http://omnios.omniti.com/wiki.php/DevEnv
ENV['PATH'] = "#{ENV['PATH']}:/opt/gcc-4.7.2/bin"
%w{developer/gcc48 developer/object-file developer/linker
developer/library/lint developer/build/gnu-make system/header
system/library/math/header-math}.map {|name| package name }
end
end
end
end

View File

@ -0,0 +1,46 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on RedHat and Fedora platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class RHEL < Base
provides(:poise_build_essential, platform_family: %w{rhel fedora})
private
# (see Base#install_build_essential)
def install_build_essential
pkgs = %w{autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch}
# Ensure GCC 4 is available on older pre-6 EL
if node['platform_family'] == 'rhel' && node['platform_version'].to_i < 6
pkgs += %w{gcc44 gcc44-c++}
end
package pkgs
end
end
end
end

View File

@ -0,0 +1,39 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on SmartOS platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class SmartOS < Base
provides(:poise_build_essential, platform_family: 'smartos')
private
# (see Base#install_build_essential)
def install_build_essential
%w{autoconf binutils build-essential gcc47 gmake pkg-config}.map {|name| package name }
end
end
end
end

View File

@ -0,0 +1,47 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on Solaris platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class Solaris < Base
provides(:poise_build_essential, platform_family: 'solaris2')
private
# (see Base#install_build_essential)
def install_build_essential
if node['platform_version'].to_f < 5.11
unsupported_platform('poise_build_essential does not support Solaris before 11. You will need to install SUNWbison, SUNWgcc, SUNWggrp, SUNWgmake, and SUNWgtar from the Solaris DVD')
return []
end
# lock because we don't use gcc 5 yet.
[package('gcc') { version '4.8.2'} ] + \
%w{autoconf automake bison gnu-coreutils flex gcc-3 gnu-grep gnu-make
gnu-patch gnu-tar make pkg-config ucb}.map {|name| package name }
end
end
end
end

View File

@ -0,0 +1,43 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on SUSE platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class SUSE < Base
provides(:poise_build_essential, platform_family: 'suse')
private
# (see Base#install_build_essential)
def install_build_essential
pkgs = %w{autoconf bison flex gcc gcc-c++ kernel-default-devel make m4}
if node['platform_version'].to_i < 12
pkgs += %w{gcc48 gcc48-c++}
end
package pkgs
end
end
end
end

View File

@ -0,0 +1,68 @@
#
# Copyright 2008-2017, Chef Software, Inc.
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/build_essential_providers/base'
module PoiseBuildEssential
module BuildEssentialProviders
# A provider for `poise_build_essential` to install on Windows platforms.
#
# @see PoiseBuildEssential::Resources::PoiseBuildEssential::Resource
# @provides poise_build_essential
class Windows < Base
provides(:poise_build_essential, platform_family: 'windows')
private
# (see Base#install_build_essential)
def install_build_essential
install_build_essential_packages
end
# (see Base#upgrade_build_essential)
def upgrade_build_essential
# Upgrade and install are the same on Windows. (?)
install_build_essential
end
# (see Base#remove_build_essential)
def remove_build_essential
raise NotImplementedError
end
# Install MSYS2 packages needed for the build environment.
#
# @api private
# @return [Array<Chef::Resource>]
def install_build_essential_packages
# TODO This probably won't work on 32-bit right now, fix that.
[
'base-devel', # Brings down msys based bash/make/awk/patch/stuff.
'mingw-w64-x86_64-toolchain', # Puts 64-bit SEH mingw toolchain in msys2\mingw64.
'mingw-w64-i686-toolchain' # Puts 32-bit DW2 mingw toolchain in msys2\ming32.
].map do |pkg_group|
# The pacman package provider doesn't support groups, so going old-school.
poise_msys2_execute "pacman --sync #{pkg_group}" do
command ['pacman', '--sync', '--noconfirm', '--noprogressbar', '--needed', pkg_group]
end
end
end
end
end
end

View File

@ -0,0 +1,18 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/resources'
require 'poise_build_essential/build_essential_providers'

View File

@ -0,0 +1,26 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_build_essential/resources/poise_build_essential'
module PoiseBuildEssential
# Chef resources and providers for poise-build-essential.
#
# @since 1.0.0
module Resources
end
end

View File

@ -0,0 +1,48 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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/resource'
require 'poise'
module PoiseBuildEssential
module Resources
# (see PoiseBuildEssential::Resource)
# @since 1.0.0
module PoiseBuildEssential
# A `poise_build_essential` resource to install a C compiler and build tools.
#
# @provides poise_build_essential
# @action install
# @action upgrade
# @action uninstall
# @example
# poise_build_essential 'build-essential'
class Resource < Chef::Resource
include Poise
provides(:poise_build_essential)
actions(:install, :upgrade, :remove)
# @!attribute allow_unsupported_platform
# Whether or not to raise an error on unsupported platforms.
# @return [Boolean]
attribute(:allow_unsupported_platform, kind_of: [TrueClass, FalseClass], default: lazy { node['poise-build-essential']['allow_unsupported_platform'] })
end
# Providers can be found under build_essential_providers/.
end
end
end

View File

@ -0,0 +1,20 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 PoiseBuildEssential
VERSION = '1.0.0'
end

View File

@ -0,0 +1,19 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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.
#
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
require "poise_build_essential/cheftie"

View File

@ -0,0 +1 @@
{"name":"poise-build-essential","version":"1.0.0","description":"A Chef cookbook to install a C compiler and build tools.","long_description":"# Poise-Build-Essential Cookbook\n\n[![Build Status](https://img.shields.io/travis/poise/poise-build-essential.svg)](https://travis-ci.org/poise/poise-build-essential)\n[![Gem Version](https://img.shields.io/gem/v/poise-build-essential.svg)](https://rubygems.org/gems/poise-build-essential)\n[![Cookbook Version](https://img.shields.io/cookbook/v/poise-build-essential.svg)](https://supermarket.chef.io/cookbooks/poise-build-essential)\n[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-build-essential.svg)](https://codecov.io/github/poise/poise-build-essential)\n[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-build-essential.svg)](https://gemnasium.com/poise/poise-build-essential)\n[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n\nA [Chef](https://www.chef.io/) cookbook to install a C compiler and build tools..\n\n## Quick Start\n\nTo install a C compiler:\n\n```ruby\ninclude_recipe 'poise-build-essential'\n```\n\nOr to install using a resource and at compile time:\n\n```ruby\npoise_build_essential 'build_essential' do\n action :nothing\nend.run_action(:install)\n```\n\n## Recipes\n\n* `poise-build-essential::default` Install a C compiler and build tools.\n\n## Attributes\n\n* `node['poise-build-essential']['action']` Action to use. One of install,\n upgrade, or remove. *(default: install)*\n* `node['poise-build-essential']['allow_unsupported_platform']` Whether or not\n to raise an error on unsupported platforms. *(default: false)*\n\n## Resources\n\n### `poise_build_essential`\n\nThe `poise_build_essential` resource installs a C compiler and build tools.\n\n```ruby\npoise_build_essential 'build_essential' do\n allow_unsupported_platform true\nend\n```\n\n#### Actions\n\n* `:install` Install a C compiler. *(default)*\n* `:upgrade` Install a C compiler using `package action :ugprade` rules.\n* `:remove` Remove a C compiler.\n\n#### Properties\n\n* `allow_unsupported_platform` Whether or not to raise an error on unsupported\n platforms. *(default: false)*\n\n## Sponsors\n\nDevelopment sponsored by [SAP](https://www.sap.com/).\n\nThe Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).\n\n## License\n\nSome code copyright 2008-2017, Chef Software, Inc. Used under the terms of the\nApache License, Version 2.0.\n\nCopyright 2017, Noah Kantrowitz\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","maintainer":"Noah Kantrowitz","maintainer_email":"noah@coderanger.net","license":"Apache 2.0","platforms":{},"dependencies":{"poise":"~> 2.6"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/poise/poise-build-essential","issues_url":"https://github.com/poise/poise-build-essential/issues","chef_version":[["< 14",">= 12.1"]],"ohai_version":[]}

View File

@ -0,0 +1,19 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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.
#
poise_build_essential 'build_essential' do
action node['poise-build-essential']['action'].to_sym
end

View File

@ -0,0 +1,5 @@
# Poise-Git Changelog
## v1.0.0
* Initial release!

View File

@ -0,0 +1,151 @@
# Poise-Git Cookbook
[![Build Status](https://img.shields.io/travis/poise/poise-git.svg)](https://travis-ci.org/poise/poise-git)
[![Gem Version](https://img.shields.io/gem/v/poise-git.svg)](https://rubygems.org/gems/poise-git)
[![Cookbook Version](https://img.shields.io/cookbook/v/poise-git.svg)](https://supermarket.chef.io/cookbooks/poise-git)
[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-git.svg)](https://codecov.io/github/poise/poise-git)
[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-git.svg)](https://gemnasium.com/poise/poise-git)
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
A [Chef](https://www.chef.io/) cookbook to manage [Git](https://git-scm.com/).
## Quick Start
To install Git and clone a repository using a deploy key from a data bag:
```ruby
poise_git '/srv/myapp' do
repository 'git@github.com:example/myapp.git'
deploy_key data_bag_item('keys', 'myapp')['key']
end
```
To install Git and clone a repository using a deploy key that already exists on
disk:
```ruby
poise_git '/srv/myapp' do
repository 'git@github.com:example/myapp.git'
deploy_key '/path/to/mykey.pem'
end
```
## Recipes
* `poise-git::default` Install Git.
## Attributes
* `node['poise-git']['default_recipe']` Recipe used by `poise_git` to install
Git if not already available. *(default: poise-git)*
* `node['poise-git']['provider']` Default provider for `poise_git_client` resource
instances. *(default: auto)*
* `node['poise-git']['recipe'][*]` All subkeys of `'recipe'` will be passed
as properties to the `poise_git_client` resource before installation when using
the `poise-git::default` recipe.
## Resources
### `poise_git`
The `poise_git` resource extends the core `git` resource, adding a `deploy_key`
property to use SSH deploy keys automatically.
```ruby
poise_git '/srv/myapp' do
repository 'git@github.com:example/myapp.git'
deploy_key 'mysecretkey'
end
```
The `poise_git` resource supports all the same actions and properties as the
core `git` resource.
The `deploy_key` property can either be passed the absolute path to an existing
SSH key file, or the raw SSH private key text.
### `poise_git_client`
The `poise_git_client` resource installs Git.
```ruby
poise_git_client 'git'
```
#### Actions
* `:install` Install Git. *(default)*
* `:uninstall` Uninstall Git.
#### Properties
* `version` Version of Git to install. If a partial version is given, use the
latest available version matching that prefix. *(name property)*
#### Provider Options
The `poise_git_client` resource uses provide options for per-provider configuration. See
[the poise-service documentation](https://github.com/poise/poise-service#service-options)
for more information on using provider options.
## Git Client Providers
### `system`
The `system` provider installs Git using system packages. This is currently
only tested on platforms using `apt-get` and `yum` (Debian, Ubuntu, RHEL, CentOS
Amazon Linux, and Fedora) and is a default provider on those platforms. It may
work on other platforms but is untested.
```ruby
poise_git_client 'git' do
provider :system
end
```
#### Options
* `package_name` Override auto-detection of the package name.
* `package_upgrade` Install using action `:upgrade`. *(default: false)*
* `package_version` Override auto-detection of the package version.
### `dummy`
The `dummy` provider supports using the `poise_git_client` resource with ChefSpec
or other testing frameworks to not actually install Git. It is used by default under
ChefSpec. It can also be used to manage the Git installation externally from
this cookbook.
```ruby
poise_git_client 'git' do
provider :dummy
options git_binary: '/path/to/git'
end
```
#### Provider Options
* `git_binary` Path to the `git` executable. *(default: /git)*
* `git_environment` Hash of environment variables to use with this Git. *(default: {})*
## Sponsors
Development sponsored by [SAP](https://www.sap.com/).
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
## License
Copyright 2015-2017, Noah Kantrowitz
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.

View File

@ -0,0 +1,26 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 recipe to use to install git.
default['poise-git']['default_recipe'] = 'poise-git'
# Default inversion options.
default['poise-git']['provider'] = 'auto'
default['poise-git']['options'] = {}
# Attributes for recipe[poise-git]. All values are nil because the actual
# defaults live in the resource.
default['poise-git']['recipe']['version'] = nil

View File

@ -0,0 +1,24 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 PoiseGit
autoload :GitClientProviders, 'poise_git/git_client_providers'
autoload :GitCommandMixin, 'poise_git/git_command_mixin'
autoload :Resources, 'poise_git/resources'
autoload :SafeString, 'poise_git/safe_string'
autoload :VERSION, 'poise_git/version'
end

View File

@ -0,0 +1,18 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_git/resources'
require 'poise_git/git_client_providers'

View File

@ -0,0 +1,36 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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/platform/provider_priority_map'
require 'poise_git/git_client_providers/dummy'
require 'poise_git/git_client_providers/system'
module PoiseGit
# Inversion providers for the poise_git resource.
#
# @since 1.0.0
module GitClientProviders
autoload :Base, 'poise_git/git_client_providers/base'
# Set up priority maps
Chef::Platform::ProviderPriorityMap.instance.priority(:poise_git_client, [
PoiseGit::GitClientProviders::Dummy,
PoiseGit::GitClientProviders::System,
])
end
end

View File

@ -0,0 +1,93 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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'
require 'poise'
module PoiseGit
module GitClientProviders
# The provider base class for `poise_git_client`.
#
# @see PoiseGit::Resources::PoiseGitClient::Resource
# @provides poise_git_client
class Base < Chef::Provider
include Poise(inversion: :poise_git_client)
provides(:poise_git_client)
# Set default inversion options.
#
# @api private
def self.default_inversion_options(node, new_resource)
super.merge({
version: new_resource.version,
})
end
# The `install` action for the `poise_git_client` resource.
#
# @return [void]
def action_install
notifying_block do
install_git
end
end
# The `uninstall` action for the `poise_git_client` resource.
#
# @return [void]
def action_uninstall
notifying_block do
uninstall_git
end
end
# The path to the `git` binary. This is an output property.
#
# @abstract
# @return [String]
def git_binary
raise NotImplementedError
end
# The environment variables for this Git. This is an output property.
#
# @return [Hash<String, String>]
def git_environment
{}
end
private
# Install git.
#
# @abstract
# @return [void]
def install_git
raise NotImplementedError
end
# Uninstall git.
#
# @abstract
# @return [void]
def uninstall_git
raise NotImplementedError
end
end
end
end

View File

@ -0,0 +1,79 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_git/git_client_providers/base'
module PoiseGit
module GitClientProviders
# Inversion provider for the `poise_git_client` resource to use a fake Git,
# for use in unit tests.
#
# @since 1.0.0
# @see PoiseGit::Resources::PoiseGitClient::Resource
# @provides poise_git_client
class Dummy < Base
provides(:dummy)
# Enable by default on ChefSpec.
#
# @api private
def self.provides_auto?(node, _resource)
node.platform?('chefspec')
end
# Manual overrides for dummy data.
#
# @api private
def self.default_inversion_options(node, resource)
super.merge({
git_binary: '/git',
git_environment: nil,
})
end
# The `install` action for the `poise_git_client` resource.
#
# @return [void]
def action_install
# This space left intentionally blank.
end
# The `uninstall` action for the `poise_git_client` resource.
#
# @return [void]
def action_uninstall
# This space left intentionally blank.
end
# Path to the non-existent Git.
#
# @return [String]
def git_binary
options['git_binary']
end
# Environment for the non-existent Git.
#
# @return [String]
def git_environment
options['git_environment'] || super
end
end
end
end

View File

@ -0,0 +1,73 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_languages'
require 'poise_git/git_client_providers/base'
module PoiseGit
module GitClientProviders
# A provider for `poise_git_client` to install from distro packages.
#
# @since 1.0.0
# @see PoiseGit::Resources::PoiseGitClient::Resource
# @provides poise_git_client
class System < Base
include PoiseLanguages::System::Mixin
provides(:system)
packages('git', {
omnios: {default: %w{developer/versioning/git}},
smartos: {default: %w{scmgit}},
})
# Output value for the Git binary we are installing.
def git_binary
# What should this be for OmniOS and SmartOS?
"/usr/bin/git"
end
private
# Install git from system packages.
#
# @return [void]
def install_git
install_system_packages do
# Unlike language-ish packages, we don't need a headers package.
dev_package false
end
end
# Remove git from system packages.
#
# @return [void]
def uninstall_git
uninstall_system_packages do
# Unlike language-ish packages, we don't need a headers package.
dev_package false
end
end
def system_package_candidates(version)
# This is kind of silly, could use a refactor in the mixin but just
# moving on for right now.
node.value_for_platform(self.class.packages) || %w{git}
end
end
end
end

View File

@ -0,0 +1,37 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise/utils'
require 'poise_languages'
module PoiseGit
# Mixin for resources and providers which run Git commands.
#
# @since 1.0.0
module GitCommandMixin
include Poise::Utils::ResourceProviderMixin
# Mixin for resources which run Git commands.
module Resource
include PoiseLanguages::Command::Mixin::Resource(:git, runtime: :poise_git_client)
end
module Provider
include PoiseLanguages::Command::Mixin::Provider(:git)
end
end
end

View File

@ -0,0 +1,27 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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 'poise_git/resources/poise_git_client'
require 'poise_git/resources/poise_git'
module PoiseGit
# Chef resources and providers for poise-git.
#
# @since 1.0.0
module Resources
end
end

View File

@ -0,0 +1,252 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 'shellwords'
require 'zlib'
require 'chef/provider/git'
require 'chef/resource/git'
require 'poise'
require 'poise_git/git_command_mixin'
require 'poise_git/safe_string'
module PoiseGit
module Resources
# (see PoiseGit::Resource)
# @since 1.0.0
module PoiseGit
# A `poise_git` resource to manage Python installations using pip.
#
# @provides poise_git
# @action checkout
# @action export
# @action sync
# @example
# poise_git '/srv/myapp' do
# repository 'https://...'
# deploy_key data_bag_item('deploy_keys', 'myapp')['key']
# end
class Resource < Chef::Resource::Git
include Poise
include ::PoiseGit::GitCommandMixin
provides(:poise_git)
# Manually create matchers because #actions is unreliable.
%i{checkout export sync}.each do |action|
Poise::Helpers::ChefspecMatchers.create_matcher(:poise_git, action)
end
# @api private
def initialize(*args)
super
# Because the superclass declares this, we have to as well. Should be
# removable at some point when Chef makes everything use the provider
# resolver system instead.
@resource_name = :poise_git if defined?(@resource_name) && @resource_name
@provider = ::PoiseGit::Resources::PoiseGit::Provider if defined?(@provider) && @provider
end
# @!attribute strict_ssh
# Enable strict SSH host key checking. Defaults to false.
# @return [Boolean]
attribute(:strict_ssh, equal_to: [true, false], default: false)
# @!attribute deploy_key
# SSH deploy key as either a string value or a path to a key file.
# @return [String]
def deploy_key(val=nil)
# Use a SafeString for literal deploy keys so they aren't shown.
val = SafeString.new(val) if val && !deploy_key_is_local?(val)
set_or_return(:deploy_key, val, kind_of: String)
end
# Default SSH wrapper path.
#
# @api private
# @return [String]
def ssh_wrapper_path
@ssh_wrapper_path ||= "#{Chef::Config[:file_cache_path]}/poise_git_wrapper_#{Zlib.crc32(name)}"
end
# Guess if the deploy key is a local path or literal value.
#
# @api private
# @param key [String, nil] Key value to check. Defaults to self.key.
# @return [Boolean]
def deploy_key_is_local?(key=nil)
key ||= deploy_key
# Try to be mindful of Windows-y paths here even though they almost
# certainly won't actually work later on with ssh.
key && key =~ /\A(\/|[a-zA-Z]:)/
end
# Path to deploy key.
#
# @api private
# @return [String]
def deploy_key_path
@deploy_key_path ||= if deploy_key_is_local?
deploy_key
else
"#{Chef::Config[:file_cache_path]}/poise_git_deploy_#{Zlib.crc32(name)}"
end
end
# Hook to force the git install via recipe if needed.
def after_created
if !parent_git && node['poise-git']['default_recipe']
# Use the default recipe to give us a parent the next time we ask.
run_context.include_recipe(node['poise-git']['default_recipe'])
# Force it to re-expand the cache next time.
@parent_git = nil
end
super
end
end
# The default provider for the `poise_git` resource.
#
# @see Resource
class Provider < Chef::Provider::Git
include Poise
include ::PoiseGit::GitCommandMixin
provides(:poise_git)
# @api private
def initialize(*args)
super
# Set the SSH wrapper path in a late-binding kind of way. This better
# supports situations where the user doesn't exist until Chef converges.
new_resource.ssh_wrapper(new_resource.ssh_wrapper_path) if new_resource.deploy_key
end
# Hack our special login in before load_current_resource runs because that
# needs access to the git remote.
#
# @api private
def load_current_resource
create_deploy_key if new_resource.deploy_key
super
end
# Like {#load_current_resource}, make sure git is installed since we might
# need it depending on the version of Chef.
#
# @api private
def define_resource_requirements
create_deploy_key if new_resource.deploy_key
super
end
private
# Install git and set up the deploy key if needed. Safe to call multiple
# times if needed.
#
# @api private
# @return [void]
def create_deploy_key
return if @create_deploy_key
Chef::Log.debug("[#{new_resource}] Creating deploy key")
old_why_run = Chef::Config[:why_run]
begin
# Forcibly disable why run support so these will always run, since
# we need to be able to talk to the git remote even just for the
# whyrun checks.
Chef::Config[:why_run] = false
notifying_block do
write_deploy_key
write_ssh_wrapper
end
ensure
Chef::Config[:why_run] = old_why_run
end
@create_deploy_key = true
end
# Copy the deploy key to a file if needed.
#
# @api private
# @return [void]
def write_deploy_key
# Check if we have a local path or some actual content
return if new_resource.deploy_key_is_local?
file new_resource.deploy_key_path do
owner new_resource.user
group new_resource.group
mode '600'
content new_resource.deploy_key
sensitive true
end
end
# Create the SSH wrapper script.
#
# @api private
# @return [void]
def write_ssh_wrapper
# Write out the GIT_SSH script, it should already be enabled above
file new_resource.ssh_wrapper_path do
owner new_resource.user
group new_resource.group
mode '700'
content %Q{#!/bin/sh\n/usr/bin/env ssh #{'-o "StrictHostKeyChecking=no" ' unless new_resource.strict_ssh}-i "#{new_resource.deploy_key_path}" $@\n}
end
end
# Patch back in the `#git` from the git provider. This otherwise conflicts
# with the `#git` defined by the DSL, which gets included in such a way
# that the DSL takes priority.
#
# @api private
def git(*args, &block)
self.class.superclass.instance_method(:git).bind(self).call(*args, &block)
end
# Trick all shell_out related things in the base class in to using
# my git_shell_out instead.
#
# @api private
def shell_out(*cmd, **options)
if @shell_out_hack_inner
# This is the real call.
super
else
# This ia call we want to intercept and send to our method.
begin
@shell_out_hack_inner = true
# Remove nils and flatten for compat with how core uses this method.
cmd.compact!
cmd.flatten!
# Reparse the command to get a clean array.
cmd = Shellwords.split(cmd.join(' '))
# We'll add the git command back in ourselves.
cmd.shift if cmd.first == 'git'
# Push the yak stack.
git_shell_out(*cmd, **options)
ensure
@shell_out_hack_inner = false
end
end
end
end
end
end
end

View File

@ -0,0 +1,82 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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/resource'
require 'poise'
module PoiseGit
module Resources
# (see PoiseGitClient::Resource)
# @since 1.0.0
module PoiseGitClient
# A `poise_git_client` resource to install a C compiler and build tools.
#
# @provides poise_git_client
# @action install
# @action uninstall
# @example
# poise_git_client 'git'
class Resource < Chef::Resource
include Poise(inversion: true, container: true)
provides(:poise_git_client)
actions(:install, :uninstall)
# @!attribute version
# Version of Git to install. The version is prefix-matched so `'2'`
# will install the most recent Git 2.x, and so on.
# @return [String]
# @example Install any version
# poise_git_client 'any' do
# version ''
# end
# @example Install Git 2
# poise_git_client '2'
attribute(:version, kind_of: String, default: lazy { default_version })
# The path to the `git` binary for this Git installation. This is
# an output property.
#
# @return [String]
# @example
# execute "#{resources('poise_git_client[git]').git_binary} init"
def git_binary
provider_for_action(:git_binary).git_binary
end
# The environment variables for this Git installation. This is an
# output property.
#
# @return [Hash<String, String>]
def git_environment
provider_for_action(:git_environment).git_environment
end
private
# Default value for the version property. Trims an optional `git-` from
# the resource name.
#
# @return [String]
def default_version
name[/^(git-?)?(.*)$/, 2] || ''
end
end
# Providers can be found under git_client_providers/.
end
end
end

View File

@ -0,0 +1,25 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 PoiseGit
# A string that won't be shown in Chef error output
class SafeString < String
def to_text
'"suppressed sensitive value"'
end
end
end

View File

@ -0,0 +1,20 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 PoiseGit
VERSION = '1.0.0'
end

View File

@ -0,0 +1,19 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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.
#
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
require "poise_git/cheftie"

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
#
# Copyright 2017, Noah Kantrowitz
#
# 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.
#
poise_git_client 'git' do
node['poise-git']['recipe'].each do |key, value|
# Skip nils, use false if you want to disable something.
send(key, value) unless value.nil?
end
end

View File

@ -0,0 +1,22 @@
# Poise-Ruby-Build Changelog
## v1.1.0
* Chef 13 support.
* Switch to `poise-git` and `poise-build-essential` rather than the traditional
cookbooks to ensure support for older Chef and clean up lingering bugs.
## v1.0.2
* Fix a typo that prevented uninstalling `ruby_build` runtimes.
* Ensure bzip2 is installed as some minimal Linux images do not include it.
## v1.0.1
* Install bundler in the same way as other `ruby_runtime` providers.
* New integration test harness.
## v1.0.0
* Initial release!

View File

@ -0,0 +1,53 @@
# Poise-Ruby-Build Cookbook
[![Build Status](https://img.shields.io/travis/poise/poise-ruby-build.svg)](https://travis-ci.org/poise/poise-ruby-build)
[![Gem Version](https://img.shields.io/gem/v/poise-ruby-build.svg)](https://rubygems.org/gems/poise-ruby-build)
[![Cookbook Version](https://img.shields.io/cookbook/v/poise-ruby-build.svg)](https://supermarket.chef.io/cookbooks/poise-ruby-build)
[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-ruby-build.svg)](https://codecov.io/github/poise/poise-ruby-build)
[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-ruby-build.svg)](https://gemnasium.com/poise/poise-ruby-build)
[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
A [ruby-build](https://github.com/sstephenson/ruby-build) provider for the
[poise-ruby cookbook](https://github.com/poise/poise-ruby).
## Provider
The `ruby_build` provider uses [ruby-build](https://github.com/sstephenson/ruby-build)
to compile and install Ruby.
```ruby
ruby_runtime 'myapp' do
provider :ruby_build
version '2.1'
end
```
### Options
* `install_doc` Install documentation with Ruby. *(default: false)*
* `install_repo` Git URI to clone to install ruby-build. *(default: https://github.com/sstephenson/ruby-build.git)*
* `install_rev` Git revision to clone to install ruby-build. *(default: master)*
* `prefix` Base path for install ruby-build and rubies. *(default: /opt/ruby_build)*
* `version` Override the Ruby version.
## Sponsors
Development sponsored by [Bloomberg](http://www.bloomberg.com/company/technology/).
The Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).
## License
Copyright 2015-2017, Noah Kantrowitz
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.

View File

@ -0,0 +1,17 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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['poise-ruby']['provider'] = 'ruby_build'

View File

@ -0,0 +1,26 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 PoiseRuby
# A plugin for poise-ruby to compile Ruby using ruby-build.
#
# @since 1.0.0
module RubyBuild
autoload :Provider, 'poise_ruby/ruby_build/provider'
autoload :VERSION, 'poise_ruby/ruby_build/version'
end
end

View File

@ -0,0 +1,17 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 'poise_ruby/ruby_build/provider'

View File

@ -0,0 +1,219 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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/mixin/shell_out'
require 'poise_ruby/ruby_providers/base'
module PoiseRuby
module RubyBuild
# Inversion provider for `ruby_runtime` to install via ruby-build.
#
# @since 1.0.0
# @provides ruby_build
class Provider < PoiseRuby::RubyProviders::Base
include Chef::Mixin::ShellOut
provides(:ruby_build)
# Add default options for ruby-build.
#
# @param node [Chef::Node] Node to load from.
# @param resource [Chef::Resource] Resource to load from.
# @return [Hash]
def self.default_inversion_options(node, resource)
super.merge({
install_doc: false,
install_repo: 'https://github.com/sstephenson/ruby-build.git',
install_rev: 'master',
prefix: '/opt/ruby_build',
})
end
# Path to the compiled Ruby binary.
#
# @return [String]
def ruby_binary
::File.join(options['prefix'], 'builds', new_resource.name, 'bin', 'ruby')
end
# Find the full definition name to use with ruby-build. This is based on
# prefix matching from the `ruby-build --definitions` output. Only
# public because sigh scoping.
#
# @!visibility private
# @return [String]
def ruby_definition
@ruby_definition ||= begin
cmd = shell_out!([::File.join(options['prefix'], 'install', options['install_rev'], 'bin', 'ruby-build'), '--definitions'])
version_prefix = options['version']
# Default for '', look for MRI 2.x.
version_prefix = '2' if version_prefix == ''
# Find the last line that starts with the target version.
cmd.stdout.split(/\n/).reverse.find {|line| line.start_with?(version_prefix) } || options['version']
end
end
private
# Path to the version record file. Should contain the actual version of
# Ruby installed in this folder.
#
# @return [String]
def version_file
::File.join(options['prefix'], 'builds', new_resource.name, 'VERSION')
end
# Installs ruby-build and then uses that to install Ruby.
#
# @return [void]
def install_ruby
# We assume that if the version_file exists, ruby-build is already
# installed. Calling #ruby_definition will shell out to ruby-build.
if ::File.exists?(version_file) && IO.read(version_file) == ruby_definition
# All set, bail out.
return
end
converge_by("Installing Ruby #{options['version'].empty? ? new_resource.name : options['version']} via ruby-build") do
notifying_block do
create_prefix_directory
create_install_directory
create_builds_directory
install_ruby_build
install_dependencies
# Possible failed install or a version change. Wipe the existing build.
# If we weren't going to rebuild, we would have bailed out already.
uninstall_ruby
end
# Second converge has ruby-build installed so using #ruby_definition
# is safe.
notifying_block do
build_ruby
create_version_file
end
end
end
# Create the base prefix directory.
#
# @return [Chef::Resource::Directory]
def create_prefix_directory
directory options['prefix'] do
owner 'root'
group 'root'
mode '755'
end
end
# Create the directory to hold ruby-build installations.
#
# @return [Chef::Resource::Directory]
def create_install_directory
directory ::File.join(options['prefix'], 'install') do
owner 'root'
group 'root'
mode '755'
end
end
# Create the directory to hold compiled rubies.
#
# @return [Chef::Resource::Directory]
def create_builds_directory
directory ::File.join(options['prefix'], 'builds') do
owner 'root'
group 'root'
mode '755'
end
end
# Clone ruby-build from GitHub or a similar git server. Will also install
# git via the `git` cookbook unless `no_dependencies` is set.
#
# @return [Chef::Resource::Git]
def install_ruby_build
poise_git ::File.join(options['prefix'], 'install', options['install_rev']) do
repository options['install_repo']
revision options['install_rev']
user 'root'
end
end
# Install dependency packages needed to compile Ruby. A no-op if
# `no_dependencies` is set.
#
# @return [Chef::Resource::Package]
def install_dependencies
return if options['no_dependencies']
poise_build_essential 'build_essential'
unless options['version'].start_with?('jruby')
pkgs = node.value_for_platform_family(
debian: %w{libreadline6-dev zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev libxml2-dev libxslt1-dev},
rhel: %w{tar bzip2 readline-devel zlib-devel libffi-devel openssl-devel libxml2-devel libxslt-devel},
suse: %w{zlib-devel libffi-devel sqlite3-devel libxml2-devel libxslt-devel},
)
package pkgs if pkgs
end
end
# Compile Ruby using ruby-build.
#
# @return [Chef::Resource::Execute]
def build_ruby
# Figure out the argument to disable docs
disable_docs = if options['install_doc']
nil
elsif options['version'].start_with?('rbx')
nil # Doesn't support?
elsif options['version'].start_with?('ree')
'--no-dev-docs'
else
'--disable-install-doc'
end
execute 'ruby-build install' do
command [::File.join(options['prefix'], 'install', options['install_rev'], 'bin', 'ruby-build'), ruby_definition, ::File.join(options['prefix'], 'builds', new_resource.name)]
user 'root'
environment 'RUBY_CONFIGURE_OPTS' => disable_docs if disable_docs
end
end
# Write out the concrete version to the VERSION file.
#
# @return [Chef::Resource::File]
def create_version_file
file version_file do
owner 'root'
group 'root'
mode '644'
content ruby_definition
end
end
# Delete the compiled Ruby, but leave ruby-build installed as it may be
# shared by other resources.
#
# @return [Chef::Resource::Directory]
def uninstall_ruby
directory ::File.join(options['prefix'], 'builds', new_resource.name) do
action :delete
end
end
end
end
end

View File

@ -0,0 +1,22 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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 PoiseRuby
module RubyBuild
VERSION = '1.1.0'
end
end

View File

@ -0,0 +1,19 @@
#
# Copyright 2015-2017, Noah Kantrowitz
#
# 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.
#
raise 'Halite is not compatible with no_lazy_load false, please set no_lazy_load true in your Chef configuration file.' unless Chef::Config[:no_lazy_load]
$LOAD_PATH << File.expand_path('../../files/halite_gem', __FILE__)
require "poise_ruby/ruby_build/cheftie"

View File

@ -0,0 +1 @@
{"name":"poise-ruby-build","version":"1.1.0","description":"A Chef cookbook for managing Ruby installations using ruby-build.","long_description":"# Poise-Ruby-Build Cookbook\n\n[![Build Status](https://img.shields.io/travis/poise/poise-ruby-build.svg)](https://travis-ci.org/poise/poise-ruby-build)\n[![Gem Version](https://img.shields.io/gem/v/poise-ruby-build.svg)](https://rubygems.org/gems/poise-ruby-build)\n[![Cookbook Version](https://img.shields.io/cookbook/v/poise-ruby-build.svg)](https://supermarket.chef.io/cookbooks/poise-ruby-build)\n[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-ruby-build.svg)](https://codecov.io/github/poise/poise-ruby-build)\n[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-ruby-build.svg)](https://gemnasium.com/poise/poise-ruby-build)\n[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n\nA [ruby-build](https://github.com/sstephenson/ruby-build) provider for the\n[poise-ruby cookbook](https://github.com/poise/poise-ruby).\n\n## Provider\n\nThe `ruby_build` provider uses [ruby-build](https://github.com/sstephenson/ruby-build)\nto compile and install Ruby.\n\n```ruby\nruby_runtime 'myapp' do\n provider :ruby_build\n version '2.1'\nend\n```\n\n### Options\n\n* `install_doc` Install documentation with Ruby. *(default: false)*\n* `install_repo` Git URI to clone to install ruby-build. *(default: https://github.com/sstephenson/ruby-build.git)*\n* `install_rev` Git revision to clone to install ruby-build. *(default: master)*\n* `prefix` Base path for install ruby-build and rubies. *(default: /opt/ruby_build)*\n* `version` Override the Ruby version.\n\n## Sponsors\n\nDevelopment sponsored by [Bloomberg](http://www.bloomberg.com/company/technology/).\n\nThe Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).\n\n## License\n\nCopyright 2015-2017, Noah Kantrowitz\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","maintainer":"Noah Kantrowitz","maintainer_email":"noah@coderanger.net","license":"Apache 2.0","platforms":{},"dependencies":{"poise":"~> 2.0","poise-build-essential":"~> 1.0","poise-git":"~> 1.0","poise-ruby":"~> 2.1"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/poise/poise-ruby-build","issues_url":"https://github.com/poise/poise-ruby-build/issues","chef_version":[["< 14",">= 12.1"]],"ohai_version":[]}

View File

@ -2,11 +2,28 @@ seven_zip Cookbook CHANGELOG
========================
This file is used to list changes made in each version of the seven_zip cookbook.
v2.0.2
------
- Add timeout to extract action on seven\_zip resource and configurable default\_extract_timeout attribute.
v2.0.1
------
- [GH Issue 21 - NoMethodError: Undefined method or attribute `kernel' on `node'](https://github.com/daptiv/seven_zip/issues/21).
v2.0.0
------
- [Upgrade to 7-Zip 15.14](https://github.com/daptiv/seven_zip/pull/9).
- [7-Zip now installed to the default MSI location by default](https://github.com/daptiv/seven_zip/pull/11).
- [7z.exe is located using the Windows registry unless the home attribute is explicitly set](https://github.com/daptiv/seven_zip/pull/10).
- [7-Zip is only added to the Windows PATH if the syspath attribute is set](https://github.com/daptiv/seven_zip/pull/11).
- [Installation idempotence check was fixed](https://github.com/daptiv/seven_zip/pull/14), package name was corrected.
- [TravisCI build added](https://github.com/daptiv/seven_zip/pull/12).
- [ServerSpec tests added](https://github.com/daptiv/seven_zip/pull/9)
- [Document Archive LRWP](https://github.com/daptiv/seven_zip/pull/6)
v1.0.2
------
### Improvement
- **[COOK-3476](https://tickets.opscode.com/browse/COOK-3476)** - Upgrade to 7-zip 9.22
- [COOK-3476 - Upgrade to 7-zip 9.22](https://tickets.opscode.com/browse/COOK-3476)
1.0.0
-----

View File

@ -1,29 +0,0 @@
If you would like to contribute, please open a ticket in JIRA:
* http://tickets.opscode.com
Create the ticket in the COOK project and use the cookbook name as the
component.
For all code contributions, we ask that contributors sign a
contributor license agreement (CLA). Instructions may be found here:
* http://wiki.opscode.com/display/chef/How+to+Contribute
When contributing changes to individual cookbooks, please do not
modify the version number in the metadata.rb. Also please do not
update the CHANGELOG.md for a new version. Not all changes to a
cookbook may be merged and released in the same versions. Opscode will
handle the version updates during the release process. You are welcome
to correct typos or otherwise make updates to documentation in the
README.
If a contribution adds new platforms or platform versions, indicate
such in the body of the commit message(s), and update the relevant
COOK ticket. When writing commit messages, it is helpful for others if
you indicate the COOK ticket. For example:
git commit -m '[COOK-1041] Updated pool resource to correctly delete.'
In the ticket itself, it is also helpful if you include log output of
a successful Chef run, but this is not absolutely required.

View File

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@ -1,40 +1,98 @@
seven_zip Cookbook
==============
[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-zip suite of tools (GUI and CLI).
[![Cookbook Version](http://img.shields.io/cookbook/v/seven_zip.svg)](https://supermarket.chef.io/cookbooks/seven_zip)
[![Build status](https://ci.appveyor.com/api/projects/status/y1lsnlkd2b3q6gfd/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/seven-zip/branch/master)
# seven_zip Cookbook
[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-zip suite of tools (GUI and CLI). This cookbook replaces the older [7-zip cookbook](https://github.com/sneal/7-zip).
Requirements
------------
### Platform
# Requirements
## Platforms
- Windows XP
- Windows Vista
- Windows Server 2003 R2
- Windows 7
- Windows 8, 8.1
- Windows 10
- Windows Server 2003 R2
- Windows Server 2008 (R1, R2)
- Windows 8
- Windows Server 2012
- Windows Server 2012 (R1, R2)
### Cookbooks
## Chef
- Chef >= 11.6
## Cookbooks
- windows
# Attributes
## Optional
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><code>['seven_zip']['home']</code></td>
<td>String</td>
<td>7-Zip installation directory.</td>
<td></td>
</tr>
<tr>
<td><code>['seven_zip']['syspath']</code></td>
<td>Boolean</td>
<td>If true, adds 7-zip directory to system PATH environment variable.</td>
<td></td>
</tr>
<tr>
<td><code>['seven_zip']['default_extract_timeout']</code></td>
<td>Integer</td>
<td>The default timeout for an extract operation in seconds. This can be overridden by a resource attribute.</td>
<td>600</td>
</tr>
</table>
Attributes
----------
- `node['seven_zip']['home']` - location to install 7-zip files to. default is `%SYSTEMDRIVE%\7-zip`
# Usage
## default
Add `seven_zip::default` to your run\_list which will download and install 7-zip for the current Windows platform.
Usage
-----
### default
Downloads and installs 7-zip to the location specified by `node['seven_zip']['home']`. Also ensures `node['seven_zip']['home']` is in the system path.
# Resource/Provider
## seven_zip_archive
Extracts a 7-zip compatible archive (iso, zip, 7z etc) to the specified destination directory.
#### Actions
- `:extract` - Extract a 7-zip compatible archive
License & Authors
-----------------
- Author:: Seth Chisamore (<schisamo@opscode.com>)
#### Attribute Parameters
- `path` - Name attribute. The destination to extract to.
- `source` - The file path to the archive to extract.
- `overwrite` - Defaults to false. If true, the destination files will be overwritten.
- `checksum` - The archive file checksum.
- `timeout` - The extract action timeout in seconds, defaults to `node['seven_zip']['default_extract_timeout']`.
#### Examples
Extract 7-zip source files to `C:\seven_zip_source`.
```ruby
seven_zip_archive 'seven_zip_source' do
path 'C:\seven_zip_source'
source 'http://www.7-zip.org/a/7z1514-src.7z'
overwrite true
checksum '3713aed72728eae8f6649e4803eba0b3676785200c76df6269034c520df4bbd5'
timeout 30
end
```
# Recipes
## default
Installs 7-zip and adds it to your system PATH.
# License & Authors
- Author:: Seth Chisamore (<schisamo@chef.io>)
- Author:: Shawn Neal (<sneal@sneal.net>)
```text
Copyright:: 2011, Opscode, Inc.
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.

View File

@ -1,9 +1,9 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook Name:: seven_zip
# Attribute:: default
#
# Copyright:: Copyright (c) 2011 Opscode, Inc.
# Copyright:: Copyright (c) 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.
@ -18,14 +18,14 @@
# limitations under the License.
#
if kernel['machine'] =~ /x86_64/
default['seven_zip']['url'] = "http://www.7-zip.org/a/7z920-x64.msi"
default['seven_zip']['checksum'] = "62df458bc521001cd9a947643a84810ecbaa5a16b5c8e87d80df8e34c4a16fe2"
default['seven_zip']['package_name'] = "7z920-x64.msi"
if node['kernel']['machine'] == 'x86_64'
default['seven_zip']['url'] = 'http://www.7-zip.org/a/7z1514-x64.msi'
default['seven_zip']['checksum'] = 'cefe1a9092d8a6be68468c33910d6206b40e934fb63cab686c5cccf369fbf712'
default['seven_zip']['package_name'] = '7-Zip 15.14 (x64 edition)'
else
default['seven_zip']['url'] = "http://www.7-zip.org/a/7z920.msi"
default['seven_zip']['checksum'] = "fe4807b4698ec89f82de7d85d32deaa4c772fc871537e31fb0fccf4473455cb8"
default['seven_zip']['package_name'] = "7z920.msi"
default['seven_zip']['url'] = 'http://www.7-zip.org/a/7z1514.msi'
default['seven_zip']['checksum'] = 'eaf58e29941d8ca95045946949d75d9b5455fac167df979a7f8e4a6bf2d39680'
default['seven_zip']['package_name'] = '7-Zip 15.14'
end
default['seven_zip']['home'] = "#{ENV['SYSTEMDRIVE']}\\7-zip"
default['seven_zip']['default_extract_timeout'] = 600

View File

@ -0,0 +1,33 @@
#
# Author:: Shawn Neal (<sneal@sneal.net>)
# Cookbook Name:: visualstudio
#
# Copyright 2015, Shawn Neal
#
# 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.
#
if defined?(ChefSpec)
chefspec_version = Gem.loaded_specs['chefspec'].version
define_method = if chefspec_version < Gem::Version.new('4.1.0')
ChefSpec::Runner.method(:define_runner_method)
else
ChefSpec.method(:define_matcher)
end
define_method.call :seven_zip_archive
def extract_seven_zip_archive(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:seven_zip_archive, :extract, resource_name)
end
end

View File

@ -1,41 +1 @@
{
"name": "seven_zip",
"description": "Installs/Configures the 7-zip file archiver",
"long_description": "seven_zip Cookbook\n==============\n[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-zip suite of tools (GUI and CLI).\n\n\nRequirements\n------------\n### Platform\n- Windows XP\n- Windows Vista\n- Windows Server 2003 R2\n- Windows 7\n- Windows Server 2008 (R1, R2)\n- Windows 8\n- Windows Server 2012\n\n### Cookbooks\n- windows\n\n\nAttributes\n----------\n- `node['seven_zip']['home']` - location to install 7-zip files to. default is `%SYSTEMDRIVE%\\7-zip`\n\n\nUsage\n-----\n### default\nDownloads and installs 7-zip to the location specified by `node['seven_zip']['home']`. Also ensures `node['seven_zip']['home']` is in the system path.\n\n\nLicense & Authors\n-----------------\n- Author:: Seth Chisamore (<schisamo@opscode.com>)\n\n```text\nCopyright:: 2011, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
"maintainer": "Opscode, Inc.",
"maintainer_email": "cookbooks@opscode.com",
"license": "Apache 2.0",
"platforms": {
"windows": ">= 0.0.0"
},
"dependencies": {
"windows": ">= 1.2.2"
},
"recommendations": {
},
"suggestions": {
},
"conflicting": {
},
"providing": {
},
"replacing": {
},
"attributes": {
},
"groupings": {
},
"recipes": {
},
"version": "1.0.4",
"source_url": "",
"issues_url": ""
}
{"name":"seven_zip","version":"2.0.2","description":"Installs/Configures the 7-zip file archiver","long_description":"[![Cookbook Version](http://img.shields.io/cookbook/v/seven_zip.svg)](https://supermarket.chef.io/cookbooks/seven_zip)\n[![Build status](https://ci.appveyor.com/api/projects/status/y1lsnlkd2b3q6gfd/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/seven-zip/branch/master)\n\n# seven_zip Cookbook\n[7-Zip](http://www.7-zip.org/) is a file archiver with a high compression ratio. This cookbook installs the full 7-zip suite of tools (GUI and CLI). This cookbook replaces the older [7-zip cookbook](https://github.com/sneal/7-zip).\n\n# Requirements\n## Platforms\n- Windows XP\n- Windows Vista\n- Windows 7\n- Windows 8, 8.1\n- Windows 10\n- Windows Server 2003 R2\n- Windows Server 2008 (R1, R2)\n- Windows Server 2012 (R1, R2)\n\n## Chef\n- Chef >= 11.6\n\n## Cookbooks\n- windows\n\n# Attributes\n## Optional\n<table>\n <tr>\n <th>Key</th>\n <th>Type</th>\n <th>Description</th>\n <th>Default</th>\n </tr>\n <tr>\n <td><code>['seven_zip']['home']</code></td>\n <td>String</td>\n <td>7-Zip installation directory.</td>\n <td></td>\n </tr>\n <tr>\n <td><code>['seven_zip']['syspath']</code></td>\n <td>Boolean</td>\n <td>If true, adds 7-zip directory to system PATH environment variable.</td>\n <td></td>\n </tr>\n <tr>\n <td><code>['seven_zip']['default_extract_timeout']</code></td>\n <td>Integer</td>\n <td>The default timeout for an extract operation in seconds. This can be overridden by a resource attribute.</td>\n <td>600</td>\n </tr>\n</table>\n\n# Usage\n## default\n\nAdd `seven_zip::default` to your run\\_list which will download and install 7-zip for the current Windows platform. \n\n# Resource/Provider\n## seven_zip_archive\nExtracts a 7-zip compatible archive (iso, zip, 7z etc) to the specified destination directory.\n\n#### Actions\n- `:extract` - Extract a 7-zip compatible archive\n\n#### Attribute Parameters\n- `path` - Name attribute. The destination to extract to.\n- `source` - The file path to the archive to extract.\n- `overwrite` - Defaults to false. If true, the destination files will be overwritten.\n- `checksum` - The archive file checksum.\n- `timeout` - The extract action timeout in seconds, defaults to `node['seven_zip']['default_extract_timeout']`.\n\n#### Examples\nExtract 7-zip source files to `C:\\seven_zip_source`.\n\n```ruby\nseven_zip_archive 'seven_zip_source' do\n path 'C:\\seven_zip_source'\n source 'http://www.7-zip.org/a/7z1514-src.7z'\n overwrite true\n checksum '3713aed72728eae8f6649e4803eba0b3676785200c76df6269034c520df4bbd5'\n timeout 30\nend\n```\n\n# Recipes\n## default\n\nInstalls 7-zip and adds it to your system PATH.\n\n# License & Authors\n- Author:: Seth Chisamore (<schisamo@chef.io>)\n- Author:: Shawn Neal (<sneal@sneal.net>)\n\n```text\nCopyright:: 2011-2016, Chef Software, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Shawn Neal","maintainer_email":"sneal@sneal.net","license":"Apache 2.0","platforms":{"windows":">= 0.0.0"},"dependencies":{"windows":">= 1.2.2"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{}}

View File

@ -1,10 +0,0 @@
name "seven_zip"
maintainer "Opscode, Inc."
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs/Configures the 7-zip file archiver"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.0.4"
supports "windows"
depends "windows", ">= 1.2.2"

View File

@ -1,5 +1,5 @@
#
# Author:: Shawn Neal (<sneal@daptiv.com>)
# Author:: Shawn Neal (<sneal@sneal.net>)
# Cookbook Name:: seven_zip
# Provider:: archive
#
@ -28,21 +28,41 @@ def whyrun_supported?
true
end
use_inline_resources
action :extract do
converge_by("Extract #{@new_resource.source} => #{@new_resource.path} (overwrite=#{@new_resource.overwrite})") do
FileUtils.mkdir_p(@new_resource.path) unless Dir.exists?(@new_resource.path)
FileUtils.mkdir_p(@new_resource.path) unless Dir.exist?(@new_resource.path)
local_source = cached_file(@new_resource.source, @new_resource.checksum)
cmd = "#{seven_zip_exe} x"
cmd << " -y" if @new_resource.overwrite
cmd << " -o#{win_friendly_path(@new_resource.path)}"
cmd << " #{local_source}"
cmd = "\"#{seven_zip_exe}\" x"
cmd << ' -y' if @new_resource.overwrite
cmd << " -o\"#{win_friendly_path(@new_resource.path)}\""
cmd << " \"#{local_source}\""
Chef::Log.debug(cmd)
shell_out!(cmd)
shell_out!(cmd, timeout: extract_timeout)
end
end
def seven_zip_exe()
Chef::Log.debug("seven zip home: #{node['seven_zip']['home']}")
win_friendly_path(::File.join(node['seven_zip']['home'], '7z.exe'))
def seven_zip_exe
path = if node['seven_zip']['home']
node['seven_zip']['home']
else
seven_zip_exe_from_registry
end
Chef::Log.debug("Using 7-zip home: #{path}")
win_friendly_path(::File.join(path, '7z.exe'))
end
def seven_zip_exe_from_registry
require 'win32/registry'
# Read path from recommended Windows App Paths registry location
# docs: https://msdn.microsoft.com/en-us/library/windows/desktop/ee872121
::Win32::Registry::HKEY_LOCAL_MACHINE.open(
'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe',
::Win32::Registry::KEY_READ
).read_s('Path')
end
def extract_timeout
@new_resource.timeout || node['seven_zip']['default_extract_timeout']
end

View File

@ -1,9 +1,9 @@
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Author:: Seth Chisamore (<schisamo@chef.io>)
# Cookbook Name:: seven_zip
# Recipe:: default
#
# Copyright 2011, Opscode, Inc.
# 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.
@ -21,11 +21,21 @@
windows_package node['seven_zip']['package_name'] do
source node['seven_zip']['url']
checksum node['seven_zip']['checksum']
options "INSTALLDIR=\"#{node['seven_zip']['home']}\""
options "INSTALLDIR=\"#{node['seven_zip']['home']}\"" if node['seven_zip']['home']
action :install
end
# update path
windows_path "#{node['seven_zip']['home']}" do
windows_path 'seven_zip' do
path lazy {
if node['seven_zip']['home']
node['seven_zip']['home']
else
::Win32::Registry::HKEY_LOCAL_MACHINE.open(
'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\7zFM.exe',
::Win32::Registry::KEY_READ
).read_s('Path')
end
}
action :add
end
end if node['seven_zip']['syspath']

View File

@ -1,5 +1,5 @@
#
# Author:: Shawn Neal (<sneal@daptiv.com>)
# Author:: Shawn Neal (<sneal@sneal.net>)
# Cookbook Name:: seven_zip
# Resource:: archive
#
@ -22,7 +22,8 @@ default_action :extract
actions :extract
attribute :path, :kind_of => String, :name_attribute => true
attribute :source, :kind_of => String
attribute :overwrite, :kind_of => [ TrueClass, FalseClass ], :default => false
attribute :checksum, :kind_of => String
attribute :path, kind_of: String, name_attribute: true
attribute :source, kind_of: String
attribute :overwrite, kind_of: [TrueClass, FalseClass], default: false
attribute :checksum, kind_of: String
attribute :timeout, kind_of: Integer

View File

@ -1,6 +1,7 @@
{
"run_list": [
"kosmos-base",
"kosmos-redis",
"sockethub",
"sockethub::proxy",
"kosmos-wordpress",

View File

@ -0,0 +1,18 @@
{
"run_list": [
"kosmos-base",
"kosmos-redis",
"kosmos-mastodon",
"kosmos-mastodon::nginx"
],
"normal": {
"postgresql": {
"password": {
"postgres": "thiscrapaintsafecuznocrypto"
}
}
},
"automatic": {
"ipaddress": "staging.kosmos.org"
}
}

View File

@ -17,9 +17,6 @@ package 'mailutils'
node.override['unattended-upgrades']['admin_email'] = 'ops@5apps.com'
include_recipe 'unattended-upgrades'
package 'ruby2.1'
package 'ruby2.1-dev'
package 'mosh'
# Searches data bag "users" for groups attribute "sysadmin".

View File

@ -8,7 +8,8 @@ version '0.1.0'
depends "kosmos-nginx"
depends "kosmos-nodejs"
depends "kosmos-ruby"
depends "kosmos-redis"
depends "poise-ruby-build"
depends "application_ruby"
depends "application_javascript"
depends "postgresql"

View File

@ -8,7 +8,7 @@
#
include_recipe "kosmos-nodejs"
include_recipe "kosmos-ruby"
# include_recipe "kosmos-ruby"
node.override['postgresql']['enable_pgdg_apt'] = false
include_recipe "postgresql::server"
include_recipe "postgresql::ruby"
@ -52,7 +52,7 @@ application mastodon_path do
user "mastodon"
group "mastodon"
repository "https://github.com/67P/mastodon.git"
revision "kosmos"
revision "staging"
end
mastodon_credentials = Chef::EncryptedDataBagItem.load('credentials', 'mastodon')
@ -83,6 +83,11 @@ application mastodon_path do
recursive true
end
ruby_runtime do
provider :ruby_build
version '2.4.1'
end
bundle_install do
user "mastodon"
deployment true
@ -109,9 +114,10 @@ application mastodon_path do
source "mastodon-web.systemd.service.erb"
variables user: user,
app_dir: mastodon_path,
port: node["kosmos-mastodon"]["puma_port"]
port: node["kosmos-mastodon"]["puma_port"],
bundle_path: '/opt/ruby_build/builds/opt/mastodon/bin/bundle'
notifies :run, "execute[systemctl daemon-reload]", :delayed
notifies :restart, "service[mastodon-web]", :delayed
# notifies :restart, "service[mastodon-web]", :delayed
end
service "mastodon-web" do
@ -123,9 +129,10 @@ application mastodon_path do
template "/lib/systemd/system/mastodon-sidekiq.service" do
source "mastodon-sidekiq.systemd.service.erb"
variables user: user,
app_dir: mastodon_path
app_dir: mastodon_path,
bundle_path: '/opt/ruby_build/builds/opt/mastodon/bin/bundle'
notifies :run, "execute[systemctl daemon-reload]", :delayed
notifies :restart, "service[mastodon-sidekiq]", :delayed
# notifies :restart, "service[mastodon-sidekiq]", :delayed
end
service "mastodon-sidekiq" do
@ -140,7 +147,7 @@ application mastodon_path do
app_dir: mastodon_path,
port: node["kosmos-mastodon"]["streaming_port"]
notifies :run, "execute[systemctl daemon-reload]", :delayed
notifies :restart, "service[mastodon-streaming]", :delayed
# notifies :restart, "service[mastodon-streaming]", :delayed
end
service "mastodon-streaming" do
@ -148,10 +155,10 @@ application mastodon_path do
end
end
unless node.chef_environment == "development"
# Backup the database to S3
node.override["backup"]["postgresql"]["host"] = "localhost"
node.override["backup"]["postgresql"]["username"] = "postgres"
node.override["backup"]["postgresql"]["password"] = node['postgresql']['password']['postgres']
include_recipe "backup"
end
# unless node.chef_environment == "development"
# # Backup the database to S3
# node.override["backup"]["postgresql"]["host"] = "localhost"
# node.override["backup"]["postgresql"]["username"] = "postgres"
# node.override["backup"]["postgresql"]["password"] = node['postgresql']['password']['postgres']
# include_recipe "backup"
# end

View File

@ -9,7 +9,7 @@ User=<%= @user %>
WorkingDirectory=<%= @app_dir %>
Environment="RAILS_ENV=production"
Environment="DB_POOL=5"
ExecStart=/usr/local/bin/bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push
ExecStart=<%= @bundle_path %> exec sidekiq -c 5 -q default -q mailers -q pull -q push
TimeoutSec=15
Restart=always

View File

@ -12,10 +12,10 @@ PIDFile=<%= @app_dir %>/tmp/puma.pid
WorkingDirectory=<%= @app_dir %>
Environment="RAILS_ENV=production"
Environment="PORT=3000"
ExecStart=/usr/local/bin/bundle exec puma -C config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid
ExecStop=/usr/local/bin/bundle exec puma -C config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid stop
ExecReload=/usr/local/bin/bundle exec pumactl -F config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid phased-restart
ExecRestart=/usr/local/bin/bundle exec pumactl -F config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid restart
ExecStart=<%= @bundle_path %> exec puma -C config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid
ExecStop=<%= @bundle_path %> exec puma -C config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid stop
ExecReload=<%= @bundle_path %> exec pumactl -F config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid phased-restart
ExecRestart=<%= @bundle_path %> exec pumactl -F config/puma.rb --pidfile <%= @app_dir %>/tmp/puma.pid restart
TimeoutSec=15
Restart=always

View File

@ -1,11 +0,0 @@
# kosmos-ruby CHANGELOG
This file is used to list changes made in each version of the kosmos-ruby cookbook.
## 0.1.0
- [your_name] - Initial release of kosmos-ruby
- - -
Check the [Markdown Syntax Guide](http://daringfireball.net/projects/markdown/syntax) for help with Markdown.
The [Github Flavored Markdown page](http://github.github.com/github-flavored-markdown/) describes the differences between markdown on github and standard markdown.

View File

@ -1,80 +0,0 @@
# kosmos-ruby Cookbook
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwich.
## Requirements
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
e.g.
### Platforms
- SandwichOS
### Chef
- Chef 12.0 or later
### Cookbooks
- `toaster` - kosmos-ruby needs toaster to brown your bagel.
## Attributes
TODO: List your cookbook attributes here.
e.g.
### kosmos-ruby::default
<table>
<tr>
<th>Key</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<td><tt>['kosmos-ruby']['bacon']</tt></td>
<td>Boolean</td>
<td>whether to include bacon</td>
<td><tt>true</tt></td>
</tr>
</table>
## Usage
### kosmos-ruby::default
TODO: Write usage instructions for each cookbook.
e.g.
Just include `kosmos-ruby` in your node's `run_list`:
```json
{
"name":"my_node",
"run_list": [
"recipe[kosmos-ruby]"
]
}
```
## Contributing
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
1. Fork the repository on Github
2. Create a named feature branch (like `add_component_x`)
3. Write your change
4. Write tests for your change (if applicable)
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
## License and Authors
Authors: TODO: List authors

View File

@ -1 +0,0 @@
default['kosmos-ruby']['version'] = '2.3'

View File

@ -1,7 +0,0 @@
name 'kosmos-ruby'
maintainer 'Kosmos'
maintainer_email 'mail@kosmos.org'
license 'All rights reserved'
description 'Installs/Configures kosmos-ruby'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.1.0'

View File

@ -1,54 +0,0 @@
#
# Cookbook Name:: kosmos-ruby
# Recipe:: default
#
# Copyright 2017, Kosmos
#
# All rights reserved - Do Not Redistribute
#
package_name = "ruby#{node['kosmos-ruby']['version']}"
apt_repository 'brightbox_ruby' do
uri 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu'
distribution node['lsb']['codename']
components ['main']
keyserver 'keyserver.ubuntu.com'
key '80F70E11F0F0D5F10CB20E62F5DA5F09C3173AA6'
end
packages = [
"ruby#{node['kosmos-ruby']['version']}",
"ruby#{node['kosmos-ruby']['version']}-dev",
"build-essential",
"libssl-dev",
"zlib1g-dev"
]
apt_package packages do
action :install
end
apt_package 'ruby-switch' do
action :install
notifies :run, 'execute[set default ruby]', :immediately
end
execute 'set default ruby' do
command "ruby-switch --set #{package_name}"
action :nothing
notifies :reload, 'ohai[reload]', :immediately
end
ohai 'reload' do
action :nothing
end
execute 'update rubygems' do
command 'gem update --system 2.6.8'
not_if "gem --version | grep ^2.6.8$"
end
gem_package "bundler" do
version "1.13.2"
end