From 180b3f5df06f2c870cd7a2acf31826b76e53ca0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Kar=C3=A9kinian?= Date: Tue, 2 May 2017 11:56:29 +0200 Subject: [PATCH] Update ark cookbook --- Batali | 2 +- batali.manifest | 26 +- cookbooks/ark/.foodcritic | 1 + cookbooks/ark/CHANGELOG.md | 5 + cookbooks/ark/README.md | 8 +- cookbooks/ark/attributes/default.rb | 2 +- cookbooks/ark/metadata.json | 2 +- cookbooks/ark/providers/default.rb | 503 ------------------------- cookbooks/ark/recipes/default.rb | 4 +- cookbooks/ark/resources/default.rb | 556 +++++++++++++++++++++++++--- 10 files changed, 535 insertions(+), 574 deletions(-) create mode 100644 cookbooks/ark/.foodcritic delete mode 100644 cookbooks/ark/providers/default.rb diff --git a/Batali b/Batali index c96ff4e..ab145b8 100644 --- a/Batali +++ b/Batali @@ -35,7 +35,7 @@ Batali.define do cookbook 'chef_client_updater', '~> 1.0.2' cookbook 'timezone-ii' cookbook 'nodejs', '~> 3.0.0' - cookbook 'ark' + cookbook 'ark', '~> 3.0.0' cookbook 'logrotate' cookbook 'openssl', '~> 7.0.1' end diff --git a/batali.manifest b/batali.manifest index 9a481f2..1f3226a 100644 --- a/batali.manifest +++ b/batali.manifest @@ -1035,6 +1035,18 @@ "version": "3.0.0" } }, + { + "name": "homebrew", + "dependencies": [ + + ], + "version": "3.0.0", + "source": { + "type": "Batali::Source::Site", + "url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download", + "version": "3.0.0" + } + }, { "name": "ark", "dependencies": [ @@ -1050,23 +1062,11 @@ "seven_zip", ">= 0.0.0" ] - ], - "version": "2.2.1", - "source": { - "type": "Batali::Source::Site", - "url": "https://supermarket.chef.io:443/api/v1/cookbooks/ark/versions/2.2.1/download", - "version": "2.2.1" - } - }, - { - "name": "homebrew", - "dependencies": [ - ], "version": "3.0.0", "source": { "type": "Batali::Source::Site", - "url": "https://supermarket.chef.io:443/api/v1/cookbooks/homebrew/versions/3.0.0/download", + "url": "https://supermarket.chef.io:443/api/v1/cookbooks/ark/versions/3.0.0/download", "version": "3.0.0" } }, diff --git a/cookbooks/ark/.foodcritic b/cookbooks/ark/.foodcritic new file mode 100644 index 0000000..b9f8767 --- /dev/null +++ b/cookbooks/ark/.foodcritic @@ -0,0 +1 @@ +~FC016 diff --git a/cookbooks/ark/CHANGELOG.md b/cookbooks/ark/CHANGELOG.md index 41b3e54..f10ff09 100644 --- a/cookbooks/ark/CHANGELOG.md +++ b/cookbooks/ark/CHANGELOG.md @@ -2,6 +2,11 @@ This file is used to list changes made in each version of the ark cookbook. +## 3.0.0 (2017-04-05) +- Rewrite of resource to custom resources. +- Remove EOL platforms from testing. +- Update zlib URL +- ## 2.2.1 (2016-12-16) - Use Ohai root_group attribute to avoid trying to set the group to root on BSD/macOS. - Add missing accessor for owner property diff --git a/cookbooks/ark/README.md b/cookbooks/ark/README.md index ac467c1..5b05216 100644 --- a/cookbooks/ark/README.md +++ b/cookbooks/ark/README.md @@ -16,7 +16,7 @@ ark 'pig' do end ``` -The provider will: +The `ark` resource will: - fetch it to to `/var/cache/chef/` - unpack it to the default path (`/usr/local/pig-0.8.0`) @@ -44,7 +44,7 @@ Should work on common Unix/Linux systems with typical userland utilities like ta ### Chef -- Chef 12.1+ +- Chef 12.5+ ### Cookbooks @@ -66,7 +66,7 @@ Customize the attributes to suit site specific conventions and defaults. ## Resources -- `ark` - does the extract/build/configure dance +- `ark` - does the extract/build/configure ### Actions @@ -281,7 +281,7 @@ You can also supply the file extension in case the file extension can not be det - Copyright: 2011, Philip (flip) Kromer - Infochimps, Inc - Copyright: 2012, Bryan W. Berry - Copyright: 2012, Denis Barishev -- Copyright: 2013-2016, Chef Software, Inc +- Copyright: 2013-2017, Chef Software, Inc - Copyright: 2014, Bloomberg L.P. ``` diff --git a/cookbooks/ark/attributes/default.rb b/cookbooks/ark/attributes/default.rb index 0f44dbd..0767723 100644 --- a/cookbooks/ark/attributes/default.rb +++ b/cookbooks/ark/attributes/default.rb @@ -1,5 +1,5 @@ # -# Cookbook Name:: ark +# Cookbook:: ark # Attributes:: default # # diff --git a/cookbooks/ark/metadata.json b/cookbooks/ark/metadata.json index d3ba1cf..7746bfc 100644 --- a/cookbooks/ark/metadata.json +++ b/cookbooks/ark/metadata.json @@ -1 +1 @@ -{"name":"ark","version":"2.2.1","description":"Provides a custom resource for installing runtime artifacts in a predictable fashion","long_description":"# ark cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/ark.svg?branch=master)](https://travis-ci.org/chef-cookbooks/ark) [![Cookbook Version](https://img.shields.io/cookbook/v/ark.svg)](https://supermarket.chef.io/cookbooks/ark)\n\n## Overview\n\nThis 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.\n\nThis 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.\n\nGiven a simple project archive available at a url:\n\n```ruby\nark 'pig' do\n url 'http://apache.org/pig/pig-0.8.0.tar.gz'\nend\n```\n\nThe provider will:\n\n- fetch it to to `/var/cache/chef/`\n- unpack it to the default path (`/usr/local/pig-0.8.0`)\n- create a symlink for `:home_dir` (`/usr/local/pig`) pointing to path\n- add specified binary commands to the environment `PATH` variable\n\nBy 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`.\n\nAt 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.\n\n## Requirements\n\n### Platforms\n\n- Debian/Ubuntu\n- RHEL/CentOS/Scientific/Oracle\n- Fedora\n- FreeBSD\n- SmartOS\n- Mac OS X\n- openSUSE / SUSE Linux Enterprises\n- Windows\n\nShould 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.\n\n### Chef\n\n- Chef 12.1+\n\n### Cookbooks\n\n- build-essential\n- seven_zip\n- windows\n\n## Attributes\n\nCustomize the attributes to suit site specific conventions and defaults.\n\n- `node['ark']['apache_mirror']` - if the URL is an apache mirror, use the attribute as the default. default: `http://apache.mirrors.tds.net`\n- `node['ark']['prefix_root']` - default base location if the `prefix_root` is not passed into the resource. default: `/usr/local`\n- `node['ark']['prefix_bin']` - default binary location if the `prefix_bin` is not passed into the resource. default: `/usr/local/bin`\n- `node['ark']['prefix_home']` - default home location if the `prefix_home` is not passed into the resource. default: `/usr/local`\n- `node['ark']['package_dependencies']` - prerequisite system packages that need to be installed to support ark. default: varies based on platform\n- `node['ark']['tar']` - allows overriding the default path to the tar binary, which varies based on platform\n- `node['ark']['sevenzip_binary']` - allows overriding the default path to the 7zip binary, which is determined based on registry key value\n\n## Resources\n\n- `ark` - does the extract/build/configure dance\n\n### Actions\n\n- `:install`: extracts the file and creates a 'friendly' symbolic link to the extracted directory path\n- `:configure`: configure ahead of the install action\n- `:install_with_make`: extracts the archive to a path, runs `configure`, `make`, and `make install`.\n- `:dump`: strips all directories from the archive and dumps the contained files into a specified path\n- `:cherry_pick`: extract a specified file from an archive and places in specified path\n- `:put`: extract the archive to a specified path, does not create any symbolic links\n- `:remove`: removes the extracted directory and related symlink #TODO\n- `:setup_py`: runs the command \"python setup.py\" in the extracted directory\n- `:setup_py_build`: runs the command \"python setup.py build\" in the extracted directory\n- `:setup_py_install`: runs the command \"python setup.py install\" in the extracted directory\n\n### :cherry_pick\n\nExtract a specified file from an archive and places in specified path.\n\n#### Relevant Attribute Parameters for :cherry_pick\n\n- `path`: directory to place file in.\n- `creates`: specific file to cherry-pick.\n\n### :dump\n\nStrips all directories from the archive and dumps the contained files into a specified path.\n\nNOTE: This currently only works for zip archives\n\n#### Attribute Parameters for :dump\n\n- `path`: path to dump files to.\n- `mode`: file mode for `app_home`, as an integer.\n\n - Example: `0775`\n\n- `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.\n\n### :put\n\nExtract the archive to a specified path, does not create any symbolic links.\n\n#### Attribute Parameters for :put\n\n- `path`: path to extract to.\n\n - Default: `/usr/local`\n\n- `append_env_path`: boolean, if true, append the `./bin` directory of the extracted directory to the global `PATH` variable for all users.\n\n### Attribute Parameters\n\n- `name`: name of the package, defaults to the resource name.\n- `url`: url for tarball, `.tar.gz`, `.bin` (oracle-specific), `.war`, and `.zip` currently supported. Also supports special syntax\n- `:name:version:apache_mirror:` that will auto-magically construct download url from the apache mirrors site.\n- `version`: software version, defaults to `1`.\n- `mode`: file mode for `app_home`, is an integer.\n- `prefix_root`: default `prefix_root`, for use with `:install*` actions.\n- `prefix_home`: default directory prefix for a friendly symlink to the path.\n\n - Example: `/usr/local/maven` -> `/usr/local/maven-2.2.1`\n\n- `prefix_bin`: default directory to place a symlink to a binary command.\n\n - Example: `/opt/bin/mvn` -> `/opt/maven-2.2.1/bin/mvn`, where the `prefix_bin` is `/opt/bin`\n\n- `path`: path to extract the ark to. The `:install*` actions overwrite any user-provided values for `:path`.\n\n - Default: `/usr/local/-` for the `:install`, `:install_with_make` actions\n\n- `home_dir`: symbolic link to the path `:prefix_root/:name-:version`, does not apply to `:dump`, `:put`, or `:cherry_pick` actions.\n\n - Default: `:prefix_root/:name`\n\n- `has_binaries`: array of binary commands to symlink into `/usr/local/bin/`, you must specify the relative path.\n\n - Example: `[ 'bin/java', 'bin/javaws' ]`\n\n- `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.\n\n - Example: `mvn`, `java`, `javac`, etc.\n\n- `environment`: hash of environment variables to pass to invoked shell commands like `tar`, `unzip`, `configure`, and `make`.\n\n- `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.\n\n- `autoconf_opts`: an array of command line options for use with the GNU `autoconf` script.\n\n - Example: `[ '--include=/opt/local/include', '--force' ]`\n\n- `make_opts`: an array of command line options for use with `make`.\n\n - Example: `[ '--warn-undefined-variables', '--load-average=2' ]`\n\n- `owner`: owner of extracted directory.\n\n - Default: `root`\n\n- `group`: group of extracted directory.\n\n - Default: `root`\n\n- `backup`: The number of backups to be kept in /var/chef/backup (for UNIX- and Linux-based platforms) or C:/chef/backup (for the Microsoft Windows platform). Set to false to prevent backups from being kept.\n\n - Default: `5`\n\n#### Examples\n\nThis 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`\n\n```ruby\n # install Apache Ivy dependency resolution tool\n ark \"ivy\" do\n url 'http://someurl.example.com/ivy.tar.gz'\n version '2.2.0'\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n action :install\n end\n```\n\nThis 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:\n\n```ruby\n ark 'jdk' do\n url 'http://download.example.com/jdk-7u2-linux-x64.tar.gz'\n version '7.2'\n path \"/usr/local/jvm/\"\n home_dir \"/usr/local/jvm/default\"\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n append_env_path true\n owner 'foobar'\n end\n```\n\nInstall Apache Ivy dependency resolution tool in `/resource_name` in this case `/usr/local/ivy`, do not symlink, and strip any leading directory if one exists in the tarball:\n\n```ruby\n ark \"ivy\" do\n url 'http://someurl.example.com/ivy.tar.gz'\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n action :put\n end\n```\n\nInstall Apache Ivy dependency resolution tool in `/home/foobar/ivy`, strip any leading directory if one exists, don't keep backup copies of `ivy.tar.gz`:\n\n```ruby\n ark \"ivy\" do\n path \"/home/foobar\"\n url 'http://someurl.example.com/ivy.tar.gz'\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n action :put\n backup false\n end\n```\n\nStrip 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:\n\n```ruby\n ark \"my_jars\" do\n url \"http://example.com/bunch_of_jars.zip\"\n path \"/usr/local/tomcat/lib\"\n creates \"mysql.jar\"\n owner \"tomcat\"\n action :dump\n end\n```\n\nExtract specific files from a tarball (currently only handles one named file):\n\n```ruby\n ark 'mysql-connector-java' do\n url 'http://oracle.com/mysql-connector.zip'\n creates 'mysql-connector-java-5.0.8-bin.jar'\n path '/usr/local/tomcat/lib'\n action :cherry_pick\n end\n```\n\nBuild and install haproxy and use alternative values for `prefix_root`, `prefix_home`, and `prefix_bin`:\n\n```ruby\n ark \"haproxy\" do\n url \"http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz\"\n version \"1.5\"\n checksum 'ba0424bf7d23b3a607ee24bbb855bb0ea347d7ffde0bec0cb12a89623cbaf911'\n make_opts [ 'TARGET=linux26' ]\n prefix_root '/opt'\n prefix_home '/opt'\n prefix_bin '/opt/bin'\n action :install_with_make\n end\n```\n\nYou can also supply the file extension in case the file extension can not be determined by the URL:\n\n```ruby\n ark \"test_autogen\" do\n url 'https://github.com/zeromq/libzmq/tarball/master'\n extension \"tar.gz\"\n action :install_with_make\n end\n```\n\n## License & Authors\n\n- Author: Philip (flip) Kromer - Infochimps, Inc([coders@infochimps.com](mailto:coders@infochimps.com))\n- Author: Bryan W. Berry ([bryan.berry@gmail.com](mailto:bryan.berry@gmail.com))\n- Author: Denis Barishev ([denis.barishev@gmail.com](mailto:denis.barishev@gmail.com))\n- Author: Sean OMeara ([someara@chef.io](mailto:someara@chef.io))\n- Author: John Bellone ([jbellone@bloomberg.net](mailto:jbellone@bloomberg.net))\n- Copyright: 2011, Philip (flip) Kromer - Infochimps, Inc\n- Copyright: 2012, Bryan W. Berry\n- Copyright: 2012, Denis Barishev\n- Copyright: 2013-2016, Chef Software, Inc\n- Copyright: 2014, Bloomberg L.P.\n\n```\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache 2.0","platforms":{"ubuntu":">= 0.0.0","debian":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","suse":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0","amazon":">= 0.0.0","windows":">= 0.0.0","mac_os_x":">= 0.0.0","smartos":">= 0.0.0","freebsd":">= 0.0.0"},"dependencies":{"build-essential":">= 0.0.0","windows":">= 0.0.0","seven_zip":">= 0.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"ark::default":"Installs packages needed by the custom resource"}} \ No newline at end of file +{"name":"ark","version":"3.0.0","description":"Provides a custom resource for installing runtime artifacts in a predictable fashion","long_description":"# ark cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/ark.svg?branch=master)](https://travis-ci.org/chef-cookbooks/ark) [![Cookbook Version](https://img.shields.io/cookbook/v/ark.svg)](https://supermarket.chef.io/cookbooks/ark)\n\n## Overview\n\nThis 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.\n\nThis 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.\n\nGiven a simple project archive available at a url:\n\n```ruby\nark 'pig' do\n url 'http://apache.org/pig/pig-0.8.0.tar.gz'\nend\n```\n\nThe `ark` resource will:\n\n- fetch it to to `/var/cache/chef/`\n- unpack it to the default path (`/usr/local/pig-0.8.0`)\n- create a symlink for `:home_dir` (`/usr/local/pig`) pointing to path\n- add specified binary commands to the environment `PATH` variable\n\nBy 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`.\n\nAt 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.\n\n## Requirements\n\n### Platforms\n\n- Debian/Ubuntu\n- RHEL/CentOS/Scientific/Oracle\n- Fedora\n- FreeBSD\n- SmartOS\n- Mac OS X\n- openSUSE / SUSE Linux Enterprises\n- Windows\n\nShould 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.\n\n### Chef\n\n- Chef 12.5+\n\n### Cookbooks\n\n- build-essential\n- seven_zip\n- windows\n\n## Attributes\n\nCustomize the attributes to suit site specific conventions and defaults.\n\n- `node['ark']['apache_mirror']` - if the URL is an apache mirror, use the attribute as the default. default: `http://apache.mirrors.tds.net`\n- `node['ark']['prefix_root']` - default base location if the `prefix_root` is not passed into the resource. default: `/usr/local`\n- `node['ark']['prefix_bin']` - default binary location if the `prefix_bin` is not passed into the resource. default: `/usr/local/bin`\n- `node['ark']['prefix_home']` - default home location if the `prefix_home` is not passed into the resource. default: `/usr/local`\n- `node['ark']['package_dependencies']` - prerequisite system packages that need to be installed to support ark. default: varies based on platform\n- `node['ark']['tar']` - allows overriding the default path to the tar binary, which varies based on platform\n- `node['ark']['sevenzip_binary']` - allows overriding the default path to the 7zip binary, which is determined based on registry key value\n\n## Resources\n\n- `ark` - does the extract/build/configure \n\n### Actions\n\n- `:install`: extracts the file and creates a 'friendly' symbolic link to the extracted directory path\n- `:configure`: configure ahead of the install action\n- `:install_with_make`: extracts the archive to a path, runs `configure`, `make`, and `make install`.\n- `:dump`: strips all directories from the archive and dumps the contained files into a specified path\n- `:cherry_pick`: extract a specified file from an archive and places in specified path\n- `:put`: extract the archive to a specified path, does not create any symbolic links\n- `:remove`: removes the extracted directory and related symlink #TODO\n- `:setup_py`: runs the command \"python setup.py\" in the extracted directory\n- `:setup_py_build`: runs the command \"python setup.py build\" in the extracted directory\n- `:setup_py_install`: runs the command \"python setup.py install\" in the extracted directory\n\n### :cherry_pick\n\nExtract a specified file from an archive and places in specified path.\n\n#### Relevant Attribute Parameters for :cherry_pick\n\n- `path`: directory to place file in.\n- `creates`: specific file to cherry-pick.\n\n### :dump\n\nStrips all directories from the archive and dumps the contained files into a specified path.\n\nNOTE: This currently only works for zip archives\n\n#### Attribute Parameters for :dump\n\n- `path`: path to dump files to.\n- `mode`: file mode for `app_home`, as an integer.\n\n - Example: `0775`\n\n- `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.\n\n### :put\n\nExtract the archive to a specified path, does not create any symbolic links.\n\n#### Attribute Parameters for :put\n\n- `path`: path to extract to.\n\n - Default: `/usr/local`\n\n- `append_env_path`: boolean, if true, append the `./bin` directory of the extracted directory to the global `PATH` variable for all users.\n\n### Attribute Parameters\n\n- `name`: name of the package, defaults to the resource name.\n- `url`: url for tarball, `.tar.gz`, `.bin` (oracle-specific), `.war`, and `.zip` currently supported. Also supports special syntax\n- `:name:version:apache_mirror:` that will auto-magically construct download url from the apache mirrors site.\n- `version`: software version, defaults to `1`.\n- `mode`: file mode for `app_home`, is an integer.\n- `prefix_root`: default `prefix_root`, for use with `:install*` actions.\n- `prefix_home`: default directory prefix for a friendly symlink to the path.\n\n - Example: `/usr/local/maven` -> `/usr/local/maven-2.2.1`\n\n- `prefix_bin`: default directory to place a symlink to a binary command.\n\n - Example: `/opt/bin/mvn` -> `/opt/maven-2.2.1/bin/mvn`, where the `prefix_bin` is `/opt/bin`\n\n- `path`: path to extract the ark to. The `:install*` actions overwrite any user-provided values for `:path`.\n\n - Default: `/usr/local/-` for the `:install`, `:install_with_make` actions\n\n- `home_dir`: symbolic link to the path `:prefix_root/:name-:version`, does not apply to `:dump`, `:put`, or `:cherry_pick` actions.\n\n - Default: `:prefix_root/:name`\n\n- `has_binaries`: array of binary commands to symlink into `/usr/local/bin/`, you must specify the relative path.\n\n - Example: `[ 'bin/java', 'bin/javaws' ]`\n\n- `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.\n\n - Example: `mvn`, `java`, `javac`, etc.\n\n- `environment`: hash of environment variables to pass to invoked shell commands like `tar`, `unzip`, `configure`, and `make`.\n\n- `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.\n\n- `autoconf_opts`: an array of command line options for use with the GNU `autoconf` script.\n\n - Example: `[ '--include=/opt/local/include', '--force' ]`\n\n- `make_opts`: an array of command line options for use with `make`.\n\n - Example: `[ '--warn-undefined-variables', '--load-average=2' ]`\n\n- `owner`: owner of extracted directory.\n\n - Default: `root`\n\n- `group`: group of extracted directory.\n\n - Default: `root`\n\n- `backup`: The number of backups to be kept in /var/chef/backup (for UNIX- and Linux-based platforms) or C:/chef/backup (for the Microsoft Windows platform). Set to false to prevent backups from being kept.\n\n - Default: `5`\n\n#### Examples\n\nThis 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`\n\n```ruby\n # install Apache Ivy dependency resolution tool\n ark \"ivy\" do\n url 'http://someurl.example.com/ivy.tar.gz'\n version '2.2.0'\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n action :install\n end\n```\n\nThis 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:\n\n```ruby\n ark 'jdk' do\n url 'http://download.example.com/jdk-7u2-linux-x64.tar.gz'\n version '7.2'\n path \"/usr/local/jvm/\"\n home_dir \"/usr/local/jvm/default\"\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n append_env_path true\n owner 'foobar'\n end\n```\n\nInstall Apache Ivy dependency resolution tool in `/resource_name` in this case `/usr/local/ivy`, do not symlink, and strip any leading directory if one exists in the tarball:\n\n```ruby\n ark \"ivy\" do\n url 'http://someurl.example.com/ivy.tar.gz'\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n action :put\n end\n```\n\nInstall Apache Ivy dependency resolution tool in `/home/foobar/ivy`, strip any leading directory if one exists, don't keep backup copies of `ivy.tar.gz`:\n\n```ruby\n ark \"ivy\" do\n path \"/home/foobar\"\n url 'http://someurl.example.com/ivy.tar.gz'\n checksum '89ba5fde0c596db388c3bbd265b63007a9cc3df3a8e6d79a46780c1a39408cb5'\n action :put\n backup false\n end\n```\n\nStrip 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:\n\n```ruby\n ark \"my_jars\" do\n url \"http://example.com/bunch_of_jars.zip\"\n path \"/usr/local/tomcat/lib\"\n creates \"mysql.jar\"\n owner \"tomcat\"\n action :dump\n end\n```\n\nExtract specific files from a tarball (currently only handles one named file):\n\n```ruby\n ark 'mysql-connector-java' do\n url 'http://oracle.com/mysql-connector.zip'\n creates 'mysql-connector-java-5.0.8-bin.jar'\n path '/usr/local/tomcat/lib'\n action :cherry_pick\n end\n```\n\nBuild and install haproxy and use alternative values for `prefix_root`, `prefix_home`, and `prefix_bin`:\n\n```ruby\n ark \"haproxy\" do\n url \"http://haproxy.1wt.eu/download/1.5/src/snapshot/haproxy-ss-20120403.tar.gz\"\n version \"1.5\"\n checksum 'ba0424bf7d23b3a607ee24bbb855bb0ea347d7ffde0bec0cb12a89623cbaf911'\n make_opts [ 'TARGET=linux26' ]\n prefix_root '/opt'\n prefix_home '/opt'\n prefix_bin '/opt/bin'\n action :install_with_make\n end\n```\n\nYou can also supply the file extension in case the file extension can not be determined by the URL:\n\n```ruby\n ark \"test_autogen\" do\n url 'https://github.com/zeromq/libzmq/tarball/master'\n extension \"tar.gz\"\n action :install_with_make\n end\n```\n\n## License & Authors\n\n- Author: Philip (flip) Kromer - Infochimps, Inc([coders@infochimps.com](mailto:coders@infochimps.com))\n- Author: Bryan W. Berry ([bryan.berry@gmail.com](mailto:bryan.berry@gmail.com))\n- Author: Denis Barishev ([denis.barishev@gmail.com](mailto:denis.barishev@gmail.com))\n- Author: Sean OMeara ([someara@chef.io](mailto:someara@chef.io))\n- Author: John Bellone ([jbellone@bloomberg.net](mailto:jbellone@bloomberg.net))\n- Copyright: 2011, Philip (flip) Kromer - Infochimps, Inc\n- Copyright: 2012, Bryan W. Berry\n- Copyright: 2012, Denis Barishev\n- Copyright: 2013-2017, Chef Software, Inc\n- Copyright: 2014, Bloomberg L.P.\n\n```\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"ubuntu":">= 0.0.0","debian":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","suse":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0","amazon":">= 0.0.0","windows":">= 0.0.0","mac_os_x":">= 0.0.0","smartos":">= 0.0.0","freebsd":">= 0.0.0"},"dependencies":{"build-essential":">= 0.0.0","windows":">= 0.0.0","seven_zip":">= 0.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"ark::default":"Installs packages needed by the custom resource"},"source_url":"https://github.com/chef-cookbooks/ark","issues_url":"https://github.com/chef-cookbooks/ark/issues","chef_version":">= 12.5","ohai_version":{}} \ No newline at end of file diff --git a/cookbooks/ark/providers/default.rb b/cookbooks/ark/providers/default.rb deleted file mode 100644 index 7f16a7f..0000000 --- a/cookbooks/ark/providers/default.rb +++ /dev/null @@ -1,503 +0,0 @@ -# -# Cookbook Name:: ark -# Provider:: Ark -# -# Author:: Bryan W. Berry -# Author:: Sean OMeara -# Copyright 2012, Bryan W. Berry -# Copyright 2013-2016, 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 -# -# 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 -include ::Ark::ProviderHelpers - -################# -# action :install -################# -action :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}]" - backup new_resource.backup - 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}]" - action :nothing - end - - # set_owner - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end - - # usually on windows there is no central directory with executables where the applications are linked - 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 - to ::File.join(new_resource.path, bin) - end - end - - # action_link_paths - link new_resource.home_dir do - to new_resource.path - end - - # Add to path for interactive bash sessions - template "/etc/profile.d/#{new_resource.name}.sh" do - cookbook 'ark' - source 'add_to_path.sh.erb' - owner 'root' - group node['root_group'] - mode '0755' - cookbook 'ark' - variables(directory: "#{new_resource.path}/bin") - only_if { new_resource.append_env_path } - end - end - - # Add to path for the current chef-client converge. - bin_path = ::File.join(new_resource.path, 'bin') - ruby_block "adding '#{bin_path}' to chef-client ENV['PATH']" do - block do - ENV['PATH'] = bin_path + ':' + ENV['PATH'] - end - only_if do - new_resource.append_env_path && ENV['PATH'].scan(bin_path).empty? - end - end -end - -############## -# action :put -############## -action :put do - show_deprecations - set_put_paths - - directory new_resource.path do - recursive true - action :create - notifies :run, "execute[unpack #{new_resource.release_file}]" - end - - # download - remote_file new_resource.release_file do - source new_resource.url - checksum new_resource.checksum if new_resource.checksum - action :create - notifies :run, "execute[unpack #{new_resource.release_file}]" - backup new_resource.backup - 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}]" - action :nothing - end - - # set_owner - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end -end - -########################### -# action :dump -########################### -action :dump do - show_deprecations - set_dump_paths - - directory new_resource.path do - recursive true - action :create - notifies :run, "execute[unpack #{new_resource.release_file}]" - end - - # download - remote_file new_resource.release_file do - Chef::Log.debug("DEBUG: new_resource.release_file #{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 dump_command - cwd new_resource.path - environment new_resource.environment - notifies :run, "execute[set owner on #{new_resource.path}]" - action :nothing - end - - # set_owner - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end -end - -########################### -# action :unzip -########################### -action :unzip do - show_deprecations - set_dump_paths - - directory new_resource.path do - recursive true - action :create - notifies :run, "execute[unpack #{new_resource.release_file}]" - end - - # download - remote_file new_resource.release_file do - Chef::Log.debug("DEBUG: new_resource.release_file #{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 unzip_command - cwd new_resource.path - environment new_resource.environment - notifies :run, "execute[set owner on #{new_resource.path}]" - action :nothing - end - - # set_owner - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end -end - -##################### -# action :cherry_pick -##################### -action :cherry_pick do - show_deprecations - set_dump_paths - Chef::Log.debug("DEBUG: new_resource.creates #{new_resource.creates}") - - directory new_resource.path do - recursive true - action :create - notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]" - end - - # download - remote_file new_resource.release_file do - source new_resource.url - checksum new_resource.checksum if new_resource.checksum - action :create - notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]" - end - - execute "cherry_pick #{new_resource.creates} from #{new_resource.release_file}" do - 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 - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end -end - -########################### -# action :install_with_make -########################### -action :install_with_make 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[autogen #{new_resource.path}]" - notifies :run, "execute[configure #{new_resource.path}]" - notifies :run, "execute[make #{new_resource.path}]" - notifies :run, "execute[make install #{new_resource.path}]" - action :nothing - end - - # set_owner - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end - - execute "autogen #{new_resource.path}" do - command './autogen.sh' - only_if { ::File.exist? "#{new_resource.path}/autogen.sh" } - cwd new_resource.path - environment new_resource.environment - action :nothing - ignore_failure true - end - - execute "configure #{new_resource.path}" do - command "./configure #{new_resource.autoconf_opts.join(' ')}" - only_if { ::File.exist? "#{new_resource.path}/configure" } - cwd new_resource.path - environment new_resource.environment - action :nothing - end - - execute "make #{new_resource.path}" do - command "make #{new_resource.make_opts.join(' ')}" - cwd new_resource.path - environment new_resource.environment - action :nothing - end - - execute "make install #{new_resource.path}" do - command "make install #{new_resource.make_opts.join(' ')}" - cwd new_resource.path - environment new_resource.environment - action :nothing - end -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 - 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[autogen #{new_resource.path}]" - notifies :run, "execute[configure #{new_resource.path}]" - action :nothing - end - - # set_owner - execute "set owner on #{new_resource.path}" do - command owner_command - action :nothing - end - - execute "autogen #{new_resource.path}" do - command './autogen.sh' - only_if { ::File.exist? "#{new_resource.path}/autogen.sh" } - cwd new_resource.path - environment new_resource.environment - action :nothing - ignore_failure true - end - - execute "configure #{new_resource.path}" do - command "./configure #{new_resource.autoconf_opts.join(' ')}" - only_if { ::File.exist? "#{new_resource.path}/configure" } - cwd new_resource.path - environment new_resource.environment - action :nothing - end -end diff --git a/cookbooks/ark/recipes/default.rb b/cookbooks/ark/recipes/default.rb index 8b5072c..9a482aa 100644 --- a/cookbooks/ark/recipes/default.rb +++ b/cookbooks/ark/recipes/default.rb @@ -1,9 +1,9 @@ # -# Cookbook Name:: ark +# Cookbook:: ark # Recipe:: default # # Author:: Bryan W. Berry -# Copyright 2012, Bryan W. Berry +# Copyright:: 2012-2017, Bryan W. Berry # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/cookbooks/ark/resources/default.rb b/cookbooks/ark/resources/default.rb index 985d1e8..3ca2ea1 100644 --- a/cookbooks/ark/resources/default.rb +++ b/cookbooks/ark/resources/default.rb @@ -1,9 +1,10 @@ # -# Cookbook Name:: ark +# Cookbook:: ark # Resource:: Ark # # Author:: Bryan W. Berry -# Copyright 2012, Bryan W. Berry +# Copyright:: 2012-2017, Bryan W. Berry +# Copyright:: 2016-2017, Chef Software Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,53 +19,510 @@ # limitations under the License. # -actions( - :cherry_pick, - :configure, - :dump, - :install, - :install_with_make, - :put, - :setup_py, - :setup_py_build, - :setup_py_install, - :unzip -) +property :owner, String +property :group, [String, Integer], default: 0 +property :url, String, required: true +property :path, String +property :full_path, String +property :append_env_path, [true, false], default: false +property :checksum, regex: /^[a-zA-Z0-9]{64}$/, default: nil +property :has_binaries, Array, default: [] +property :creates, String +property :release_file, String, default: '' +property :strip_leading_dir, [true, false, NilClass] +property :strip_components, Integer, default: 1 +property :mode, [Integer, String], default: 0755 +property :prefix_root, String +property :prefix_home, String +property :prefix_bin, String +property :version, String +property :home_dir, String +property :win_install_dir, String +property :environment, Hash, default: {} +property :autoconf_opts, Array, default: [] +property :make_opts, Array, default: [] +property :home_dir, String +property :autoconf_opts, Array, default: [] +property :extension, String +property :backup, [FalseClass, Integer], default: 5 -default_action :install +################# +# action :install +################# +action :install do + show_deprecations + set_paths -attr_accessor :extension, - :home_dir, - :owner, - :path, - :prefix_bin, - :prefix_root, - :release_file, - :version + directory new_resource.path do + recursive true + action :create + notifies :run, "execute[unpack #{new_resource.release_file}]" + end -attribute :owner, kind_of: String, default: nil -attribute :group, kind_of: [String, Integer], 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: Integer, 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 -attribute :backup, kind_of: [FalseClass, Integer], default: 5 + 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}]" + backup new_resource.backup + 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}]" + action :nothing + end + + # set_owner + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end + + # usually on windows there is no central directory with executables where the applications are linked + 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 + to ::File.join(new_resource.path, bin) + end + end + + # action_link_paths + link new_resource.home_dir do + to new_resource.path + end + + # Add to path for interactive bash sessions + template "/etc/profile.d/#{new_resource.name}.sh" do + cookbook 'ark' + source 'add_to_path.sh.erb' + owner 'root' + group node['root_group'] + mode '0755' + cookbook 'ark' + variables(directory: "#{new_resource.path}/bin") + only_if { new_resource.append_env_path } + end + end + + # Add to path for the current chef-client converge. + bin_path = ::File.join(new_resource.path, 'bin') + ruby_block "adding '#{bin_path}' to chef-client ENV['PATH']" do + block do + ENV['PATH'] = bin_path + ':' + ENV['PATH'] + end + only_if do + new_resource.append_env_path && ENV['PATH'].scan(bin_path).empty? + end + end +end + +############## +# action :put +############## +action :put do + show_deprecations + set_put_paths + + directory new_resource.path do + recursive true + action :create + notifies :run, "execute[unpack #{new_resource.release_file}]" + end + + # download + remote_file new_resource.release_file do + source new_resource.url + checksum new_resource.checksum if new_resource.checksum + action :create + notifies :run, "execute[unpack #{new_resource.release_file}]" + backup new_resource.backup + 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}]" + action :nothing + end + + # set_owner + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end +end + +########################### +# action :dump +########################### +action :dump do + show_deprecations + set_dump_paths + + directory new_resource.path do + recursive true + action :create + notifies :run, "execute[unpack #{new_resource.release_file}]" + end + + # download + remote_file new_resource.release_file do + Chef::Log.debug("DEBUG: new_resource.release_file #{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 dump_command + cwd new_resource.path + environment new_resource.environment + notifies :run, "execute[set owner on #{new_resource.path}]" + action :nothing + end + + # set_owner + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end +end + +########################### +# action :unzip +########################### +action :unzip do + show_deprecations + set_dump_paths + + directory new_resource.path do + recursive true + action :create + notifies :run, "execute[unpack #{new_resource.release_file}]" + end + + # download + remote_file new_resource.release_file do + Chef::Log.debug("DEBUG: new_resource.release_file #{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 unzip_command + cwd new_resource.path + environment new_resource.environment + notifies :run, "execute[set owner on #{new_resource.path}]" + action :nothing + end + + # set_owner + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end +end + +##################### +# action :cherry_pick +##################### +action :cherry_pick do + show_deprecations + set_dump_paths + Chef::Log.debug("DEBUG: new_resource.creates #{new_resource.creates}") + + directory new_resource.path do + recursive true + action :create + notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]" + end + + # download + remote_file new_resource.release_file do + source new_resource.url + checksum new_resource.checksum if new_resource.checksum + action :create + notifies :run, "execute[cherry_pick #{new_resource.creates} from #{new_resource.release_file}]" + end + + execute "cherry_pick #{new_resource.creates} from #{new_resource.release_file}" do + 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 + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end +end + +########################### +# action :install_with_make +########################### +action :install_with_make 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[autogen #{new_resource.path}]" + notifies :run, "execute[configure #{new_resource.path}]" + notifies :run, "execute[make #{new_resource.path}]" + notifies :run, "execute[make install #{new_resource.path}]" + action :nothing + end + + # set_owner + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end + + execute "autogen #{new_resource.path}" do + command './autogen.sh' + only_if { ::File.exist? "#{new_resource.path}/autogen.sh" } + cwd new_resource.path + environment new_resource.environment + action :nothing + ignore_failure true + end + + execute "configure #{new_resource.path}" do + command "./configure #{new_resource.autoconf_opts.join(' ')}" + only_if { ::File.exist? "#{new_resource.path}/configure" } + cwd new_resource.path + environment new_resource.environment + action :nothing + end + + execute "make #{new_resource.path}" do + command "make #{new_resource.make_opts.join(' ')}" + cwd new_resource.path + environment new_resource.environment + action :nothing + end + + execute "make install #{new_resource.path}" do + command "make install #{new_resource.make_opts.join(' ')}" + cwd new_resource.path + environment new_resource.environment + action :nothing + end +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 + 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[autogen #{new_resource.path}]" + notifies :run, "execute[configure #{new_resource.path}]" + action :nothing + end + + # set_owner + execute "set owner on #{new_resource.path}" do + command owner_command + action :nothing + end + + execute "autogen #{new_resource.path}" do + command './autogen.sh' + only_if { ::File.exist? "#{new_resource.path}/autogen.sh" } + cwd new_resource.path + environment new_resource.environment + action :nothing + ignore_failure true + end + + execute "configure #{new_resource.path}" do + command "./configure #{new_resource.autoconf_opts.join(' ')}" + only_if { ::File.exist? "#{new_resource.path}/configure" } + cwd new_resource.path + environment new_resource.environment + action :nothing + end +end + +action_class.class_eval do + include ::Ark::ProviderHelpers +end