Update upstream cookbooks
This commit is contained in:
1
cookbooks/tar/.foodcritic
Normal file
1
cookbooks/tar/.foodcritic
Normal file
@@ -0,0 +1 @@
|
||||
~FC016
|
||||
@@ -1,74 +1,110 @@
|
||||
# Tar Cookbook Changelog
|
||||
# tar Cookbook CHANGELOG
|
||||
|
||||
This file is used to list changes made in each version of the tar cookbook.
|
||||
|
||||
## 2.0.0 (2017-02-16)
|
||||
|
||||
- Converted the existing LWRPs to custom resources and bumped the minimum supported Chef release to 12.5
|
||||
- Add all supported platforms to the metadata
|
||||
- Add full testing of the resources in Travis CI
|
||||
|
||||
## 1.1.0 (2016-12-21)
|
||||
|
||||
- added support for .xz compression type
|
||||
- Reformat the readme
|
||||
- Define both Chefspec matchers
|
||||
- Remove Chef 11 compatibility code
|
||||
|
||||
## 1.0.0 (2016-12-21)
|
||||
|
||||
- This cookbook has been adopted by Chef and will be maintained by the Community Cookbook Team going forward.
|
||||
- This cookbook now requires Chef 12.1+ to align with the requirements of all Chef maintained cookbooks
|
||||
- Cookbook boilerplate has been updated
|
||||
|
||||
- chefignore file added
|
||||
- gitignore file
|
||||
- Test Kitchen config added
|
||||
- Berksfile added
|
||||
- Gemfile added
|
||||
- Badges added to the readme
|
||||
- Add maintainers files
|
||||
- Add rakefile for simplified testing
|
||||
- Add github templates
|
||||
- Add license file
|
||||
- Update author in metadata and add supermarket metadata
|
||||
- Add contributing and testing docs
|
||||
- Cookstyle fixes
|
||||
- Add basic chefspec convergence test
|
||||
- Add a basic test cookbook
|
||||
- Add test kitchen testing in Travis
|
||||
|
||||
## v0.7.0 (2015-07-08)
|
||||
|
||||
* Add adoption notice
|
||||
* Use `file_cache_path` instead of `file_backup_path` for downloaded artifact
|
||||
storage
|
||||
* Fix links to Chef documentation in README
|
||||
- Add adoption notice
|
||||
- Use `file_cache_path` instead of `file_backup_path` for downloaded artifact storage
|
||||
- Fix links to Chef documentation in README
|
||||
|
||||
## v0.6.0 (2014-12-03)
|
||||
|
||||
* Allow either string or array for tar flags
|
||||
- Allow either string or array for tar flags
|
||||
|
||||
## v0.5.0 (2014-07-28)
|
||||
|
||||
* Add support for more attributes of `remote_file`
|
||||
* Escape downloaded file names
|
||||
- Add support for more attributes of `remote_file`
|
||||
- Escape downloaded file names
|
||||
|
||||
## v0.4.0 (2014-06-13)
|
||||
|
||||
* Add `archive_name` option for when the file name is different from the
|
||||
package name
|
||||
- Add `archive_name` option for when the file name is different from the package name
|
||||
|
||||
## v0.3.4 (2014-06-05)
|
||||
|
||||
* Define ChefSpec::Runner method for tar_extract
|
||||
- Define ChefSpec::Runner method for tar_extract
|
||||
|
||||
## v0.3.3 (2014-06-03)
|
||||
|
||||
* Add ChefSpec matchers
|
||||
- Add ChefSpec matchers
|
||||
|
||||
## v0.3.2 (2014-05-05)
|
||||
|
||||
* Add checksum to remote file downloads
|
||||
- Add checksum to remote file downloads
|
||||
|
||||
## v0.3.1 (2014-04-04)
|
||||
|
||||
* Correct "notifies" definition in tar_extract's remote_file
|
||||
- Correct "notifies" definition in tar_extract's remote_file
|
||||
|
||||
## v0.3.0 (2014-03-21)
|
||||
|
||||
* Add `:extract_local` action
|
||||
- Add `:extract_local` action
|
||||
|
||||
## v0.2.0 (2013-12-31)
|
||||
|
||||
* Make `tar_extract` only run if needed
|
||||
* Fix missing space in command line prefix
|
||||
* Ensure `file_backup_path` exists on initial chef-client run
|
||||
* Only add headers if needed
|
||||
- Make `tar_extract` only run if needed
|
||||
- Fix missing space in command line prefix
|
||||
- Ensure `file_backup_path` exists on initial chef-client run
|
||||
- Only add headers if needed
|
||||
|
||||
## v0.1.0 (2013-11-26)
|
||||
|
||||
* Allow custom HTTP headers when downloading files
|
||||
* Allow the type of tar compression
|
||||
* Improve resource notifications
|
||||
- Allow custom HTTP headers when downloading files
|
||||
- Allow the type of tar compression
|
||||
- Improve resource notifications
|
||||
|
||||
## v0.0.4 (2013-10-02)
|
||||
|
||||
* Remove conditional download requests in favor of built-in functionality in Chef >= 11.6.0.
|
||||
* Fix readme example
|
||||
* Foodcritic fixes
|
||||
- Remove conditional download requests in favor of built-in functionality in Chef >= 11.6.0.
|
||||
- Fix readme example
|
||||
- Foodcritic fixes
|
||||
|
||||
## v0.0.3 (2013-01-30)
|
||||
|
||||
* Conditional requests for downloads
|
||||
* Allow extract if non-root user
|
||||
* Formatting fixes
|
||||
- Conditional requests for downloads
|
||||
- Allow extract if non-root user
|
||||
- Formatting fixes
|
||||
|
||||
## v0.0.2 (2012-10-13)
|
||||
|
||||
* Add `tar_extract` LWRP
|
||||
- Add `tar_extract` LWRP
|
||||
|
||||
## v0.0.1 (2011-09-15)
|
||||
|
||||
|
||||
2
cookbooks/tar/CONTRIBUTING.md
Normal file
2
cookbooks/tar/CONTRIBUTING.md
Normal file
@@ -0,0 +1,2 @@
|
||||
Please refer to
|
||||
https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD
|
||||
15
cookbooks/tar/MAINTAINERS.md
Normal file
15
cookbooks/tar/MAINTAINERS.md
Normal file
@@ -0,0 +1,15 @@
|
||||
<!-- This is a generated file. Please do not edit directly -->
|
||||
|
||||
# Maintainers
|
||||
|
||||
This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead.
|
||||
|
||||
Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead.
|
||||
|
||||
# Project Maintainer
|
||||
* [Tim Smith](https://github.com/tas50)
|
||||
|
||||
# Maintainers
|
||||
* [Jennifer Davis](https://github.com/sigje)
|
||||
* [Tim Smith](https://github.com/tas50)
|
||||
* [Thom May](https://github.com/thommay)
|
||||
@@ -1,101 +1,95 @@
|
||||
*This cookbook is no longer actively maintained and is up for adoption. If you
|
||||
would like to take over development, go to https://supermarket.chef.io/cookbooks/tar,
|
||||
click the "Adopt me!" button, and you could be the new maintainer of this cookbook!*
|
||||
# tar Cookbook
|
||||
|
||||
DESCRIPTION
|
||||
===========
|
||||
[](https://travis-ci.org/chef-cookbooks/tar) [](https://supermarket.chef.io/cookbooks/tar)
|
||||
|
||||
Installs tar and two resources for managing remote tar files.
|
||||
`tar_package` handles remote source package compilation.
|
||||
`tar_extract` handles retrieving remote tar files and extracting
|
||||
them locally.
|
||||
Installs tar and includes resources for managing remote tar files. `tar_package` handles remote source package compilation. `tar_extract` handles retrieving remote tar files and extracting them locally.
|
||||
|
||||
LICENSE AND AUTHOR
|
||||
==================
|
||||
## Resources
|
||||
|
||||
Author:: Nathan L Smith (<nathan@cramerdev.com>)
|
||||
Author:: George Miranda (<gmiranda@opscode.com>)
|
||||
Author:: Mark Van de Vyver (<mark@@taqtiqa.com>)
|
||||
### tar_package
|
||||
|
||||
Copyright 2011, Cramer Development, Inc.
|
||||
Copyright 2011, Opscode, Inc.
|
||||
Copyright 2013, TAQTIQA LLC.
|
||||
A `tar_package` LWRP provides an easy way to download remote files and compile and install them. This only works for the most basic Autoconf programs that can do `./configure && make && make install`.
|
||||
|
||||
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
|
||||
#### Actions
|
||||
|
||||
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.
|
||||
|
||||
Resources/Providers
|
||||
===================
|
||||
|
||||
A `tar_package` LWRP provides an easy way to download remote files and compile and install them. This only works for the most basic Autoconf programs that can do `./configure && make && make install`.
|
||||
|
||||
A `tar_extract` LWRP provides an easy way to download remote tar files and extract them to a local directory.
|
||||
|
||||
# Actions
|
||||
|
||||
`tar_package`
|
||||
- :install: Installs the package
|
||||
|
||||
`tar_extract`
|
||||
- :extract: Extracts the tar file from a url
|
||||
- :extract_local: Extracts the tar file from a local file path
|
||||
#### Properties
|
||||
|
||||
# Attribute Parameters
|
||||
|
||||
`tar_package`
|
||||
- source: name attribute. The source remote URL.
|
||||
- prefix: Directory to be used as the `--prefix` configure flag.
|
||||
- source\_directory: Directory to which source files are download.
|
||||
- source_directory: Directory to which source files are download.
|
||||
- creates: A file this command creates - if the file exists, the command will not be run.
|
||||
- configure\_flags: Array of additional flags to be passed to `./configure`.
|
||||
- archive\_name: Specify a different name for the downloaded archive. Use it if the directory name inside the tar file is different than the name defined in the URL.
|
||||
Additionally, `tar_package` supports most `remote_file` [attributes](https://docs.chef.io/chef/resources.html#remote-file).
|
||||
- configure_flags: Array of additional flags to be passed to `./configure`.
|
||||
- archive_name: Specify a different name for the downloaded archive. Use it if the directory name inside the tar file is different than the name defined in the URL. Additionally, `tar_package` supports most `remote_file` [attributes](https://docs.chef.io/chef/resources.html#remote-file).
|
||||
|
||||
`tar_extract`
|
||||
- source: name attribute. The source remote URL.
|
||||
- target\_dir: Directory to extract into, e.g. tar xzf -C (target_dir)
|
||||
- download\_dir: Directory to which tarball is downloaded (defaults to chef cache which requires root `group` and `user`).
|
||||
- creates: A file this command creates - if the file exists, the command will not be run.
|
||||
- compress_char: Flag for compression type, such as `z` for `gzip`. `man tar` for options.
|
||||
- tar\_flags: Array of additional flags to be passed to tar xzf command.
|
||||
- group: Group name or group ID to extract the archive under. If set to non-root group, point to a `download_dir` the group has permission to access.
|
||||
- user: User name or user ID to extract the archive under. If set to non-root user, point to a `download_dir` the user has permission to access.
|
||||
Additionally, `tar_extract` supports most `remote_file` [attributes](https://docs.chef.io/chef/resources.html#remote-file).
|
||||
#### Example
|
||||
|
||||
# Example
|
||||
|
||||
tar_package 'http://pgfoundry.org/frs/download.php/1446/pgpool-3.4.1.tar.gz' do
|
||||
prefix '/usr/local'
|
||||
creates '/usr/local/bin/pgpool'
|
||||
end
|
||||
```
|
||||
tar_package 'http://pgfoundry.org/frs/download.php/1446/pgpool-3.4.1.tar.gz' do
|
||||
prefix '/usr/local'
|
||||
creates '/usr/local/bin/pgpool'
|
||||
end
|
||||
```
|
||||
|
||||
This will download, compile, and install the package from the given URL and install it into /usr/local.
|
||||
|
||||
tar_extract 'http://dev.mycoderepo.com/artifacts/mycode-1.2.3.tar.gz' do
|
||||
target_dir '/opt/myapp/mycode'
|
||||
creates '/opt/myapp/mycode/lib'
|
||||
tar_flags [ '-P', '--strip-components 1' ]
|
||||
end
|
||||
### tar_extract
|
||||
|
||||
A `tar_extract` LWRP provides an easy way to download remote tar files and extract them to a local directory.
|
||||
|
||||
#### Actions
|
||||
|
||||
- :extract: Extracts the tar file from a url
|
||||
- :extract_local: Extracts the tar file from a local file path
|
||||
|
||||
#### Properties
|
||||
|
||||
- source: name attribute. The source remote URL.
|
||||
- target_dir: Directory to extract into, e.g. tar xzf -C (target_dir)
|
||||
- download_dir: Directory to which tarball is downloaded (defaults to chef cache which requires root `group` and `user`).
|
||||
- creates: A file this command creates - if the file exists, the command will not be run.
|
||||
- compress_char: Flag for compression type, such as `z` for `gzip`. `man tar` for options.
|
||||
- tar_flags: Array of additional flags to be passed to tar xzf command.
|
||||
- group: Group name or group ID to extract the archive under. If set to non-root group, point to a `download_dir` the group has permission to access.
|
||||
- user: User name or user ID to extract the archive under. If set to non-root user, point to a `download_dir` the user has permission to access. Additionally, `tar_extract` supports most `remote_file` [attributes](https://docs.chef.io/chef/resources.html#remote-file).
|
||||
|
||||
#### Example
|
||||
|
||||
```
|
||||
tar_extract 'http://dev.mycoderepo.com/artifacts/mycode-1.2.3.tar.gz' do
|
||||
target_dir '/opt/myapp/mycode'
|
||||
creates '/opt/myapp/mycode/lib'
|
||||
tar_flags [ '-P', '--strip-components 1' ]
|
||||
end
|
||||
```
|
||||
|
||||
This will download the tarball to cache, extract the contents to /opt/myapp/mycode, use the file '/opt/myapp/mycode/lib' to determine idempotency, and pass both '-P' and '--strip-components 1' flags to the tar xzf command.
|
||||
|
||||
tar_extract '/tmp/mycode-1.2.3.tar.gz' do
|
||||
action :extract_local
|
||||
target_dir '/opt/myapp/mycode'
|
||||
creates '/opt/myapp/mycode/lib'
|
||||
end
|
||||
```
|
||||
tar_extract '/tmp/mycode-1.2.3.tar.gz' do
|
||||
action :extract_local
|
||||
target_dir '/opt/myapp/mycode'
|
||||
creates '/opt/myapp/mycode/lib'
|
||||
end
|
||||
```
|
||||
|
||||
This will extract the contents of /tmp/mycode-1.2.3.tar.gz to /opt/myapp/mycode and use the file '/opt/myapp/mycode/lib' to determine idempotency.
|
||||
|
||||
# ChefSpec Matchers
|
||||
## ChefSpec Matchers
|
||||
|
||||
ChefSpec matchers are defined for tar_package and tar_extract.
|
||||
|
||||
## LICENSE AND AUTHOR
|
||||
|
||||
Author:: Nathan L Smith ([nathan@cramerdev.com](mailto:nathan@cramerdev.com)) Author:: George Miranda ([gmiranda@chef.io](mailto:gmiranda@chef.io)) Author:: Mark Van de Vyver ([mark@@taqtiqa.com](mailto:mark@@taqtiqa.com))
|
||||
|
||||
Copyright 2011, Cramer Development, Inc. Copyright 2011, Opscode, Inc. Copyright 2013, TAQTIQA LLC.
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
if defined?(ChefSpec)
|
||||
ChefSpec.define_matcher :tar_package
|
||||
ChefSpec.define_matcher :tar_extract
|
||||
|
||||
def install_tar_package(source)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,7 +0,0 @@
|
||||
name "tar"
|
||||
maintainer "Cramer Development, Inc."
|
||||
maintainer_email "sysadmin@cramerdev.com"
|
||||
license "Apache 2.0"
|
||||
description "Installs tar and two LWRPs to manage remote tar packages"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "0.7.0"
|
||||
@@ -1,86 +0,0 @@
|
||||
#
|
||||
# Cookbook Name:: tar
|
||||
# Provider:: extract
|
||||
#
|
||||
# Author:: Nathan L Smith (<nathan@cramerdev.com>)
|
||||
# Author:: George Miranda (<gmiranda@opscode.com>)
|
||||
# Author:: Mark Van de Vyver (<mark@@taqtiqa.com>)
|
||||
#
|
||||
# Copyright 2011, Cramer Development, Inc.
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
# Copyright 2013, TAQTIQA LLC.
|
||||
#
|
||||
# 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'
|
||||
|
||||
use_inline_resources if defined?(use_inline_resources)
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
action :extract do
|
||||
version = Chef::Version.new(Chef::VERSION[/^(\d+\.\d+\.\d+)/, 1])
|
||||
r = new_resource
|
||||
basename = ::File.basename(r.name)
|
||||
local_archive = "#{r.download_dir}/#{basename}"
|
||||
|
||||
directory r.download_dir do
|
||||
recursive true
|
||||
end
|
||||
|
||||
remote_file basename do
|
||||
source r.name
|
||||
checksum r.checksum
|
||||
path local_archive
|
||||
backup false
|
||||
action :create
|
||||
group r.group
|
||||
owner r.user
|
||||
mode r.mode
|
||||
notifies :run, "execute[extract #{local_archive}]"
|
||||
if version.major > 11 || (version.major == 11 && version.minor >= 6)
|
||||
unless r.headers.nil?
|
||||
headers r.headers
|
||||
end
|
||||
use_etag r.use_etag
|
||||
use_last_modified r.use_last_modified
|
||||
atomic_update r.atomic_update
|
||||
force_unlink r.force_unlink
|
||||
manage_symlink_source r.manage_symlink_source
|
||||
end
|
||||
end
|
||||
|
||||
extract_tar(local_archive, new_resource)
|
||||
end
|
||||
|
||||
action :extract_local do
|
||||
extract_tar(new_resource.name, new_resource)
|
||||
end
|
||||
|
||||
def extract_tar(local_archive, r)
|
||||
execute "extract #{local_archive}" do
|
||||
if r.tar_flags.kind_of?(String)
|
||||
flags = r.tar_flags
|
||||
else
|
||||
flags = r.tar_flags.join(' ')
|
||||
end
|
||||
command "tar xf#{r.compress_char} #{local_archive.shellescape} #{flags}"
|
||||
cwd r.target_dir
|
||||
creates r.creates
|
||||
group r.group
|
||||
user r.user
|
||||
action (r.creates || r.not_if.any? || r.only_if.any? ? :run : :nothing)
|
||||
end
|
||||
end
|
||||
@@ -1,65 +0,0 @@
|
||||
#
|
||||
# Cookbook Name:: tar
|
||||
# Provider:: package
|
||||
#
|
||||
# Author:: Nathan L Smith (<nathan@cramerdev.com>)
|
||||
#
|
||||
# Copyright 2011, Cramer Development, 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.
|
||||
#
|
||||
|
||||
use_inline_resources if defined?(use_inline_resources)
|
||||
|
||||
def whyrun_supported?
|
||||
true
|
||||
end
|
||||
|
||||
action :install do
|
||||
version = Chef::Version.new(Chef::VERSION[/^(\d+\.\d+\.\d+)/, 1])
|
||||
r = new_resource
|
||||
basename = r.archive_name || ::File.basename(r.name)
|
||||
dirname = basename.chomp('.tar.gz') # Assuming .tar.gz
|
||||
src_dir = r.source_directory
|
||||
|
||||
remote_file basename do
|
||||
source r.name
|
||||
path "#{src_dir}/#{basename}"
|
||||
backup false
|
||||
action :create_if_missing
|
||||
if version.major > 11 || (version.major == 11 && version.minor >= 6)
|
||||
unless r.headers.nil?
|
||||
headers r.headers
|
||||
end
|
||||
use_etag r.use_etag
|
||||
use_last_modified r.use_last_modified
|
||||
atomic_update r.atomic_update
|
||||
force_unlink r.force_unlink
|
||||
manage_symlink_source r.manage_symlink_source
|
||||
end
|
||||
end
|
||||
|
||||
execute "extract #{basename}" do
|
||||
command "tar xfz #{basename}"
|
||||
cwd src_dir
|
||||
creates "#{src_dir}/#{dirname}"
|
||||
end
|
||||
|
||||
execute "compile & install #{dirname}" do
|
||||
flags = [r.prefix ? "--prefix=#{r.prefix}" : nil, *r.configure_flags].compact.join(' ')
|
||||
command "./configure --quiet #{flags} && make --quiet && make --quiet install"
|
||||
cwd "#{src_dir}/#{dirname}"
|
||||
creates r.creates
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Author:: Nathan L Smith (<nathan@cramerdev.com>)
|
||||
#
|
||||
# Copyright 2011, Cramer Development, Inc.
|
||||
# Copyright:: 2011, Cramer Development, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
# Resource:: extract
|
||||
#
|
||||
# Author:: Nathan L Smith (<nathan@cramerdev.com>)
|
||||
# Author:: George Miranda (<gmiranda@opscode.com>)
|
||||
# Author:: George Miranda (<gmiranda@chef.io>)
|
||||
# Author:: Mark Van de Vyver (<mark@taqtiqa.com>)
|
||||
#
|
||||
# Copyright 2011, Cramer Development, Inc.
|
||||
# Copyright 2012, Opscode, Inc.
|
||||
# Copyright 2013, TAQTIQA LLC.
|
||||
# Copyright:: 2011, Cramer Development, Inc.
|
||||
# Copyright:: 2012-2016, Chef Software, Inc.
|
||||
# Copyright:: 2013, TAQTIQA LLC.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -23,27 +23,75 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :extract, :extract_local
|
||||
property :source, String, name_property: true
|
||||
property :checksum, String
|
||||
property :download_dir, String, default: Chef::Config[:file_cache_path]
|
||||
property :group, String, default: 'root'
|
||||
property :mode, String, default: '0755'
|
||||
property :target_dir, String
|
||||
property :creates, String
|
||||
property :compress_char, String, default: 'z'
|
||||
property :tar_flags, [String, Array], default: []
|
||||
property :user, String, default: 'root'
|
||||
property :headers, Hash
|
||||
property :use_etag, [TrueClass, FalseClass], default: true
|
||||
property :use_last_modified, [TrueClass, FalseClass], default: true
|
||||
property :atomic_update, [TrueClass, FalseClass], default: true
|
||||
property :force_unlink, [TrueClass, FalseClass], default: false
|
||||
property :manage_symlink_source, [TrueClass, FalseClass]
|
||||
|
||||
attribute :source, :kind_of => String, :name_attribute => true
|
||||
attribute :checksum, :kind_of => String
|
||||
attribute :download_dir, :kind_of => String, :default => Chef::Config[:file_cache_path]
|
||||
attribute :group, :kind_of => String, :default => 'root'
|
||||
attribute :mode, :kind_of => String, :default => '0755'
|
||||
attribute :target_dir, :kind_of => String
|
||||
attribute :creates, :kind_of => String
|
||||
attribute :compress_char, :kind_of => String, :default => 'z'
|
||||
attribute :tar_flags, :kind_of => [String, Array], :default => Array.new
|
||||
attribute :user, :kind_of => String, :default => 'root'
|
||||
require 'shellwords'
|
||||
|
||||
version = Chef::Version.new(Chef::VERSION[/^(\d+\.\d+\.\d+)/, 1])
|
||||
if version.major > 11 || (version.major == 11 && version.minor >= 6)
|
||||
attribute :headers, :kind_of => Hash, :default => nil
|
||||
attribute :use_etag, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :use_last_modified, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :atomic_update, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :force_unlink, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :manage_symlink_source, :kind_of => [TrueClass, FalseClass], :default => nil
|
||||
action :extract do
|
||||
r = new_resource
|
||||
basename = ::File.basename(r.name)
|
||||
extname = ::File.extname(r.name)
|
||||
r.compress_char = '' if extname.casecmp('.xz') == 0
|
||||
local_archive = "#{r.download_dir}/#{basename}"
|
||||
|
||||
directory r.download_dir do
|
||||
recursive true
|
||||
end
|
||||
|
||||
remote_file basename do
|
||||
source r.name
|
||||
checksum r.checksum
|
||||
path local_archive
|
||||
backup false
|
||||
action :create
|
||||
group r.group
|
||||
owner r.user
|
||||
mode r.mode
|
||||
headers r.headers unless r.headers.nil?
|
||||
use_etag r.use_etag
|
||||
use_last_modified r.use_last_modified
|
||||
atomic_update r.atomic_update
|
||||
force_unlink r.force_unlink
|
||||
manage_symlink_source r.manage_symlink_source
|
||||
notifies :run, "execute[extract #{local_archive}]"
|
||||
end
|
||||
|
||||
extract_tar(local_archive, new_resource)
|
||||
end
|
||||
|
||||
default_action :extract
|
||||
action :extract_local do
|
||||
extract_tar(new_resource.name, new_resource)
|
||||
end
|
||||
|
||||
action_class.class_eval do
|
||||
def extract_tar(local_archive, r)
|
||||
execute "extract #{local_archive}" do
|
||||
flags = if r.tar_flags.is_a?(String)
|
||||
r.tar_flags
|
||||
else
|
||||
r.tar_flags.join(' ')
|
||||
end
|
||||
command "tar xf#{r.compress_char} #{local_archive.shellescape} #{flags}"
|
||||
cwd r.target_dir
|
||||
creates r.creates
|
||||
group r.group
|
||||
user r.user
|
||||
action (r.creates || r.not_if.any? || r.only_if.any? ? :run : :nothing)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Author:: Nathan L Smith (<nathan@cramerdev.com>)
|
||||
#
|
||||
# Copyright 2011, Cramer Development, Inc.
|
||||
# Copyright:: 2011, Cramer Development, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -19,24 +19,49 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
actions :install
|
||||
attribute :source, String, name_attribute: true
|
||||
attribute :headers, Hash, default: {}
|
||||
attribute :prefix, String
|
||||
attribute :source_directory, String, default: '/usr/local/src'
|
||||
attribute :creates, String
|
||||
attribute :configure_flags, Array, default: []
|
||||
attribute :archive_name, String
|
||||
attribute :headers, Hash
|
||||
attribute :use_etag, [TrueClass, FalseClass], default: true
|
||||
attribute :use_last_modified, [TrueClass, FalseClass], default: true
|
||||
attribute :atomic_update, [TrueClass, FalseClass], default: true
|
||||
attribute :force_unlink, [TrueClass, FalseClass], default: false
|
||||
attribute :manage_symlink_source, [TrueClass, FalseClass]
|
||||
|
||||
attribute :source, :kind_of => String, :name_attribute => true
|
||||
attribute :headers, :kind_of => Hash, :default => {}
|
||||
attribute :prefix, :kind_of => String
|
||||
attribute :source_directory, :kind_of => String, :default => '/usr/local/src'
|
||||
attribute :creates, :kind_of => String
|
||||
attribute :configure_flags, :kind_of => Array, :default => []
|
||||
attribute :archive_name, :kind_of => String
|
||||
action :install do
|
||||
r = new_resource
|
||||
basename = r.archive_name || ::File.basename(r.name)
|
||||
dirname = basename.chomp('.tar.gz') # Assuming .tar.gz
|
||||
src_dir = r.source_directory
|
||||
|
||||
version = Chef::Version.new(Chef::VERSION[/^(\d+\.\d+\.\d+)/, 1])
|
||||
if version.major > 11 || (version.major == 11 && version.minor >= 6)
|
||||
attribute :headers, :kind_of => Hash, :default => nil
|
||||
attribute :use_etag, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :use_last_modified, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :atomic_update, :kind_of => [TrueClass, FalseClass], :default => true
|
||||
attribute :force_unlink, :kind_of => [TrueClass, FalseClass], :default => false
|
||||
attribute :manage_symlink_source, :kind_of => [TrueClass, FalseClass], :default => nil
|
||||
remote_file basename do
|
||||
source r.name
|
||||
path "#{src_dir}/#{basename}"
|
||||
backup false
|
||||
headers r.headers unless r.headers.nil?
|
||||
use_etag r.use_etag
|
||||
use_last_modified r.use_last_modified
|
||||
atomic_update r.atomic_update
|
||||
force_unlink r.force_unlink
|
||||
manage_symlink_source r.manage_symlink_source
|
||||
action :create_if_missing
|
||||
end
|
||||
|
||||
execute "extract #{basename}" do
|
||||
command "tar xfz #{basename}"
|
||||
cwd src_dir
|
||||
creates "#{src_dir}/#{dirname}"
|
||||
end
|
||||
|
||||
execute "compile & install #{dirname}" do
|
||||
flags = [r.prefix ? "--prefix=#{r.prefix}" : nil, *r.configure_flags].compact.join(' ')
|
||||
command "./configure --quiet #{flags} && make --quiet && make --quiet install"
|
||||
cwd "#{src_dir}/#{dirname}"
|
||||
creates r.creates
|
||||
end
|
||||
end
|
||||
|
||||
default_action :install
|
||||
|
||||
Reference in New Issue
Block a user