Vendor the external cookbooks

Knife-Zero doesn't include Berkshelf support, so vendoring everything in
the repo is convenient again
This commit is contained in:
Greg Karékinian
2019-10-13 19:17:42 +02:00
parent f4bfe31ac1
commit a32f34b408
1245 changed files with 100630 additions and 0 deletions

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":[]}