Update cookbooks and add wordpress cookbook

This commit is contained in:
Greg Karékinian
2016-02-19 18:09:49 +01:00
parent 9ba973e3ac
commit 820b0ab3f8
606 changed files with 22421 additions and 14084 deletions

View File

@@ -1,63 +1,80 @@
ark Cookbook CHANGELOG
======================
# ark Cookbook CHANGELOG
This file is used to list changes made in each version of the ark cookbook.
## v1.0.1 (2016-02-16)
- Remove a large number of zero byte archives that snuck into the repository
- Remove a Chef 10 compatibility check in the custom resource
v0.9.0 (2014-06-06)
-------------------
* [COOK-3642] Add Windows support
## v1.0.0 (2016-02-09)
- Added the pkg-config package to the debian platform family
- Added tar, xz-lzma-compat, and bzip2 packages to the RHEL and fedora platform families
- Updated FreeBSD to install gmake instead of make
- Added OS X, SmartOS, and FreeBSD to the tar path attributes to support those platforms
- Removed the has_binaries attribute from put action documentation in the readme file since this isn't supported there
- Moved the libraries module locations to no longer be under Opscode:: and broke out libraries into more logical units
- Fixed issues with spaces in Windows paths that could cause failures
- Fixed a bad attribute for the 7zip home on windows. Instead of using a node attribute use the value directly to avoid computed attribute overiding issues
- Switched from the 7-zip cookbook to seven_zip since the 7-zip cookbook is now deprecated
- Changed unzip commands to not use -u so that a newer archive can overwrite an existing directory
- Added support for actions py_setup, py_setup_install, py_setup_build
- Fixed setting home_dir attribute
- Added source_url and issues_url to the metadata.rb
- Expanded the supported platforms in metadata.rb
- Removed all references to Opscode
- Improved error logging when an unknown extension is encountered
- Added support for .tar files
- Improved overall testing:
- Removed the kitchen.cloud.yml file and gem dependencies
- Added integration testing in Travis with Kitchen-Docker and Travis tests now run using the nightly build of ChefDK
- Expanded platforms tested in the .kitchen.yml file
- Updated the Gemfile with the latest testing dependencies
- Added full Chefspec coverage
- Greatly expanded the ark_spec test cookbook
- Removed the original minitests
- Added standard Chef .gitignore and chefignore files
- Resolved a large number of rubocop warnings
- Removed old Opscode contributing and testing docs
- Added a cookbook version badge to the readme
- Removed the Toftfile
v0.8.2 (2014-04-23)
-------------------
## v0.9.0 (2014-06-06)
- [COOK-3642] Add Windows support
## v0.8.2 (2014-04-23)
- [COOK-4514] - Support for SLES with the Ark cookbook
v0.8.0 (2014-04-10)
-------------------
## v0.8.0 (2014-04-10)
- [COOK-2771] - Add support for XZ compression
v0.7.2 (2014-03-28)
-------------------
## v0.7.2 (2014-03-28)
- [COOK-4477] - Fix failing test suite
- [COOK-4484] - Replace strip_leading_dir attribute with more general strip_components
v0.7.0 (2014-03-18)
-------------------
## v0.7.0 (2014-03-18)
- [COOK-4437] - configure and install_with_make should chown after unpack
v0.6.0 (2014-02-27)
-------------------
## v0.6.0 (2014-02-27)
[COOK-3786] - Unable to install multiple versions of archive without duplication
v0.5.0 (2014-02-21)
-------------------
## v0.5.0 (2014-02-21)
### Bug
- **[COOK-4288](https://tickets.opscode.com/browse/COOK-4288)** - Cleanup the Kitchen
### Improvement
- **[COOK-4264](https://tickets.opscode.com/browse/COOK-4264)** - Add node['ark']['package_dependencies'] to allow tuning packages.
v0.4.2
------
## v0.4.2
### Improvement
- **[COOK-3854](https://tickets.opscode.com/browse/COOK-3854)** - Capability with mac_os_x: '/bin/chown' - No such file or directory
- Cleaning up some style for rubucop
- Updating test harness
v0.4.0
------
## v0.4.0
### Improvement
- **[COOK-3539](https://tickets.opscode.com/browse/COOK-3539)** - Allow dumping of bz2 and gzip files
v0.3.2
------
## v0.3.2
### Bug
- **[COOK-3191](https://tickets.opscode.com/browse/COOK-3191)** - Propogate unzip failures
- **[COOK-3118](https://tickets.opscode.com/browse/COOK-3118)** - Set cookbook attribute in provider
@@ -67,54 +84,41 @@ v0.3.2
### Improvement
- **[COOK-3179](https://tickets.opscode.com/browse/COOK-3179)** - README updates and refactor
v0.3.0
------
## v0.3.0
### Improvement
- [COOK-3087]: Can't use ark with chef < 11
### Bug
- [COOK-3064]: `only_if` statements in ark's `install_with_make` and configure actions are not testing for file existence correctly.
- [COOK-3067]: ark kitchen test for `cherry_pick` is expecting the binary to be in the same parent folder as in the archive.
v0.2.4
------
## v0.2.4
### Bug
- [COOK-3048]: Ark provider contains a `ruby_block` resource without a block attribute
- [COOK-3063]: Ark cookbook `cherry_pick` action's unzip command does not close if statement
- [COOK-3065]: Ark install action does not symlink binaries correctly
v0.2.2
------
## v0.2.2
- Update the README to reflect the requirement for Chef 11 to use the ark resource (`use_inline_resources`).
- Making this a release so it will also appear on the community site page.
v0.2.0
------
## v0.2.0
### Bug
- [COOK-2772]: Ark cookbook has foodcritic failures in provides/default.rb
### Improvement
- [COOK-2520]: Refactor ark providers to use the '`use_inline_resources`' LWRP DSL feature
v0.1.0
------
## v0.1.0
- [COOK-2335] - ark resource broken on Chef 11
v0.0.1
------
## v0.0.1
- [COOK-2026] - Allow `cherry_pick` action to be used for directories as well as files
v0.0.1
------
## v0.0.1
- [COOK-1593] - README formatting updates for better display on Community Site
v0.0.1
------
## v0.0.1
### Bug
- dangling "unless"
@@ -124,12 +128,11 @@ v0.0.1
- add foodcritic test
- travis.ci support
v0.0.10 (May 23, 2012
------
## v0.0.10 (May 23, 2012
### Bug
- `strip_leading_dir` not working for zip files https://github.com/bryanwb/chef-ark/issues/19
- `strip_leading_dir` not working for zip files [https://github.com/bryanwb/chef-ark/issues/19](https://github.com/bryanwb/chef-ark/issues/19)
### Improvement
- use autogen.sh to generate configure script for configure action https://github.com/bryanwb/chef-ark/issues/16
- support more file extensions https://github.com/bryanwb/chef-ark/pull/18
- use autogen.sh to generate configure script for configure action [https://github.com/bryanwb/chef-ark/issues/16](https://github.com/bryanwb/chef-ark/issues/16)
- support more file extensions [https://github.com/bryanwb/chef-ark/pull/18](https://github.com/bryanwb/chef-ark/pull/18)
- add extension attribute which allows you to download files which do not have the file extension as part of the URL

View File

@@ -1,297 +1,245 @@
# <a name="title"></a> chef-ark [![Build Status](https://secure.travis-ci.org/opscode-cookbooks/ark.png?branch=master)](https://travis-ci.org/opscode-cookbooks/ark)
# ark cookbook
[![Build Status](https://travis-ci.org/burtlo/ark.svg?branch=master)](https://travis-ci.org/burtlo/ark) [![Cookbook Version](https://img.shields.io/cookbook/v/ark.svg)](https://supermarket.chef.io/cookbooks/ark)
Overview
========
## Overview
This cookbook provides `ark`, a resource for managing software archives. It manages the fetch-unpack-configure-build-install process common to installing software from source, or from binary distributions that are not fully fledged OS packages.
This cookbook provides `ark`, a resource for managing software
archives. It manages the fetch-unpack-configure-build-install process
common to installing software from source, or from binary
distributions that are not fully fledged OS packages.
This is a modified verion of Infochimp's awesome
[install_from cookbook](http://github.com/infochimps-cookbooks/install_from).
It has been heavily refactored and extended to meet different use
cases.
This cookbook started its life as a modified version of Infochimp's install_from cookbook. It has since been heavily refactored and extended to meet different use cases.
Given a simple project archive available at a url:
ark 'pig' do
url 'http://apache.org/pig/pig-0.8.0.tar.gz'
end
```ruby
ark 'pig' do
url 'http://apache.org/pig/pig-0.8.0.tar.gz'
end
```
The provider will:
- fetch it to to `/var/cache/chef/`
- unpack it to the default path (`/usr/local/pig-0.8.0`)
- create a symlink for `:home_dir` (`/usr/local/pig`) pointing to path
- add specified binary commands to the environment `PATH` variable
* fetch it to to `/var/cache/chef/`
* unpack it to the default path (`/usr/local/pig-0.8.0`)
* create a symlink for `:home_dir` (`/usr/local/pig`) pointing to path
* add specified binary commands to the enviroment `PATH` variable
By default, the ark will not run again if the `:path` is not empty. Ark provides many actions to accommodate different use cases, such as `:dump`, `:cherry_pick`, `:put`, and `:install_with_make`.
By default, the ark will not run again if the `:path` is not empty.
Ark provides many actions to accommodate different use cases, such as
`:dump`, `:cherry_pick`, `:put`, and `:install_with_make`.
At this time ark only handles files available from URLs using the [remote_file](http://docs.chef.io/resource_remote_file.html) provider. It does handle local files using the `file://` protocol.
At this time ark only handles files available from URLs. It does not
handle local files.
## Requirements
### Platforms
- Debian/Ubuntu
- RHEL/CentOS/Scientific/Oracle
- Fedora
- FreeBSD
- SmartOS
- Mac OS X
Requirements
============
Should work on common Unix/Linux systems with typical userland utilities like tar, gzip, etc. May require the installation of build tools for compiling from source, but that installation is outside the scope of this cookbook.
This cookbook requires Chef 11 for the provider, as it uses the
`use_inline_resources` method.
### Chef
- Chef 11+
More about
[use_inline_resources](http://docs.opscode.com/lwrp_common_inline_compile.html)
in the Chef documentation.
### Cookbooks
- build-essential
- seven_zip
- windows
Should work on common Unix/Linux systems with typical userland
utilities like tar, gzip, etc. May require the installation of build
tools for compiling from source, but that installation is outside the
scope of this cookbook.
## Attributes
Customize the attributes to suit site specific conventions and defaults.
- `node['ark']['apache_mirror']` - if the URL is an apache mirror, use the attribute as the default.
- `node['ark']['prefix_root']` - default base location if the `prefix_root` is not passed into the resource.
- `node['ark']['prefix_bin']` - default binary location if the `prefix_bin` is not passed into the resource.
- `node['ark']['prefix_home']` - default home location if the `prefix_home` is not passed into the resource.
- `node['ark']['win_install_dir']` - directory where the files will be put on windows
- `node['ark']['package_dependencies']` - prerequisite system packages that need to be installed to support ark.
Attributes
==========
## Resources
- `ark` - does the extract/build/configure dance
Customize the attributes to suit site specific conventions and
defaults.
* `node['ark']['apache_mirror']` - if the URL is an apache mirror,
use the attribute as the default.
* `node['ark']['prefix_root']` - default base location if the
`prefix_root` is not passed into the resource.
* `node['ark']['prefix_bin']` - default binary location if the
`prefix_bin` is not passed into the resource.
* `node['ark']['prefix_home']` - default home location if the
`prefix_home` is not passed into the resource.
* `node['ark']['win_install_dir']` - directory where the files will
be put on windows
* `node['ark']['package_dependencies']` - prerequisite system
packages that need to be installed to support ark.
Resources/Providers
===================
* `ark` - does the extract/build/configure dance
Actions
-------
- `:install`: extracts the file and creates a 'friendly' symbolic link
to the extracted directory path
### Actions
- `:install`: extracts the file and creates a 'friendly' symbolic link to the extracted directory path
- `:configure`: configure ahead of the install action
- `:install_with_make`: extracts the archive to a path, runs `make`,
and `make install`. It does _not_ run the configure step at this
time
- `:dump`: strips all directories from the archive and dumps the
contained files into a specified path
- `:cherry_pick`: extract a specified file from an archive and places
in specified path
- `:put`: extract the archive to a specified path, does not create any
symbolic links
- `:install_with_make`: extracts the archive to a path, runs `make`, and `make install`. It does _not_ run the configure step at this time
- `:dump`: strips all directories from the archive and dumps the contained files into a specified path
- `:cherry_pick`: extract a specified file from an archive and places in specified path
- `:put`: extract the archive to a specified path, does not create any symbolic links
- `:remove`: removes the extracted directory and related symlink #TODO
- `:setup_py_build`: runs the command "python setup.py build" in the
extracted directory
- `:setup_py_install`: runs the comand "python setup.py install" in
the extracted directory
## :cherry_pick
- `:setup_py`: runs the command "python setup.py" in the extracted directory
- `:setup_py_build`: runs the command "python setup.py build" in the extracted directory
- `:setup_py_install`: runs the command "python setup.py install" in the extracted directory
### :cherry_pick
Extract a specified file from an archive and places in specified path.
### Relevant Attribute Parameters for :cherry_pick
#### Relevant Attribute Parameters for :cherry_pick
- `path`: directory to place file in.
- `creates`: specific file to cherry-pick.
## :dump
Strips all directories from the archive and dumps the contained files
into a specified path.
### :dump
Strips all directories from the archive and dumps the contained files into a specified path.
NOTE: This currently only works for zip archives
### Attribute Parameters for :dump
#### Attribute Parameters for :dump
- `path`: path to dump files to.
- `mode`: file mode for `app_home`, as an integer.
- Example: `0775`
- `creates`: if you are appending files to a given directory, ark
needs a condition to test whether the file has already been
extracted. You can specify with creates, a file whose existence
indicates the ark has previously been extracted and does not need to
be extracted again.
## :put
- `creates`: if you are appending files to a given directory, ark needs a condition to test whether the file has already been extracted. You can specify with creates, a file whose existence indicates the ark has previously been extracted and does not need to be extracted again.
Extract the archive to a specified path, does not create any symbolic
links.
### Attribute Parameters for :put
### :put
Extract the archive to a specified path, does not create any symbolic links.
#### Attribute Parameters for :put
- `path`: path to extract to.
- Default: `/usr/local`
- `has_binaries`: array of binary commands to symlink into
`/usr/local/bin/`, you must specify the relative path.
- Example: `[ 'bin/java', 'bin/javaws' ]`
- `append_env_path`: boolean, if true, append the `./bin` directory of
the extracted directory to the global `PATH` variable for all users.
Attribute Parameters
--------------------
- `append_env_path`: boolean, if true, append the `./bin` directory of the extracted directory to the global `PATH` variable for all users.
### Attribute Parameters
- `name`: name of the package, defaults to the resource name.
- `url`: url for tarball, `.tar.gz`, `.bin` (oracle-specific), `.war`,
and `.zip` currently supported. Also supports special syntax
`:name:version:apache_mirror:` that will auto-magically construct
download url from the apache mirrors site.
- `url`: url for tarball, `.tar.gz`, `.bin` (oracle-specific), `.war`, and `.zip` currently supported. Also supports special syntax
- `:name:version:apache_mirror:` that will auto-magically construct download url from the apache mirrors site.
- `version`: software version, defaults to `1`.
- `checksum`: sha256 checksum, used for security .
- `mode`: file mode for `app_home`, is an integer.
- `prefix_root`: default `prefix_root`, for use with `:install*`
actions.
- `prefix_home`: default directory prefix for a friendly symlink to
the path.
- `prefix_root`: default `prefix_root`, for use with `:install*` actions.
- `prefix_home`: default directory prefix for a friendly symlink to the path.
- Example: `/usr/local/maven` -> `/usr/local/maven-2.2.1`
- `prefix_bin`: default directory to place a symlink to a binary
command.
- Example: `/opt/bin/mvn` -> `/opt/maven-2.2.1/bin/mvn`, where the
`prefix_bin` is `/opt/bin`
- `path`: path to extract the ark to. The `:install*` actions
overwrite any user-provided values for `:path`.
- Default: `/usr/local/<name>-<version>` for the `:install`,
`:install_with_make` actions
- `home_dir`: symbolic link to the path `:prefix_root/:name-:version`,
does not apply to `:dump`, `:put`, or `:cherry_pick` actions.
- `prefix_bin`: default directory to place a symlink to a binary command.
- Example: `/opt/bin/mvn` -> `/opt/maven-2.2.1/bin/mvn`, where the `prefix_bin` is `/opt/bin`
- `path`: path to extract the ark to. The `:install*` actions overwrite any user-provided values for `:path`.
- Default: `/usr/local/<name>-<version>` for the `:install`, `:install_with_make` actions
- `home_dir`: symbolic link to the path `:prefix_root/:name-:version`, does not apply to `:dump`, `:put`, or `:cherry_pick` actions.
- Default: `:prefix_root/:name`
- `has_binaries`: array of binary commands to symlink into
`/usr/local/bin/`, you must specify the relative path.
- `has_binaries`: array of binary commands to symlink into `/usr/local/bin/`, you must specify the relative path.
- Example: `[ 'bin/java', 'bin/javaws' ]`
- `append_env_path`: boolean, similar to `has_binaries` but less
granular. If true, append the `./bin` directory of the extracted
directory to. the `PATH` environment variable for all users, by
placing a file in `/etc/profile.d/`. The commands are symbolically
linked into `/usr/bin/*`. This option provides more granularity than
the boolean option.
- `append_env_path`: boolean, similar to `has_binaries` but less granular. If true, append the `./bin` directory of the extracted directory to. the `PATH` environment variable for all users, by placing a file in `/etc/profile.d/`. The commands are symbolically linked into `/usr/bin/*`. This option provides more granularity than the boolean option.
- Example: `mvn`, `java`, `javac`, etc.
- `environment`: hash of environment variables to pass to invoked
shell commands like `tar`, `unzip`, `configure`, and `make`.
- `strip_components`: number of components in path to strip when extracting archive.
With default value of `1`, ark strips the leading directory from an archive,
which is the default for both `unzip` and `tar` commands.
- `autoconf_opts`: an array of command line options for use with the
GNU `autoconf` script.
- `environment`: hash of environment variables to pass to invoked shell commands like `tar`, `unzip`, `configure`, and `make`.
- `strip_components`: number of components in path to strip when extracting archive. With default value of `1`, ark strips the leading directory from an archive, which is the default for both `unzip` and `tar` commands.
- `autoconf_opts`: an array of command line options for use with the GNU `autoconf` script.
- Example: `[ '--include=/opt/local/include', '--force' ]`
- `make_opts`: an array of command line options for use with `make`.
- Example: `[ '--warn-undefined-variables', '--load-average=2' ]`
- `owner`: owner of extracted directory.
- Default: `root`
### Examples
#### Examples
This example copies `ivy.tar.gz` to `/var/cache/chef/ivy-2.2.0.tar.gz`, unpacks its contents to `/usr/local/ivy-2.2.0/` -- stripping the leading directory, and symlinks `/usr/local/ivy` to `/usr/local/ivy-2.2.0`
This example copies `ivy.tar.gz` to
`/var/cache/chef/ivy-2.2.0.tar.gz`, unpacks its contents to
`/usr/local/ivy-2.2.0/` -- stripping the leading directory, and
symlinks `/usr/local/ivy` to `/usr/local/ivy-2.2.0`
```ruby
# install Apache Ivy dependency resolution tool
ark "ivy" do
url 'http://someurl.example.com/ivy.tar.gz'
version '2.2.0'
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
action :install
end
```
# install Apache Ivy dependency resolution tool
ark "ivy" do
url 'http://someurl.example.com/ivy.tar.gz'
version '2.2.0'
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
action :install
end
This example copies `jdk-7u2-linux-x64.tar.gz` to `/var/cache/chef/jdk-7.2.tar.gz`, unpacks its contents to `/usr/local/jvm/jdk-7.2/` -- stripping the leading directory, symlinks `/usr/local/jvm/default` to `/usr/local/jvm/jdk-7.2`, and adds `/usr/local/jvm/jdk-7.2/bin/` to the global `PATH` for all users. The user 'foobar' is the owner of the `/usr/local/jvm/jdk-7.2` directory:
This example copies `jdk-7u2-linux-x64.tar.gz` to
`/var/cache/chef/jdk-7.2.tar.gz`, unpacks its contents to
`/usr/local/jvm/jdk-7.2/` -- stripping the leading directory, symlinks
`/usr/local/jvm/default` to `/usr/local/jvm/jdk-7.2`, and adds
`/usr/local/jvm/jdk-7.2/bin/` to the global `PATH` for all users. The
user 'foobar' is the owner of the `/usr/local/jvm/jdk-7.2` directory:
```ruby
ark 'jdk' do
url 'http://download.example.com/jdk-7u2-linux-x64.tar.gz'
version '7.2'
path "/usr/local/jvm/"
home_dir "/usr/local/jvm/default"
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
append_env_path true
owner 'foobar'
end
```
ark 'jdk' do
url 'http://download.example.com/jdk-7u2-linux-x64.tar.gz'
version '7.2'
path "/usr/local/jvm/"
home_dir "/usr/local/jvm/default"
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
append_env_path true
owner 'foobar'
end
Install Apache Ivy dependency resolution tool in <path>/resource_name in this case `/usr/local/ivy`, do not symlink, and strip any leading directory if one exists in the tarball:
Install Apache Ivy dependency resolution tool in <path>/resource_name in this case
`/usr/local/ivy`, do not symlink, and strip any leading directory if one
exists in the tarball:
```ruby
ark "ivy" do
url 'http://someurl.example.com/ivy.tar.gz'
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
action :put
end
```
ark "ivy" do
url 'http://someurl.example.com/ivy.tar.gz'
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
action :put
end
Install Apache Ivy dependency resolution tool in /home/foobar/ivy, strip any leading directory if one exists:
Install Apache Ivy dependency resolution tool in /home/foobar/ivy, strip any
leading directory if one exists:
```ruby
ark "ivy" do
path "/home/foobar"
url 'http://someurl.example.com/ivy.tar.gz'
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
action :put
end
```
ark "ivy" do
path "/home/foobar
url 'http://someurl.example.com/ivy.tar.gz'
checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'
action :put
end
Strip all directories and dump files into path specified by the path attribute. You must specify the `creates` attribute in order to keep the extraction from running every time. The directory path will be created if it doesn't already exist:
Strip all directories and dump files into path specified by the path attribute.
You must specify the `creates` attribute in order to keep the extraction from
running every time. The directory path will be created if it doesn't already exist:
ark "my_jars" do
url "http://example.com/bunch_of_jars.zip"
path "/usr/local/tomcat/lib"
creates "mysql.jar"
owner "tomcat"
action :dump
end
```ruby
ark "my_jars" do
url "http://example.com/bunch_of_jars.zip"
path "/usr/local/tomcat/lib"
creates "mysql.jar"
owner "tomcat"
action :dump
end
```
Extract specific files from a tarball (currently only handles one named file):
ark 'mysql-connector-java' do
url 'http://oracle.com/mysql-connector.zip'
creates 'mysql-connector-java-5.0.8-bin.jar'
path '/usr/local/tomcat/lib'
action :cherry_pick
end
```ruby
ark 'mysql-connector-java' do
url 'http://oracle.com/mysql-connector.zip'
creates 'mysql-connector-java-5.0.8-bin.jar'
path '/usr/local/tomcat/lib'
action :cherry_pick
end
```
Build and install haproxy and use alternave values for `prefix_root`, `prefix_home`, and `prefix_bin`:
Build and install haproxy and use alternative values for `prefix_root`, `prefix_home`, and `prefix_bin`:
ark "haproxy" do
url "http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz"
version "1.5"
checksum 'ba0424bf7d23b3a607ee24bbb855bb0ea347d7ffde0bec0cb12a89623cbaf911'
make_opts [ 'TARGET=linux26' ]
prefix_root '/opt'
prefix_home '/opt'
prefix_bin '/opt/bin'
action :install_with_make
end
```ruby
ark "haproxy" do
url "http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz"
version "1.5"
checksum 'ba0424bf7d23b3a607ee24bbb855bb0ea347d7ffde0bec0cb12a89623cbaf911'
make_opts [ 'TARGET=linux26' ]
prefix_root '/opt'
prefix_home '/opt'
prefix_bin '/opt/bin'
action :install_with_make
end
```
You can also pass multiple actions to ark and supply the file extension in case
the file extension can not be determined by the URL:
You can also pass multiple actions to ark and supply the file extension in case the file extension can not be determined by the URL:
ark "test_autogen" do
url 'https://github.com/zeromq/libzmq/tarball/master'
extension "tar.gz"
action [ :configure, :install_with_make ]
end
```ruby
ark "test_autogen" do
url 'https://github.com/zeromq/libzmq/tarball/master'
extension "tar.gz"
action [ :configure, :install_with_make ]
end
```
License and Author
==================
- Author: Philip (flip) Kromer - Infochimps, Inc(<coders@infochimps.com>)
- Author: Bryan W. Berry (<bryan.berry@gmail.com>)
- Author: Denis Barishev (<denis.barishev@gmail.com>)
- Author: Sean OMeara (<someara@opscode.com>)
## License and Authors
- Author: Philip (flip) Kromer - Infochimps, Inc([coders@infochimps.com](mailto:coders@infochimps.com))
- Author: Bryan W. Berry ([bryan.berry@gmail.com](mailto:bryan.berry@gmail.com))
- Author: Denis Barishev ([denis.barishev@gmail.com](mailto:denis.barishev@gmail.com))
- Author: Sean OMeara ([someara@chef.io](mailto:someara@chef.io))
- Author: John Bellone ([jbellone@bloomberg.net](mailto:jbellone@bloomberg.net))
- Copyright: 2011, Philip (flip) Kromer - Infochimps, Inc
- Copyright: 2012, Bryan W. Berry
- Copyright: 2012, Denis Barishev
- Copyright: 2013, Opscode, Inc
- Copyright: 2013, Chef Software, Inc
- Copyright: 2014, Bloomberg L.P.
```
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
@@ -303,3 +251,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

View File

@@ -1,16 +1,43 @@
#
# Cookbook Name:: ark
# Attributes:: default
#
#
# 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['ark']['apache_mirror'] = 'http://apache.mirrors.tds.net'
default['ark']['prefix_root'] = '/usr/local'
default['ark']['prefix_bin'] = '/usr/local/bin'
default['ark']['prefix_home'] = '/usr/local'
if node['platform_family'] === 'windows'
default['ark']['tar'] = "\"#{default['7-zip']['home']}\\7z.exe\""
else
default['ark']['tar'] = '/bin/tar'
end
default['ark']['tar'] = case node['platform_family']
when 'windows'
"\"#{ENV['SYSTEMDRIVE']}\\7-zip\\7z.exe\""
when 'mac_os_x', 'freebsd'
'/usr/bin/tar'
when 'smartos'
'/bin/gtar'
else
'/bin/tar'
end
pkgs = %w(libtool autoconf) unless platform_family?('mac_os_x','windows')
pkgs += %w(unzip rsync make gcc) unless platform_family?('mac_os_x','windows')
pkgs += %w(autogen) unless platform_family?('rhel', 'fedora', 'mac_os_x', 'suse','windows')
pkgs += %w(gtar) if platform?('freebsd')
pkgs = %w(libtool autoconf) unless platform_family?('mac_os_x', 'windows')
pkgs += %w(make) unless platform_family?('mac_os_x', 'windows', 'freebsd')
pkgs += %w(unzip rsync gcc) unless platform_family?('mac_os_x', 'windows')
pkgs += %w(autogen) unless platform_family?('rhel', 'fedora', 'mac_os_x', 'suse', 'windows')
pkgs += %w(gtar) if platform?('freebsd') || platform?('smartos')
pkgs += %w(gmake) if platform?('freebsd')
pkgs += %w(xz-lzma-compat bzip2 tar) if platform_family?('rhel', 'fedora')
pkgs += %w(shtool pkg-config) if platform_family?('debian')
default['ark']['package_dependencies'] = pkgs

View File

@@ -1,102 +0,0 @@
require 'minitest/spec'
describe_recipe 'ark::test' do
# It's often convenient to load these includes in a separate
# helper along with
# your own helper methods, but here we just include them directly:
include MiniTest::Chef::Assertions
include MiniTest::Chef::Context
include MiniTest::Chef::Resources
it 'installed the unzip package' do
package('unzip').must_be_installed
end
if RUBY_PLATFORM =~ /freebsd/
it 'installs the gnu tar package on freebsc' do
package('gtar').must_be_installed
end
end
it 'puts an ark in the desired directory w/out symlinks' do
directory('/usr/local/test_put').must_exist
end
it 'dumps the correct files into place with correct owner and group' do
file('/usr/local/foo_dump/foo1.txt').must_have(:owner, 'foobarbaz').and(:group, 'foobarbaz')
end
it 'cherrypicks the mysql connector and set the correct owner and group' do
file('/usr/local/foo_cherry_pick/foo1.txt').must_have(:owner, 'foobarbaz').and(:group, 'foobarbaz')
end
it 'cherrypicks the file from a zip' do
file('/usr/local/foo_cherry_pick_from_zip/foo1.txt').must_exist
end
it 'creates directory and symlink properly for the full ark install' do
directory('/usr/local/foo-2').must_have(:owner, 'foobarbaz').and(:group, 'foobarbaz')
link('/usr/local/foo').must_exist.with(:link_type, :symbolic).and(:to, '/usr/local/foo-2')
end
it 'symlinks multiple binary commands' do
link('/usr/local/bin/do_foo').must_exist.with(:link_type, :symbolic).and(:to, '/usr/local/foo-2/bin/do_foo')
link('/usr/local/bin/do_more_foo').must_exist.with(:link_type, :symbolic).and(:to, '/usr/local/foo-2/bin/do_more_foo')
end
it 'appends to the environment PATH' do
unless RUBY_PLATFORM =~ /freebsd/
file('/etc/profile.d/foo_append_env.sh').must_include '/usr/local/foo_append_env-7.0.26/bin'
bin_path_present = !ENV['PATH'].scan('/usr/local/foo_append_env-7.0.26/bin').empty?
assert bin_path_present
end
end
it 'doesnt strip top-level directory if specified' do
directory('/usr/local/foo_dont_strip/foo_sub').must_exist
end
it 'does strip for zip file' do
file('/usr/local/foo_zip_strip/foo1.txt').must_exist
end
it 'successfully compiles haproxy' do
file('/usr/local/haproxy-1.5/haproxy').must_exist
end
unless RUBY_PLATFORM =~ /freebsd/
it 'installs haproxy binary' do
file('/usr/local/sbin/haproxy').must_exist
directory('/usr/local/doc/haproxy').must_exist
end
end
it 'creates an alternate prefix_bin' do
link('/opt/bin/do_foo').must_exist.with(:link_type, :symbolic).and(:to, '/opt/foo_alt_bin-3/bin/do_foo')
end
it 'properly unpacks .tbz and .tgz archives' do
file('/usr/local/foo_tbz/foo1.txt').must_exist
file('/usr/local/foo_tgz/foo1.txt').must_exist
end
it 'sends notification when resource updated' do
file('/tmp/foobarbaz/notification_successful.txt').must_exist
end
it 'uses autogen.sh to generate configure script' do
file('/usr/local/test_autogen-1/configure').must_exist
end
it 'strips 2 components out of foo_sub.tar.gz archive path' do
directory('/usr/local/foo_sub-1/bin').must_exist
file('/usr/local/foo_sub-1/foo1.txt').must_exist
end
it 'strips 2 components out of foo_sub.zip archive path' do
directory('/usr/local/foo_sub-2/bin').must_exist
file('/usr/local/foo_sub-2/foo1.txt').must_exist
end
end

View File

@@ -1,234 +1,113 @@
# libs
require_relative 'platform_specific_builders'
require_relative 'resource_deprecations'
require_relative 'resource_defaults'
require_relative 'sevenzip_command_builder'
require_relative 'unzip_command_builder'
require_relative 'tar_command_builder'
require_relative 'general_owner'
require_relative 'windows_owner'
module Opscode
module Ark
module ProviderHelpers
private
module Ark
module ProviderHelpers
extend ::Ark::PlatformSpecificBuilders
def unpack_type
case parse_file_extension
when /tar.gz|tgz/ then "tar_xzf"
when /tar.bz2|tbz/ then "tar_xjf"
when /tar.xz|txz/ then "tar_xJf"
when /zip|war|jar/ then "unzip"
else fail "Don't know how to expand #{new_resource.url}"
end
end
generates_archive_commands_for :seven_zip,
when_the: -> { node['platform_family'] == 'windows' },
with_klass: ::Ark::SevenZipCommandBuilder
def parse_file_extension
if new_resource.extension.nil?
# purge any trailing redirect
url = new_resource.url.clone
url =~ %r{^https?:\/\/.*(.bin|bz2|gz|jar|tbz|tgz|txz|war|xz|zip)(\/.*\/)}
url.gsub!(Regexp.last_match(2), '') unless Regexp.last_match(2).nil?
# remove tailing query string
release_basename = ::File.basename(url.gsub(/\?.*\z/, '')).gsub(/-bin\b/, '')
# (\?.*)? accounts for a trailing querystring
Chef::Log.debug("DEBUG: release_basename is #{release_basename}")
release_basename =~ /^(.+?)\.(jar|tar\.bz2|tar\.gz|tar\.xz|tbz|tgz|txz|war|zip)(\?.*)?/
Chef::Log.debug("DEBUG: file_extension is #{Regexp.last_match(2)}")
new_resource.extension = Regexp.last_match(2)
end
new_resource.extension
end
generates_archive_commands_for :unzip,
when_the: -> { new_resource.extension =~ /zip|war|jar/ },
with_klass: ::Ark::UnzipCommandBuilder
def unpack_command
if node['platform_family'] === 'windows'
cmd = sevenzip_command
else
case unpack_type
when "tar_xzf"
cmd = tar_command("xzf")
when "tar_xjf"
cmd = tar_command("xjf")
when "tar_xJf"
cmd = tar_command("xJf")
when "unzip"
cmd = unzip_command
end
end
Chef::Log.debug("DEBUG: cmd: #{cmd}")
cmd
end
generates_archive_commands_for :tar,
when_the: -> { true },
with_klass: ::Ark::TarCommandBuilder
def tar_command(tar_args)
cmd = node['ark']['tar']
cmd += " #{tar_args} "
cmd += new_resource.release_file
cmd += tar_strip_args
cmd
end
generates_owner_commands_for :windows,
when_the: -> { node['platform_family'] == 'windows' },
with_klass: ::Ark::WindowsOwner
def unzip_command
if new_resource.strip_components > 0
require 'tmpdir'
tmpdir = Dir.mktmpdir
strip_dir = '*/' * new_resource.strip_components
cmd = "unzip -q -u -o #{new_resource.release_file} -d #{tmpdir}"
cmd += " && rsync -a #{tmpdir}/#{strip_dir} #{new_resource.path}"
cmd += " && rm -rf #{tmpdir}"
cmd
else
"unzip -q -u -o #{new_resource.release_file} -d #{new_resource.path}"
end
end
generates_owner_commands_for :all_other_platforms,
when_the: -> { true },
with_klass: ::Ark::GeneralOwner
def sevenzip_command
if new_resource.strip_components > 0
require 'tmpdir'
tmpdir = Dir.mktmpdir
cmd = sevenzip_command_builder(tmpdir,'e')
cmd += " && "
currdir = tmpdir
var = 0
while var < new_resource.strip_components do
var += 1
cmd += "for /f %#{var} in ('dir /ad /b \"#{currdir.gsub! '/', '\\'}\"') do "
currdir += "\\%#{var}"
end
cmd += "xcopy \"#{currdir}\" \"#{new_resource.home_dir}\" /s /e"
else
cmd = sevenzip_command_builder(new_resource.path,'x')
end
cmd
end
def deprecations
::Ark::ResourceDeprecations.on(new_resource)
end
def sevenzip_command_builder(dir, command)
cmd = "#{node['ark']['tar']} #{command} \"";
cmd += new_resource.release_file
cmd += "\" "
case parse_file_extension
when /tar.gz|tgz|tar.bz2|tbz|tar.xz|txz/
cmd += " -so | #{node['ark']['tar']} x -aoa -si -ttar"
end
cmd += " -o\"#{dir}\" -uy"
cmd
end
def show_deprecations
deprecations.each { |message| Chef::Log.warn("DEPRECATED: #{message}") }
end
def dump_command
if node['platform_family'] === 'windows'
cmd = sevenzip_command_builder(new_resource.path,'e')
else
case unpack_type
when "tar_xzf", "tar_xjf", "tar_xJf"
cmd = "tar -mxf \"#{new_resource.release_file}\" -C \"#{new_resource.path}\""
when "unzip"
cmd = "unzip -j -q -u -o \"#{new_resource.release_file}\" -d \"#{new_resource.path}\""
end
end
Chef::Log.debug("DEBUG: cmd: #{cmd}")
cmd
end
def defaults
@resource_defaults ||= ::Ark::ResourceDefaults.new(new_resource)
end
def cherry_pick_command
if node['platform_family'] === 'windows'
cmd = sevenzip_command_builder(new_resource.path,'e')
cmd += " -r #{new_resource.creates}"
else
case unpack_type
when "tar_xzf"
cmd = cherry_pick_tar_command("xzf")
when "tar_xjf"
cmd = cherry_pick_tar_command("xjf")
when "tar_xJf"
cmd = cherry_pick_tar_command("xJf")
when "unzip"
cmd = "unzip -t #{new_resource.release_file} \"*/#{new_resource.creates}\" ; stat=$? ;"
cmd += "if [ $stat -eq 11 ] ; then "
cmd += "unzip -j -o #{new_resource.release_file} \"#{new_resource.creates}\" -d #{new_resource.path} ;"
cmd += "elif [ $stat -ne 0 ] ; then false ;"
cmd += "else "
cmd += "unzip -j -o #{new_resource.release_file} \"*/#{new_resource.creates}\" -d #{new_resource.path} ;"
cmd += "fi"
end
end
Chef::Log.debug("DEBUG: cmd: #{cmd}")
cmd
end
# rubocop:disable Metrics/AbcSize
def set_paths
new_resource.extension = defaults.extension
new_resource.prefix_bin = defaults.prefix_bin
new_resource.prefix_root = defaults.prefix_root
new_resource.home_dir = defaults.home_dir
new_resource.version = defaults.version
def cherry_pick_tar_command(tar_args)
cmd = node['ark']['tar']
cmd += " #{tar_args}"
cmd += " #{new_resource.release_file}"
cmd += " -C"
cmd += " #{new_resource.path}"
cmd += " #{new_resource.creates}"
cmd += tar_strip_args
cmd
end
# TODO: what happens when the path is already set --
# with the current logic we overwrite it
# if you are in windows we overwrite it
# otherwise we overwrite it with the root/name-version
new_resource.path = defaults.path
new_resource.release_file = defaults.release_file
end
# rubocop:enable Metrics/AbcSize
def set_paths
release_ext = parse_file_extension
prefix_bin = new_resource.prefix_bin.nil? ? new_resource.run_context.node['ark']['prefix_bin'] : new_resource.prefix_bin
prefix_root = new_resource.prefix_root.nil? ? new_resource.run_context.node['ark']['prefix_root'] : new_resource.prefix_root
if new_resource.prefix_home.nil?
default_home_dir = ::File.join(new_resource.run_context.node['ark']['prefix_home'], new_resource.name)
else
default_home_dir = ::File.join(new_resource.prefix_home, new_resource.name)
end
# set effective paths
new_resource.prefix_bin = prefix_bin
new_resource.version ||= "1" # initialize to one if nil
new_resource.home_dir ||= default_home_dir
if node['platform_family'] === 'windows'
new_resource.path = new_resource.win_install_dir
else
new_resource.path = ::File.join(prefix_root, "#{new_resource.name}-#{new_resource.version}")
end
Chef::Log.debug("path is #{new_resource.path}")
new_resource.release_file = ::File.join(Chef::Config[:file_cache_path], "#{new_resource.name}-#{new_resource.version}.#{release_ext}")
end
def set_put_paths
new_resource.extension = defaults.extension
def set_put_paths
release_ext = parse_file_extension
path = new_resource.path.nil? ? new_resource.run_context.node['ark']['prefix_root'] : new_resource.path
new_resource.path = ::File.join(path, new_resource.name)
Chef::Log.debug("DEBUG: path is #{new_resource.path}")
new_resource.release_file = ::File.join(Chef::Config[:file_cache_path], "#{new_resource.name}.#{release_ext}")
end
# TODO: Should we be setting the prefix_root -
# as the prefix_root could be used in the path_with_version
# new_resource.prefix_root = default.prefix_root
new_resource.path = defaults.path_without_version
new_resource.release_file = defaults.release_file_without_version
end
def set_dump_paths
release_ext = parse_file_extension
new_resource.release_file = ::File.join(Chef::Config[:file_cache_path], "#{new_resource.name}.#{release_ext}")
end
def set_dump_paths
new_resource.extension = defaults.extension
new_resource.release_file = defaults.release_file_without_version
end
def tar_strip_args
new_resource.strip_components > 0 ? " --strip-components=#{new_resource.strip_components}" : ""
end
def unpack_command
archive_application.unpack
end
def show_deprecations
if [true, false].include?(new_resource.strip_leading_dir)
Chef::Log.warn("DEPRECATED: strip_leading_dir attribute was deprecated. Use strip_components instead.")
end
end
def dump_command
archive_application.dump
end
def owner_command
if node['platform_family'] === 'windows'
cmd = "icacls #{new_resource.path}\\* /setowner #{new_resource.owner}"
else
cmd = "chown -R #{new_resource.owner}:#{new_resource.group} #{new_resource.path}"
end
cmd
end
def cherry_pick_command
archive_application.cherry_pick
end
# def unpacked?(path)
# if new_resource.creates
# full_path = ::File.join(new_resource.path, new_resource.creates)
# else
# full_path = path
# end
# if ::File.directory? full_path
# if ::File.stat(full_path).nlink == 2
# false
# else
# true
# end
# elsif ::File.exists? full_path
# true
# else
# false
# end
# end
def unzip_command
archive_application.unpack
end
def owner_command
owner_builder_klass.new(new_resource).command
end
private
def archive_application
@archive_application ||= archive_builder_klass.new(new_resource)
end
def archive_builder_klass
new_resource.extension ||= defaults.extension
Ark::ProviderHelpers.archive_command_generators.find { |condition, _klass| instance_exec(&condition) }.last
end
def owner_builder_klass
Ark::ProviderHelpers.owner_command_generators.find { |condition, _klass| instance_exec(&condition) }.last
end
end
end

View File

@@ -0,0 +1,13 @@
module Ark
class GeneralOwner
def initialize(resource)
@resource = resource
end
attr_reader :resource
def command
"chown -R #{resource.owner}:#{resource.group} #{resource.path}"
end
end
end

View File

@@ -0,0 +1,42 @@
if defined?(ChefSpec)
def install_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :install, resource_name)
end
def dump_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :dump, resource_name)
end
def cherry_pick_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :cherry_pick, resource_name)
end
def put_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :put, resource_name)
end
def install_with_make_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :install_with_make, resource_name)
end
def configure_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :configure, resource_name)
end
def setup_py_build_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :setup_py_build, resource_name)
end
def setup_py_install_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :setup_py_install, resource_name)
end
def setup_py_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :setup_py, resource_name)
end
def unzip_ark(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :unzip, resource_name)
end
end

View File

@@ -0,0 +1,23 @@
module Ark
module PlatformSpecificBuilders
def generates_archive_commands_for(_name, options)
condition = options[:when_the]
builder = options[:with_klass]
archive_command_generators.push [condition, builder]
end
def archive_command_generators
@archive_command_generators ||= []
end
def generates_owner_commands_for(_name, options)
condition = options[:when_the]
builder = options[:with_klass]
owner_command_generators.push [condition, builder]
end
def owner_command_generators
@owner_command_generators ||= []
end
end
end

View File

@@ -0,0 +1,100 @@
module Ark
class ResourceDefaults
def extension
resource.extension || generate_extension_from_url(resource.url.clone)
end
def prefix_bin
resource.prefix_bin || prefix_bin_from_node_in_run_context
end
def prefix_root
resource.prefix_root || prefix_root_from_node_in_run_context
end
def home_dir
if resource.home_dir.nil? || resource.home_dir.empty?
prefix_home = resource.prefix_home || prefix_home_from_node_in_run_context
::File.join(prefix_home, resource.name)
else
resource.home_dir
end
end
def version
resource.version || default_version
end
def path
if windows?
resource.win_install_dir
else
::File.join(resource.prefix_root, "#{resource.name}-#{resource.version}")
end
end
def windows?
node_in_run_context['platform_family'] == 'windows'
end
def path_without_version
partial_path = resource.path || prefix_root_from_node_in_run_context
::File.join(partial_path, resource.name)
end
def release_file
release_filename = "#{resource.name}-#{resource.version}.#{resource.extension}"
::File.join(file_cache_path, release_filename)
end
def release_file_without_version
release_filename = "#{resource.name}.#{resource.extension}"
::File.join(file_cache_path, release_filename)
end
def initialize(resource)
@resource = resource
end
private
attr_reader :resource
def generate_extension_from_url(url)
# purge any trailing redirect
url =~ %r{^https?:\/\/.*(.bin|bz2|gz|jar|tbz|tgz|txz|war|xz|zip)(\/.*\/)}
url.gsub!(Regexp.last_match(2), '') unless Regexp.last_match(2).nil?
# remove tailing query string
release_basename = ::File.basename(url.gsub(/\?.*\z/, '')).gsub(/-bin\b/, '')
# (\?.*)? accounts for a trailing querystring
Chef::Log.debug("DEBUG: release_basename is #{release_basename}")
release_basename =~ /^(.+?)\.(jar|tar\.bz2|tar\.gz|tar\.xz|tbz|tgz|txz|war|zip|tar)(\?.*)?/
Chef::Log.debug("DEBUG: file_extension is #{Regexp.last_match(2)}")
Regexp.last_match(2)
end
def prefix_bin_from_node_in_run_context
node_in_run_context['ark']['prefix_bin']
end
def prefix_root_from_node_in_run_context
node_in_run_context['ark']['prefix_root']
end
def prefix_home_from_node_in_run_context
node_in_run_context['ark']['prefix_home']
end
def default_version
"1"
end
def file_cache_path
Chef::Config[:file_cache_path]
end
def node_in_run_context
resource.run_context.node
end
end
end

View File

@@ -0,0 +1,33 @@
module Ark
class ResourceDeprecations
def self.on(resource)
new(resource).warnings
end
def initialize(resource)
@resource = resource
end
attr_reader :resource
def warnings
applicable_deprecrations.map { |_, message| message }
end
def applicable_deprecrations
deprecations.select { |condition, _| send(condition) }
end
def deprecations
{ strip_leading_dir_feature: strip_leading_dir_feature_message }
end
def strip_leading_dir_feature
[true, false].include?(resource.strip_leading_dir)
end
def strip_leading_dir_feature_message
"strip_leading_dir attribute was deprecated. Use strip_components instead."
end
end
end

View File

@@ -0,0 +1,66 @@
module Ark
class SevenZipCommandBuilder
def unpack
sevenzip_command
end
def dump
sevenzip_command_builder(resource.path, 'e')
end
def cherry_pick
"#{sevenzip_command_builder(resource.path, 'e')} -r #{resource.creates}"
end
def initialize(resource)
@resource = resource
end
private
attr_reader :resource
# rubocop:disable Metrics/AbcSize
def sevenzip_command
if resource.strip_components <= 0
sevenzip_command_builder(resource.path, 'x')
return
end
tmpdir = make_temp_directory
cmd = sevenzip_command_builder(tmpdir, 'e')
cmd += " && "
currdir = tmpdir.tr('/', '\\')
1.upto(resource.strip_components).each do |count|
cmd += "for /f %#{count} in ('dir /ad /b \"#{currdir}\"') do "
currdir += "\\%#{count}"
end
cmd += "xcopy \"#{currdir}\" \"#{resource.home_dir}\" /s /e"
end
# rubocop:enable Metrics/AbcSize
def sevenzip_binary
resource.run_context.node['ark']['tar']
end
def sevenzip_command_builder(dir, command)
"#{sevenzip_binary} #{command} \"#{resource.release_file}\"#{extension_is_tar} -o\"#{dir}\" -uy"
end
def extension_is_tar
if resource.extension =~ /tar.gz|tgz|tar.bz2|tbz|tar.xz|txz/
" -so | #{sevenzip_binary} x -aoa -si -ttar"
else
""
end
end
def make_temp_directory
require 'tmpdir'
Dir.mktmpdir
end
end
end

View File

@@ -0,0 +1,49 @@
module Ark
class TarCommandBuilder
def unpack
"#{tar_binary} #{args} #{resource.release_file}#{strip_args}"
end
def dump
"tar -mxf \"#{resource.release_file}\" -C \"#{resource.path}\""
end
def cherry_pick
"#{tar_binary} #{args} #{resource.release_file} -C #{resource.path} #{resource.creates}#{strip_args}"
end
def initialize(resource)
@resource = resource
end
private
attr_reader :resource
def node
resource.run_context.node
end
def tar_binary
resource.run_context.node['ark']['tar']
end
def args
case resource.extension
when /^(tar)$/ then "xf"
when /^(tar.gz|tgz)$/ then "xzf"
when /^(tar.bz2|tbz)$/ then "xjf"
when /^(tar.xz|txz)$/ then "xJf"
else raise unsupported_extension
end
end
def strip_args
resource.strip_components > 0 ? " --strip-components=#{resource.strip_components}" : ""
end
def unsupported_extension
"Don't know how to expand #{resource.url} (extension: #{resource.extension})"
end
end
end

View File

@@ -0,0 +1,50 @@
module Ark
class UnzipCommandBuilder
def unpack
if resource.strip_components > 0
unzip_with_strip_components
else
"unzip -q -o #{resource.release_file} -d #{resource.path}"
end
end
def dump
"unzip -j -q -o \"#{resource.release_file}\" -d \"#{resource.path}\""
end
# rubocop:disable Metrics/AbcSize
def cherry_pick
cmd = "unzip -t #{resource.release_file} \"*/#{resource.creates}\" ; stat=$? ;"
cmd += "if [ $stat -eq 11 ] ; then "
cmd += "unzip -j -o #{resource.release_file} \"#{resource.creates}\" -d #{resource.path} ;"
cmd += "elif [ $stat -ne 0 ] ; then false ;"
cmd += "else "
cmd += "unzip -j -o #{resource.release_file} \"*/#{resource.creates}\" -d #{resource.path} ;"
cmd += "fi"
cmd
end
# rubocop:enable Metrics/AbcSize
def initialize(resource)
@resource = resource
end
private
attr_reader :resource
def unzip_with_strip_components
tmpdir = make_temp_directory
strip_dir = '*/' * resource.strip_components
cmd = "unzip -q -o #{resource.release_file} -d #{tmpdir}"
cmd += " && rsync -a #{tmpdir}/#{strip_dir} #{resource.path}"
cmd += " && rm -rf #{tmpdir}"
cmd
end
def make_temp_directory
require 'tmpdir'
Dir.mktmpdir
end
end
end

View File

@@ -0,0 +1,13 @@
module Ark
class WindowsOwner
def initialize(resource)
@resource = resource
end
attr_reader :resource
def command
"icacls \"#{resource.path}\\*\" /setowner \"#{resource.owner}\""
end
end
end

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +0,0 @@
name 'ark'
maintainer 'Bryan W. Berry'
maintainer_email 'bryan.berry@gmail.com'
license 'Apache 2.0'
description 'Installs/Configures ark'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.9.0'
%w( debian ubuntu centos redhat fedora windows ).each do |os|
supports os
end
recipe 'ark::default', 'Installs and configures ark'
depends 'windows'
depends '7-zip'

View File

@@ -3,9 +3,11 @@
# Provider:: Ark
#
# Author:: Bryan W. Berry <bryan.berry@gmail.com>
# Author:: Sean OMeara <someara@opscode.com
# Author:: Sean OMeara <someara@chef.io
# Author:: John Bellone <jbellone@bloomberg.net>
# Copyright 2012, Bryan W. Berry
# Copyright 2013, Opscode, Inc.
# Copyright 2013, Chef Software, Inc.
# Copyright 2014, Bloomberg L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,14 +22,8 @@
# limitations under the License.
#
use_inline_resources if defined?(use_inline_resources)
include ::Opscode::Ark::ProviderHelpers
# From resources/default.rb
# :install, :put, :dump, :cherry_pick, :install_with_make, :configure, :setup_py_build, :setup_py_install, :setup_py
#
# Used in test.rb
# :install, :put, :dump, :cherry_pick, :install_with_make, :configure
use_inline_resources
include ::Ark::ProviderHelpers
#################
# action :install
@@ -51,9 +47,8 @@ action :install do
end
# unpack based on file extension
_unpack_command = unpack_command
execute "unpack #{new_resource.release_file}" do
command _unpack_command
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
@@ -61,14 +56,13 @@ action :install do
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end
# usually on windows there is no central directory with executables where the applciations are linked
if not node['platform_family'] === 'windows'
unless node['platform_family'] == 'windows'
# symlink binaries
new_resource.has_binaries.each do |bin|
link ::File.join(new_resource.prefix_bin, ::File.basename(bin)) do
@@ -89,7 +83,7 @@ action :install do
group 'root'
mode '0755'
cookbook 'ark'
variables(:directory => "#{new_resource.path}/bin")
variables(directory: "#{new_resource.path}/bin")
only_if { new_resource.append_env_path }
end
end
@@ -100,7 +94,9 @@ action :install do
block do
ENV['PATH'] = bin_path + ':' + ENV['PATH']
end
only_if { new_resource.append_env_path && ENV['PATH'].scan(bin_path).empty? }
only_if do
new_resource.append_env_path && ENV['PATH'].scan(bin_path).empty?
end
end
end
@@ -126,9 +122,8 @@ action :put do
end
# unpack based on file extension
_unpack_command = unpack_command
execute "unpack #{new_resource.release_file}" do
command _unpack_command
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
@@ -136,9 +131,8 @@ action :put do
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end
end
@@ -166,9 +160,8 @@ action :dump do
end
# unpack based on file extension
_dump_command = dump_command
execute "unpack #{new_resource.release_file}" do
command _dump_command
command dump_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
@@ -176,9 +169,8 @@ action :dump do
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end
end
@@ -206,9 +198,8 @@ action :unzip do
end
# unpack based on file extension
_unzip_command = unzip_command
execute "unpack #{new_resource.release_file}" do
command _unzip_command
command unzip_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
@@ -216,9 +207,8 @@ action :unzip do
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end
end
@@ -245,20 +235,16 @@ action :cherry_pick do
notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]"
end
_unpack_type = unpack_type
_cherry_pick_command = cherry_pick_command
execute "cherry_pick #{new_resource.creates} from #{new_resource.release_file}" do
Chef::Log.debug("DEBUG: unpack_type: #{_unpack_type}")
command _cherry_pick_command
command cherry_pick_command
creates "#{new_resource.path}/#{new_resource.creates}"
notifies :run, "execute[set owner on #{new_resource.path}]"
action :nothing
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end
end
@@ -285,9 +271,8 @@ action :install_with_make do
end
# unpack based on file extension
_unpack_command = unpack_command
execute "unpack #{new_resource.release_file}" do
command _unpack_command
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
@@ -299,9 +284,8 @@ action :install_with_make do
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end
@@ -335,9 +319,132 @@ action :install_with_make do
environment new_resource.environment
action :nothing
end
end
# unless new_resource.creates and ::File.exists? new_resource.creates
# end
action :setup_py_build do
show_deprecations
set_paths
directory new_resource.path do
recursive true
action :create
notifies :run, "execute[unpack #{new_resource.release_file}]"
end
remote_file new_resource.release_file do
Chef::Log.debug('DEBUG: new_resource.release_file')
source new_resource.url
checksum new_resource.checksum if new_resource.checksum
action :create
notifies :run, "execute[unpack #{new_resource.release_file}]"
end
# unpack based on file extension
execute "unpack #{new_resource.release_file}" do
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
notifies :run, "execute[python setup.py build #{new_resource.path}]"
action :nothing
end
# set_owner
execute "set owner on #{new_resource.path}" do
command owner_command
action :nothing
end
execute "python setup.py build #{new_resource.path}" do
command "python setup.py build #{new_resource.make_opts.join(' ')}"
cwd new_resource.path
environment new_resource.environment
action :nothing
end
end
action :setup_py_install do
show_deprecations
set_paths
directory new_resource.path do
recursive true
action :create
notifies :run, "execute[unpack #{new_resource.release_file}]"
end
remote_file new_resource.release_file do
Chef::Log.debug('DEBUG: new_resource.release_file')
source new_resource.url
checksum new_resource.checksum if new_resource.checksum
action :create
notifies :run, "execute[unpack #{new_resource.release_file}]"
end
# unpack based on file extension
execute "unpack #{new_resource.release_file}" do
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
notifies :run, "execute[python setup.py install #{new_resource.path}]"
action :nothing
end
# set_owner
execute "set owner on #{new_resource.path}" do
command owner_command
action :nothing
end
execute "python setup.py install #{new_resource.path}" do
command "python setup.py install #{new_resource.make_opts.join(' ')}"
cwd new_resource.path
environment new_resource.environment
action :nothing
end
end
action :setup_py do
show_deprecations
set_paths
directory new_resource.path do
recursive true
action :create
notifies :run, "execute[unpack #{new_resource.release_file}]"
end
remote_file new_resource.release_file do
Chef::Log.debug('DEBUG: new_resource.release_file')
source new_resource.url
checksum new_resource.checksum if new_resource.checksum
action :create
notifies :run, "execute[unpack #{new_resource.release_file}]"
end
# unpack based on file extension
execute "unpack #{new_resource.release_file}" do
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
notifies :run, "execute[python setup.py #{new_resource.path}]"
action :nothing
end
# set_owner
execute "set owner on #{new_resource.path}" do
command owner_command
action :nothing
end
execute "python setup.py #{new_resource.path}" do
command "python setup.py #{new_resource.make_opts.join(' ')}"
cwd new_resource.path
environment new_resource.environment
action :nothing
end
end
action :configure do
@@ -359,9 +466,8 @@ action :configure do
end
# unpack based on file extension
_unpack_command = unpack_command
execute "unpack #{new_resource.release_file}" do
command _unpack_command
command unpack_command
cwd new_resource.path
environment new_resource.environment
notifies :run, "execute[set owner on #{new_resource.path}]"
@@ -371,9 +477,8 @@ action :configure do
end
# set_owner
_owner_command = owner_command
execute "set owner on #{new_resource.path}" do
command _owner_command
command owner_command
action :nothing
end

View File

@@ -22,6 +22,4 @@ Array(node['ark']['package_dependencies']).each do |pkg|
package pkg
end
if node['platform_family'] === 'windows'
include_recipe "7-zip"
end
include_recipe "seven_zip" if node['platform_family'] == 'windows'

View File

@@ -1,152 +0,0 @@
# require 'fileutils'
# remove file so we can test sending notification on its creation
FileUtils.rm_f '/tmp/foobarbaz/foo1.txt' if ::File.exist? '/tmp/foobarbaz/foo1.txt'
ruby_block 'test_notification' do
block do
FileUtils.touch '/tmp/foobarbaz/notification_successful.txt' if ::File.exist? '/tmp/foobarbaz/foo1.txt'
end
action :nothing
end
user 'foobarbaz'
directory '/opt/bin' do
recursive true
end
ark 'foo' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tar.gz'
checksum '5996e676f17457c823d86f1605eaa44ca8a81e70d6a0e5f8e45b51e62e0c52e8'
version '2'
prefix_root '/usr/local'
owner 'foobarbaz'
group 'foobarbaz'
has_binaries ['bin/do_foo', 'bin/do_more_foo']
action :install
end
ark 'test_put' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tar.gz'
checksum '5996e676f17457c823d86f1605eaa44ca8a81e70d6a0e5f8e45b51e62e0c52e8'
owner 'foobarbaz'
group 'foobarbaz'
action :put
end
ark 'test_dump' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.zip'
checksum 'deea3a324115c9ca0f3078362f807250080bf1b27516f7eca9d34aad863a11e0'
path '/usr/local/foo_dump'
creates 'foo1.txt'
owner 'foobarbaz'
group 'foobarbaz'
action :dump
end
ark 'cherry_pick_test' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tar.gz'
checksum '5996e676f17457c823d86f1605eaa44ca8a81e70d6a0e5f8e45b51e62e0c52e8'
path '/usr/local/foo_cherry_pick'
owner 'foobarbaz'
group 'foobarbaz'
creates 'foo_sub/foo1.txt'
action :cherry_pick
end
ark 'cherry_pick_with_zip' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.zip'
checksum 'deea3a324115c9ca0f3078362f807250080bf1b27516f7eca9d34aad863a11e0'
path '/usr/local/foo_cherry_pick_from_zip'
creates 'foo_sub/foo1.txt'
action :cherry_pick
end
ark 'foo_append_env' do
version '7.0.26'
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tar.gz'
checksum '5996e676f17457c823d86f1605eaa44ca8a81e70d6a0e5f8e45b51e62e0c52e8'
append_env_path true
action :install
end
ark 'foo_dont_strip' do
version '2'
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tar.gz'
checksum '5996e676f17457c823d86f1605eaa44ca8a81e70d6a0e5f8e45b51e62e0c52e8'
strip_components 0
action :install
end
ark 'foo_zip_strip' do
version '2'
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.zip'
checksum 'deea3a324115c9ca0f3078362f807250080bf1b27516f7eca9d34aad863a11e0'
action :install
end
ark 'haproxy' do
url 'http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz'
version '1.5'
checksum 'ba0424bf7d23b3a607ee24bbb855bb0ea347d7ffde0bec0cb12a89623cbaf911'
make_opts ['TARGET=linux26']
action :install_with_make
end unless platform?('freebsd')
ark 'foo_alt_bin' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tar.gz'
checksum '5996e676f17457c823d86f1605eaa44ca8a81e70d6a0e5f8e45b51e62e0c52e8'
version '3'
prefix_root '/opt'
prefix_home '/opt'
prefix_bin '/opt/bin'
owner 'foobarbaz'
group 'foobarbaz'
has_binaries ['bin/do_foo']
action :install
end
ark 'foo_tbz' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tbz'
version '3'
end
ark 'foo_tgz' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.tgz'
version '3'
end
ark 'foo_txz' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.txz'
version '3'
end
ark 'test notification' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo.zip'
path '/tmp/foobarbaz'
creates 'foo1.txt'
action :dump
notifies :create, 'ruby_block[test_notification]', :immediately
end
ark 'test_autogen' do
url 'https://github.com/zeromq/libzmq/tarball/master'
extension 'tar.gz'
action :configure
# autoconf in RHEL < 6 is too old
not_if { platform_family?('rhel') && node['platform_version'].to_f < 6.0 }
end
ark 'foo_sub' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo_sub.tar.gz'
version '1'
strip_components 2
end
ark 'foo_sub' do
url 'https://github.com/opscode-cookbooks/ark/raw/master/files/default/foo_sub.zip'
version '2'
strip_components 2
end

View File

@@ -18,38 +18,51 @@
# limitations under the License.
#
def initialize(name, run_context = nil)
super
@resource_name = :ark
@allowed_actions.push(:install, :dump, :cherry_pick, :put, :install_with_make, :configure, :setup_py_build, :setup_py_install, :setup_py, :unzip)
@action = :install
@provider = Chef::Provider::Ark
end
actions(
:cherry_pick,
:configure,
:dump,
:install,
:install_with_make,
:put,
:setup_py,
:setup_py_build,
:setup_py_install,
:unzip
)
attr_accessor :path, :release_file, :prefix_bin, :prefix_root, :home_dir, :extension, :version
default_action :install
attribute :owner, :kind_of => String, :default => 'root'
attribute :group, :kind_of => [String, Fixnum], :default => 0
attribute :url, :kind_of => String, :required => true
attribute :path, :kind_of => String, :default => nil
attribute :full_path, :kind_of => String, :default => nil
attribute :append_env_path, :kind_of => [TrueClass, FalseClass], :default => false
attribute :checksum, :regex => /^[a-zA-Z0-9]{64}$/, :default => nil
attribute :has_binaries, :kind_of => Array, :default => []
attribute :creates, :kind_of => String, :default => nil
attribute :release_file, :kind_of => String, :default => ''
attribute :strip_leading_dir, :kind_of => [TrueClass, FalseClass, NilClass]
attribute :strip_components, :kind_of => Integer, :default => 1
attribute :mode, :kind_of => Fixnum, :default => 0755
attribute :prefix_root, :kind_of => String, :default => nil
attribute :prefix_home, :kind_of => String, :default => nil
attribute :prefix_bin, :kind_of => String, :default => nil
attribute :version, :kind_of => String, :default => nil
attribute :home_dir, :kind_of => String, :default => nil
attribute :win_install_dir, :kind_of => String, :default => nil
attribute :environment, :kind_of => Hash, :default => {}
attribute :autoconf_opts, :kind_of => Array, :default => []
attribute :make_opts, :kind_of => Array, :default => []
attribute :home_dir, :kind_of => String, :default => nil
attribute :autoconf_opts, :kind_of => Array, :default => []
attribute :extension, :kind_of => String
attr_accessor :extension,
:home_dir,
:path,
:prefix_bin,
:prefix_root,
:release_file,
:version
attribute :owner, kind_of: String, default: 'root'
attribute :group, kind_of: [String, Fixnum], default: 0
attribute :url, kind_of: String, required: true
attribute :path, kind_of: String, default: nil
attribute :full_path, kind_of: String, default: nil
attribute :append_env_path, kind_of: [TrueClass, FalseClass], default: false
attribute :checksum, regex: /^[a-zA-Z0-9]{64}$/, default: nil
attribute :has_binaries, kind_of: Array, default: []
attribute :creates, kind_of: String, default: nil
attribute :release_file, kind_of: String, default: ''
attribute :strip_leading_dir, kind_of: [TrueClass, FalseClass, NilClass]
attribute :strip_components, kind_of: Integer, default: 1
attribute :mode, kind_of: Fixnum, default: 0755
attribute :prefix_root, kind_of: String, default: nil
attribute :prefix_home, kind_of: String, default: nil
attribute :prefix_bin, kind_of: String, default: nil
attribute :version, kind_of: String, default: nil
attribute :home_dir, kind_of: String, default: nil
attribute :win_install_dir, kind_of: String, default: nil
attribute :environment, kind_of: Hash, default: {}
attribute :autoconf_opts, kind_of: Array, default: []
attribute :make_opts, kind_of: Array, default: []
attribute :home_dir, kind_of: String, default: nil
attribute :autoconf_opts, kind_of: Array, default: []
attribute :extension, kind_of: String

View File

@@ -1 +1 @@
export PATH=<%= @directory -%>:$PATH
export PATH=<%= @directory -%>:$PATH