From 0005f9ab7d11e4a50a125d522f5f859d4caf71b8 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 23 Aug 2020 11:01:05 +0200 Subject: [PATCH] Add golang cookbook Needs updating of ark and git cookbooks --- Berksfile | 6 +- Berksfile.lock | 17 +- cookbooks/ark/.foodcritic | 1 - cookbooks/ark/CHANGELOG.md | 23 ++- cookbooks/ark/MAINTAINERS.md | 15 -- cookbooks/ark/README.md | 10 +- cookbooks/ark/libraries/default.rb | 1 - cookbooks/ark/libraries/matchers.rb | 44 ----- .../ark/libraries/sevenzip_command_builder.rb | 4 +- cookbooks/ark/metadata.json | 2 +- cookbooks/ark/metadata.rb | 16 ++ cookbooks/ark/recipes/default.rb | 4 +- cookbooks/ark/resources/default.rb | 12 +- .../{default => }/add_to_path.sh.erb | 0 cookbooks/dmg/CHANGELOG.md | 142 --------------- cookbooks/dmg/CONTRIBUTING.md | 2 - cookbooks/dmg/README.md | 149 ---------------- cookbooks/dmg/metadata.json | 1 - cookbooks/dmg/recipes/default.rb | 20 --- cookbooks/dmg/resources/package.rb | 102 ----------- cookbooks/git/.foodcritic | 1 - cookbooks/git/CHANGELOG.md | 57 ++++++ cookbooks/git/MAINTAINERS.md | 15 -- cookbooks/git/README.md | 58 +++--- cookbooks/git/attributes/default.rb | 12 +- cookbooks/git/libraries/helpers.rb | 7 +- cookbooks/git/libraries/matchers.rb | 16 -- .../git/libraries/provider_git_client.rb | 6 - .../git/libraries/provider_git_client_osx.rb | 14 +- .../libraries/provider_git_client_package.rb | 5 - .../libraries/provider_git_client_source.rb | 26 +-- .../libraries/provider_git_client_windows.rb | 6 +- .../git/libraries/provider_git_service.rb | 8 +- .../libraries/provider_git_service_xinetd.rb | 55 ------ cookbooks/git/metadata.json | 2 +- cookbooks/git/metadata.rb | 26 +++ cookbooks/git/recipes/default.rb | 2 +- cookbooks/git/recipes/package.rb | 13 +- cookbooks/git/recipes/server.rb | 2 +- cookbooks/git/recipes/windows.rb | 2 +- cookbooks/git/resources/config.rb | 8 +- .../default/sv-git-daemon-log-run.erb | 2 - .../templates/default/sv-git-daemon-run.erb | 3 - .../templates/{default => }/git-xinetd.d.erb | 0 cookbooks/golang/CHANGELOG.md | 98 ++++++++++ cookbooks/golang/CONTRIBUTING.md | 4 + cookbooks/golang/README.md | 77 ++++++++ cookbooks/golang/attributes/default.rb | 15 ++ cookbooks/golang/metadata.json | 1 + cookbooks/golang/metadata.rb | 20 +++ cookbooks/golang/recipes/default.rb | 30 ++++ cookbooks/golang/resources/default.rb | 167 ++++++++++++++++++ cookbooks/golang/resources/package.rb | 52 ++++++ cookbooks/golang/templates/golang.sh.erb | 3 + site-cookbooks/kosmos-bitcoin/metadata.rb | 2 +- 55 files changed, 670 insertions(+), 716 deletions(-) delete mode 100644 cookbooks/ark/.foodcritic delete mode 100644 cookbooks/ark/MAINTAINERS.md delete mode 100644 cookbooks/ark/libraries/matchers.rb create mode 100644 cookbooks/ark/metadata.rb rename cookbooks/ark/templates/{default => }/add_to_path.sh.erb (100%) delete mode 100644 cookbooks/dmg/CHANGELOG.md delete mode 100644 cookbooks/dmg/CONTRIBUTING.md delete mode 100644 cookbooks/dmg/README.md delete mode 100644 cookbooks/dmg/metadata.json delete mode 100644 cookbooks/dmg/recipes/default.rb delete mode 100644 cookbooks/dmg/resources/package.rb delete mode 100644 cookbooks/git/.foodcritic delete mode 100644 cookbooks/git/MAINTAINERS.md delete mode 100644 cookbooks/git/libraries/matchers.rb delete mode 100644 cookbooks/git/libraries/provider_git_service_xinetd.rb create mode 100644 cookbooks/git/metadata.rb delete mode 100644 cookbooks/git/templates/default/sv-git-daemon-log-run.erb delete mode 100644 cookbooks/git/templates/default/sv-git-daemon-run.erb rename cookbooks/git/templates/{default => }/git-xinetd.d.erb (100%) create mode 100644 cookbooks/golang/CHANGELOG.md create mode 100644 cookbooks/golang/CONTRIBUTING.md create mode 100644 cookbooks/golang/README.md create mode 100644 cookbooks/golang/attributes/default.rb create mode 100644 cookbooks/golang/metadata.json create mode 100644 cookbooks/golang/metadata.rb create mode 100644 cookbooks/golang/recipes/default.rb create mode 100644 cookbooks/golang/resources/default.rb create mode 100644 cookbooks/golang/resources/package.rb create mode 100644 cookbooks/golang/templates/golang.sh.erb diff --git a/Berksfile b/Berksfile index 288f290..7ffb698 100644 --- a/Berksfile +++ b/Berksfile @@ -32,12 +32,12 @@ cookbook 'build-essential', '~> 8.2.1' cookbook 'mysql', '~> 8.5.1' # cookbook 'postgresql', '= 7.1.8' cookbook 'apt', '~> 7.3.0' -cookbook 'git', '= 6.0.0' +cookbook 'git', '>= 6.0.0' cookbook 'hostsfile', '= 2.4.5' cookbook 'ohai', '~> 5.2.5' cookbook 'nodejs', '~> 5.0.0' cookbook 'timezone_iii', '= 1.0.4' -cookbook 'ark', '= 3.1.0' +cookbook 'ark', '>= 3.1.0' cookbook 'logrotate', '= 2.2.0' cookbook 'openssl', '~> 8.5.5' cookbook 'ntp', '= 3.4.0' @@ -51,5 +51,5 @@ cookbook 'ipfs', ref: 'v0.4.1' cookbook 'elasticsearch', '= 4.2.0' cookbook 'java', '~> 4.3.0' - cookbook 'ulimit', '~> 1.0.0' +cookbook 'golang', '~> 4.1.0' diff --git a/Berksfile.lock b/Berksfile.lock index 985d29b..1e3996b 100644 --- a/Berksfile.lock +++ b/Berksfile.lock @@ -4,14 +4,15 @@ DEPENDENCIES application_git (= 1.1.0) application_javascript (~> 1.0.0) apt (~> 7.3.0) - ark (= 3.1.0) + ark (>= 3.1.0) build-essential (~> 8.2.1) chef-sugar (= 3.3.0) compat_resource (= 12.19.0) composer (~> 2.6.1) elasticsearch (= 4.2.0) firewall (~> 2.6.3) - git (= 6.0.0) + git (>= 6.0.0) + golang (~> 4.1.0) homebrew (= 3.0.0) hostname (= 0.4.2) hostsfile (= 2.4.5) @@ -67,10 +68,8 @@ GRAPH poise-javascript (~> 1.0) poise-service (~> 1.0) apt (7.3.0) - ark (3.1.0) - build-essential (>= 0.0.0) + ark (5.0.0) seven_zip (>= 0.0.0) - windows (>= 0.0.0) build-essential (8.2.1) mingw (>= 1.1) seven_zip (>= 0.0.0) @@ -80,7 +79,6 @@ GRAPH apt (>= 0.0.0) php (>= 0.0.0) windows (>= 0.0.0) - dmg (4.1.1) elasticsearch (4.2.0) apt (>= 0.0.0) ark (>= 0.0.0) @@ -88,10 +86,9 @@ GRAPH yum (>= 0.0.0) firewall (2.6.5) chef-sugar (>= 0.0.0) - git (6.0.0) - build-essential (>= 0.0.0) - dmg (>= 0.0.0) - yum-epel (>= 0.0.0) + git (10.0.0) + golang (4.1.0) + ark (~> 5.0) homebrew (3.0.0) hostname (0.4.2) hostsfile (>= 0.0.0) diff --git a/cookbooks/ark/.foodcritic b/cookbooks/ark/.foodcritic deleted file mode 100644 index b9f8767..0000000 --- a/cookbooks/ark/.foodcritic +++ /dev/null @@ -1 +0,0 @@ -~FC016 diff --git a/cookbooks/ark/CHANGELOG.md b/cookbooks/ark/CHANGELOG.md index 0639bc9..4e02c20 100644 --- a/cookbooks/ark/CHANGELOG.md +++ b/cookbooks/ark/CHANGELOG.md @@ -2,6 +2,27 @@ This file is used to list changes made in each version of the ark cookbook. +## 5.0.0 (2020-01-02) + +- Require Chef Infra Client 14+ and remove the need for the build_essential dependency - [@tas50](https://github.com/tas50) +- Use Ruby classes in resource properties - [@tas50](https://github.com/tas50) +- Simplify the platform check logic - [@tas50](https://github.com/tas50) +- Remove the .foocritic file - [@tas50](https://github.com/tas50) +- Remove long_description and recipe metadata - [@tas50](https://github.com/tas50) +- Expand testing - [@tas50](https://github.com/tas50) +- Remove Ubuntu 14.04 testing - [@tas50](https://github.com/tas50) + +## 4.0.0 (2018-07-25) + +- Support append_env_path property on Windows, which increases the minimum required Chef release to Chef 13.4 + +## 3.1.1 (2018-07-24) + +- Remove ChefSpec matchers since these are autogenerated now +- Update specs to the latest platform versions +- Remove template out of defaults directory +- Remove dependency on the Windows cookbook + ## 3.1.0 (2017-05-06) - Ensure the dependencies get installed on Chef 13 Amazon Linux systems @@ -12,7 +33,7 @@ This file is used to list changes made in each version of the ark cookbook. - 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/MAINTAINERS.md b/cookbooks/ark/MAINTAINERS.md deleted file mode 100644 index 645ed14..0000000 --- a/cookbooks/ark/MAINTAINERS.md +++ /dev/null @@ -1,15 +0,0 @@ - - -# Maintainers - -This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead. - -# Project Maintainer -* [Tim Smith](https://github.com/tas50) - -# Maintainers -* [Jennifer Davis](https://github.com/sigje) -* [Tim Smith](https://github.com/tas50) -* [Thom May](https://github.com/thommay) diff --git a/cookbooks/ark/README.md b/cookbooks/ark/README.md index 42f7cb6..35309a3 100644 --- a/cookbooks/ark/README.md +++ b/cookbooks/ark/README.md @@ -25,7 +25,7 @@ The `ark` resource will: 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. +For remote files ark supports URLs using the [remote_file](http://docs.chef.io/resource_remote_file.html) resource. Local files are accessed with the `file://` syntax. ## Requirements @@ -36,7 +36,7 @@ At this time ark only handles files available from URLs using the [remote_file]( - Fedora - FreeBSD - SmartOS -- Mac OS X +- macOS - openSUSE / SUSE Linux Enterprises - Windows @@ -44,13 +44,11 @@ Should work on common Unix/Linux systems with typical userland utilities like ta ### Chef -- Chef 12.7+ +- Chef 14+ ### Cookbooks -- build-essential - seven_zip -- windows ## Attributes @@ -66,7 +64,7 @@ Customize the attributes to suit site specific conventions and defaults. ## Resources -- `ark` - does the extract/build/configure +- `ark` - does the extract/build/configure ### Actions diff --git a/cookbooks/ark/libraries/default.rb b/cookbooks/ark/libraries/default.rb index 24b09e6..635695c 100644 --- a/cookbooks/ark/libraries/default.rb +++ b/cookbooks/ark/libraries/default.rb @@ -58,7 +58,6 @@ module Ark new_resource.path = defaults.path new_resource.release_file = defaults.release_file end - # rubocop:enable Metrics/AbcSize def set_put_paths new_resource.extension = defaults.extension diff --git a/cookbooks/ark/libraries/matchers.rb b/cookbooks/ark/libraries/matchers.rb deleted file mode 100644 index aa8901b..0000000 --- a/cookbooks/ark/libraries/matchers.rb +++ /dev/null @@ -1,44 +0,0 @@ - -if defined?(ChefSpec) - ChefSpec.define_matcher :ark - - 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 diff --git a/cookbooks/ark/libraries/sevenzip_command_builder.rb b/cookbooks/ark/libraries/sevenzip_command_builder.rb index 7319a0e..2482ac6 100644 --- a/cookbooks/ark/libraries/sevenzip_command_builder.rb +++ b/cookbooks/ark/libraries/sevenzip_command_builder.rb @@ -25,9 +25,7 @@ module Ark end def sevenzip_command - if resource.strip_components <= 0 - return sevenzip_command_builder(resource.path, 'x') - end + return sevenzip_command_builder(resource.path, 'x') if resource.strip_components <= 0 tmpdir = make_temp_directory.tr('/', '\\') cmd = sevenzip_command_builder(tmpdir, 'x') diff --git a/cookbooks/ark/metadata.json b/cookbooks/ark/metadata.json index a531332..cdbcc1c 100644 --- a/cookbooks/ark/metadata.json +++ b/cookbooks/ark/metadata.json @@ -1 +1 @@ -{"name":"ark","version":"3.1.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.7+\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.7"]],"ohai_version":[]} \ No newline at end of file +{"name":"ark","version":"5.0.0","description":"Provides a custom resource for installing runtime artifacts in a predictable fashion","long_description":"","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":{"seven_zip":">= 0.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/ark","issues_url":"https://github.com/chef-cookbooks/ark/issues","chef_version":[[">= 14.0"]],"ohai_version":[]} \ No newline at end of file diff --git a/cookbooks/ark/metadata.rb b/cookbooks/ark/metadata.rb new file mode 100644 index 0000000..1f4bb50 --- /dev/null +++ b/cookbooks/ark/metadata.rb @@ -0,0 +1,16 @@ +name 'ark' +maintainer 'Chef Software, Inc.' +maintainer_email 'cookbooks@chef.io' +license 'Apache-2.0' +description 'Provides a custom resource for installing runtime artifacts in a predictable fashion' +version '5.0.0' + +%w(ubuntu debian redhat centos suse opensuse opensuseleap scientific oracle amazon windows mac_os_x smartos freebsd).each do |os| + supports os +end + +depends 'seven_zip' # for windows os + +source_url 'https://github.com/chef-cookbooks/ark' +issues_url 'https://github.com/chef-cookbooks/ark/issues' +chef_version '>= 14.0' diff --git a/cookbooks/ark/recipes/default.rb b/cookbooks/ark/recipes/default.rb index 9a482aa..cd3d43a 100644 --- a/cookbooks/ark/recipes/default.rb +++ b/cookbooks/ark/recipes/default.rb @@ -18,6 +18,6 @@ # limitations under the License. # -package node['ark']['package_dependencies'] unless %w(windows mac_os_x).include?(node['platform_family']) +package node['ark']['package_dependencies'] unless platform_family?('windows', 'mac_os_x') -include_recipe 'seven_zip' if node['platform_family'] == 'windows' +include_recipe 'seven_zip' if platform_family?('windows') diff --git a/cookbooks/ark/resources/default.rb b/cookbooks/ark/resources/default.rb index 3bcb4c4..1551df2 100644 --- a/cookbooks/ark/resources/default.rb +++ b/cookbooks/ark/resources/default.rb @@ -83,8 +83,16 @@ action :install do action :nothing end - # usually on windows there is no central directory with executables where the applications are linked - unless node['platform_family'] == 'windows' + if platform_family?('windows') + # usually on windows there is no central directory with executables where the applications are linked + # so ignore has_binaries for now + + # Add to PATH permanently on Windows if append_env_path + windows_path "#{new_resource.path}/bin" do + action :add + only_if { new_resource.append_env_path } + end + else # symlink binaries new_resource.has_binaries.each do |bin| link ::File.join(new_resource.prefix_bin, ::File.basename(bin)) do diff --git a/cookbooks/ark/templates/default/add_to_path.sh.erb b/cookbooks/ark/templates/add_to_path.sh.erb similarity index 100% rename from cookbooks/ark/templates/default/add_to_path.sh.erb rename to cookbooks/ark/templates/add_to_path.sh.erb diff --git a/cookbooks/dmg/CHANGELOG.md b/cookbooks/dmg/CHANGELOG.md deleted file mode 100644 index a5f10e0..0000000 --- a/cookbooks/dmg/CHANGELOG.md +++ /dev/null @@ -1,142 +0,0 @@ -# dmg Cookbook CHANGELOG - -This file is used to list changes made in each version of the dmg cookbook. - -## 4.1.1 (2018-04-06) - -- The dmg_package resource is now included in Chef 14 and this cookbook has been deprecated. We highly recommend updating to Chef 14 so you can use this resource without the need for a cookbook dependency. -- Validate the type field in the resource -- Remove the now autogenerated ChefSpec matchers - -## 4.1.0 (2017-11-15) - -- Adds allow_untrusted property for older packages that aren't signed -- Resolve Chef 14 deprecation warnings -- Minor testing updates and cleanup - -## 4.0.0 (2017-04-27) - -- Converted the existing LWRP to a custom resource which increases the required chef-client release to 12.5+ -- Added Test Kitchen config with private atlas boxes for 10.10 and 10.11 -- Added a test recipe to installed Tunnelblick -- Added an Inspec test to confirm that Tunnelblick actually installs -- Remove unused attributes and the entire attributes file -- Add a warning if you include the default recipe on your runlist -- Update specs to run on 10.12 and against the test recipe since dmg::default is empty and the existing spec tested nothing - -## 3.1.1 (2017-04-11) - -- Cookstyle updates -- Test with Local Delivery and not Rake -- Update apache2 license string -- Remove foodcritic exclusions - -## 3.1.0 (2017-01-18) - -- Fixed pkg,mpkg installation when it was using mounted app name while it was actually mounted under different name for some applications -- Cookstyle fixes - -## 3.0.0 (2016-09-06) - -- Add chef_version metadata -- Run the specs against a mock of OS X -- Testing updates -- Require Chef 12+ - -## v2.4.0 (2016-04-26) - -- Added support for local .dmg files with the file property. See the readme for details -- Resolved all rubocop warnings - -## v2.3.0 (2015-10-20) - -- Add new headers property to the LWRP for custom http headers. See the readme for more information -- Removed pivotal tracker example in the readme -- Added travis and cookbook version badges to the readme -- Added a .foodcritic file to exclude rules -- Updated chefignore and .gitignore files -- Updated platforms in Test Kitchen -- Added standard Rubocop file -- Updated Travis to test using ChefDK for the latest deps -- Added a Berksfile -- Updated contributing and testing docs -- Updated Gemfile with the latest testing deps -- Added maintainers.md and maintainers.toml -- Added rakefile for simplified testing -- Added source_url and issues_url metadata -- Added basic converge chefspec - -## v2.2.2 (2014-11-12) - -- # 23, add chefspec matchers - -## v2.2.0 (2014-02-25) - -- [COOK-4285] Accept long EULAs - -## v2.1.4 (2014-01-26) - -- [COOK-4157] - dmg_package LWRP broken due to "puts" instead of "system" -- [COOK-4065] - dmg cookbook outputs the name of packages when checking if they are installed - -## v2.1.2 - -Cleaning up merge errors - -## v2.1.0 - -### Bug - -- **[COOK-3946](https://tickets.chef.io/browse/COOK-3946)** - Syntax error in resources/package.rb -- **[COOK-2672](https://tickets.chef.io/browse/COOK-2672)** - EULA for package is displayed instead accepted - -## v2.0.8 - -Adding a Chef 10 compatibility check in provider - -## v2.0.6 - -# BUG - -- [COOK-3302] - Sometimes hdiutil detach fails due to cfprefsd running in background - - # IMPROVEMENT - -- Adding foodcritic and rubocop to .travis.yml - -## v2.0.4 - -### Bug - -- **[COOK-3331](https://tickets.chef.io/browse/COOK-3331)** - Fix an issue where `dmg_package` with no source raises an exception - -## v2.0.2 - -### Bug - -- **[COOK-3578](https://tickets.chef.io/browse/COOK-3578)** - Support `package_id`s with spaces -- **[COOK-3302](https://tickets.chef.io/browse/COOK-3302)** - Fix an issue where `hdiutil detach` fails due to `cfprefsd` running in the background - -## v2.0.0 - -### Bug - -- **[COOK-3389](https://tickets.chef.io/browse/COOK-3389)** - Use `rsync` instead of `cp` (potentially a breaking change on some systems) - -## v1.1.0 - -- [COOK-1847] - accept owner parameter for installing packages - -## v1.0.0 - -- [COOK-852] - Support "pkg" in addition to "mpkg" package types - -## v0.7.0 - -- [COOK-854] - use `cp -R` instead of `cp -r` -- [COOK-855] - specify a file or directory to check for prior install - -## v0.6.0 - -- option to install software that is an .mpkg inside a .dmg -- ignore failure on chmod in case mode is already set, or is root owned diff --git a/cookbooks/dmg/CONTRIBUTING.md b/cookbooks/dmg/CONTRIBUTING.md deleted file mode 100644 index ef2f2b8..0000000 --- a/cookbooks/dmg/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Please refer to -https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD diff --git a/cookbooks/dmg/README.md b/cookbooks/dmg/README.md deleted file mode 100644 index 86f95aa..0000000 --- a/cookbooks/dmg/README.md +++ /dev/null @@ -1,149 +0,0 @@ -The dmg_package resource is now included in Chef 14 and this cookbook has been deprecated. We highly recommend updating to Chef 14 so you can use this resource without the need for a cookbook dependency. - -# dmg Cookbook - -[![Build Status](https://travis-ci.org/chef-cookbooks/dmg.svg?branch=master)](https://travis-ci.org/chef-cookbooks/dmg) [![Cookbook Version](https://img.shields.io/cookbook/v/dmg.svg)](https://supermarket.chef.io/cookbooks/dmg) - -Resource to install OS X applications (.app) from dmg files. - -## Requirements - -### Platforms - -- macOS - -### Chef - -- Chef 12.5+ - -### Cookbooks - -- none - -## Resources/Providers - -### dmg_package - -This resource will install a DMG "Package". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef: - -```bash -knife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb -``` - -Optionally, the LWRP can install an "mpkg" or "pkg" package using installer(8). - -#### Actions - -- :install - Installs the application. - -#### Parameter attributes: - -- `app` - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications. -- `source` - remote URL for the dmg to download if specified. Default is nil. -- `file` - local dmg full file path. Default is nil. -- `owner` - owner that should own the package installation. -- `destination` - directory to copy the .app into. Default is /Applications. -- `checksum` - sha256 checksum of the dmg to download. Default is nil. -- `type` - type of package, "app", "pkg" or "mpkg". Default is "app". When using "pkg" or "mpkg", the destination must be /Applications. -- `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute. -- `package_id` - Package id registered with pkgutil when a pkg or mpkg is installed -- `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces. -- `dmg_passphrase` - Specify a passphrase to use to unencrypt the dmg while mounting. -- `accept_eula` - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false. -- `headers` - Allows custom HTTP headers (like cookies) to be set on the remote_file resource. -- `allow_untrusted` - Allows packages with untrusted certs to be installed. - -#### Examples - -Install `/Applications/Tunnelblick.app` from the primary download site. - -```ruby -dmg_package 'Tunnelblick' do - source 'https://tunnelblick.net/release/Tunnelblick_3.7.0_build_4790.dmg' - checksum '5053038aa8caf7dea66dcab11d6d240672216e6546eff4c2622e216c61af85e5' - action :install -end -``` - -Install Google Chrome. Uses the `dmg_name` because the application name has spaces. Installs in `/Applications/Google Chrome.app`. - -```ruby -dmg_package 'Google Chrome' do - dmg_name 'googlechrome' - source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg' - checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a' - action :install -end -``` - -Install Dropbox. Uses `volumes_dir` because the mounted directory is different than the name of the application directory. Installs in `/Applications/Dropbox.app`. - -```ruby -dmg_package 'Dropbox' do - volumes_dir 'Dropbox Installer' - source 'http://www.dropbox.com/download?plat=mac' - checksum 'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13' - action :install -end -``` - -Install MacIrssi to `~/Applications` from the local file downloaded to the cache path into an Applications directory in the current user's home directory. Chef should run as a non-root user for this. - -```ruby -directory "#{ENV['HOME']}/Applications" - -dmg_package 'MacIrssi' do - destination "#{ENV['HOME']}/Applications" - action :install -end -``` - -Install Virtualbox to `/Applications` from the .mpkg: - -```ruby -dmg_package 'Virtualbox' do - source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg' - type 'mpkg' -end -``` - -Install pgAdmin to `/Applications` and automatically accept the EULA: - -```ruby -dmg_package 'pgAdmin3' do - source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg' - checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9' - accept_eula true -end -``` - -Install Silverlight, with idempotence check based on pkgutil: - -```ruby -dmg_package 'Silerlight' do - source 'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg' - type 'pkg' - checksum '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc' - package_id 'com.microsoft.installSilverlightPlugin' -end -``` - -## License & Authors - -**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io)) - -**Copyright:** 2011-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. -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. -``` diff --git a/cookbooks/dmg/metadata.json b/cookbooks/dmg/metadata.json deleted file mode 100644 index 7c3f674..0000000 --- a/cookbooks/dmg/metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"dmg","version":"4.1.1","description":"Resource for installing macOS applications from DMGs","long_description":"The dmg_package resource is now included in Chef 14 and this cookbook has been deprecated. We highly recommend updating to Chef 14 so you can use this resource without the need for a cookbook dependency.\n\n# dmg Cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/dmg.svg?branch=master)](https://travis-ci.org/chef-cookbooks/dmg) [![Cookbook Version](https://img.shields.io/cookbook/v/dmg.svg)](https://supermarket.chef.io/cookbooks/dmg)\n\nResource to install OS X applications (.app) from dmg files.\n\n## Requirements\n\n### Platforms\n\n- macOS\n\n### Chef\n\n- Chef 12.5+\n\n### Cookbooks\n\n- none\n\n## Resources/Providers\n\n### dmg_package\n\nThis resource will install a DMG \"Package\". It will retrieve the DMG from a remote URL, mount it using OS X's `hdid`, copy the application (.app directory) to the specified destination (/Applications), and detach the image using `hdiutil`. The dmg file will be stored in the `Chef::Config[:file_cache_path]`. If you want to install an application that has already been downloaded (not using the `source` parameter), copy it to the appropriate location. You can find out what directory this is with the following command on the node to run chef:\n\n```bash\nknife exec -E 'p Chef::Config[:file_cache_path]' -c /etc/chef/client.rb\n```\n\nOptionally, the LWRP can install an \"mpkg\" or \"pkg\" package using installer(8).\n\n#### Actions\n\n- :install - Installs the application.\n\n#### Parameter attributes:\n\n- `app` - This is the name of the application used by default for the /Volumes directory and the .app directory copied to /Applications.\n- `source` - remote URL for the dmg to download if specified. Default is nil.\n- `file` - local dmg full file path. Default is nil.\n- `owner` - owner that should own the package installation.\n- `destination` - directory to copy the .app into. Default is /Applications.\n- `checksum` - sha256 checksum of the dmg to download. Default is nil.\n- `type` - type of package, \"app\", \"pkg\" or \"mpkg\". Default is \"app\". When using \"pkg\" or \"mpkg\", the destination must be /Applications.\n- `volumes_dir` - Directory under /Volumes where the dmg is mounted. Not all dmgs are mounted into a /Volumes location matching the name of the dmg. If not specified, this will use the name attribute.\n- `package_id` - Package id registered with pkgutil when a pkg or mpkg is installed\n- `dmg_name` - Specify the name of the dmg if it is not the same as `app`, or if the name has spaces.\n- `dmg_passphrase` - Specify a passphrase to use to unencrypt the dmg while mounting.\n- `accept_eula` - Specify whether to accept the EULA. Certain dmgs require acceptance of EULA before mounting. Can be true or false, defaults to false.\n- `headers` - Allows custom HTTP headers (like cookies) to be set on the remote_file resource.\n- `allow_untrusted` - Allows packages with untrusted certs to be installed.\n\n#### Examples\n\nInstall `/Applications/Tunnelblick.app` from the primary download site.\n\n```ruby\ndmg_package 'Tunnelblick' do\n source 'https://tunnelblick.net/release/Tunnelblick_3.7.0_build_4790.dmg'\n checksum '5053038aa8caf7dea66dcab11d6d240672216e6546eff4c2622e216c61af85e5'\n action :install\nend\n```\n\nInstall Google Chrome. Uses the `dmg_name` because the application name has spaces. Installs in `/Applications/Google Chrome.app`.\n\n```ruby\ndmg_package 'Google Chrome' do\n dmg_name 'googlechrome'\n source 'https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg'\n checksum '7daa2dc5c46d9bfb14f1d7ff4b33884325e5e63e694810adc58f14795165c91a'\n action :install\nend\n```\n\nInstall Dropbox. Uses `volumes_dir` because the mounted directory is different than the name of the application directory. Installs in `/Applications/Dropbox.app`.\n\n```ruby\ndmg_package 'Dropbox' do\n volumes_dir 'Dropbox Installer'\n source 'http://www.dropbox.com/download?plat=mac'\n checksum 'b4ea620ca22b0517b75753283ceb82326aca8bc3c86212fbf725de6446a96a13'\n action :install\nend\n```\n\nInstall MacIrssi to `~/Applications` from the local file downloaded to the cache path into an Applications directory in the current user's home directory. Chef should run as a non-root user for this.\n\n```ruby\ndirectory \"#{ENV['HOME']}/Applications\"\n\ndmg_package 'MacIrssi' do\n destination \"#{ENV['HOME']}/Applications\"\n action :install\nend\n```\n\nInstall Virtualbox to `/Applications` from the .mpkg:\n\n```ruby\ndmg_package 'Virtualbox' do\n source 'http://dlc.sun.com.edgesuite.net/virtualbox/4.0.8/VirtualBox-4.0.8-71778-OSX.dmg'\n type 'mpkg'\nend\n```\n\nInstall pgAdmin to `/Applications` and automatically accept the EULA:\n\n```ruby\ndmg_package 'pgAdmin3' do\n source 'http://wwwmaster.postgresql.org/redir/198/h/pgadmin3/release/v1.12.3/osx/pgadmin3-1.12.3.dmg'\n checksum '9435f79d5b52d0febeddfad392adf82db9df159196f496c1ab139a6957242ce9'\n accept_eula true\nend\n```\n\nInstall Silverlight, with idempotence check based on pkgutil:\n\n```ruby\ndmg_package 'Silerlight' do\n source 'http://silverlight.dlservice.microsoft.com/download/D/C/2/DC2D5838-9138-4D25-AA92-52F61F7C51E6/runtime/Silverlight.dmg'\n type 'pkg'\n checksum '6d4a0ad4552d9815531463eb3f467fb8cf4bffcc'\n package_id 'com.microsoft.installSilverlightPlugin'\nend\n```\n\n## License & Authors\n\n**Author:** Cookbook Engineering Team ([cookbooks@chef.io](mailto:cookbooks@chef.io))\n\n**Copyright:** 2011-2017, Chef Software, Inc.\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":{"mac_os_x":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/dmg","issues_url":"https://github.com/chef-cookbooks/dmg/issues","chef_version":[[">= 12.5"]],"ohai_version":[]} \ No newline at end of file diff --git a/cookbooks/dmg/recipes/default.rb b/cookbooks/dmg/recipes/default.rb deleted file mode 100644 index 2690d0c..0000000 --- a/cookbooks/dmg/recipes/default.rb +++ /dev/null @@ -1,20 +0,0 @@ -# -# Cookbook:: dmg -# Recipe:: default -# -# Copyright:: 2011-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. -# 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. -# - -Chef::Log.warn('The dmg::default recipe does not contain any resources and should not be applied to a node') diff --git a/cookbooks/dmg/resources/package.rb b/cookbooks/dmg/resources/package.rb deleted file mode 100644 index 71b5327..0000000 --- a/cookbooks/dmg/resources/package.rb +++ /dev/null @@ -1,102 +0,0 @@ -# -# Author:: Joshua Timberman () -# Cookbook:: dmg -# Resource:: package -# -# Copyright:: 2011-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. -# 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. -# - -property :app, String, name_property: true -property :source, String -property :file, String -property :owner, String -property :destination, String, default: '/Applications' -property :checksum, String -property :volumes_dir, String -property :dmg_name, String -property :type, String, default: 'app', equal_to: %w(app pkg mpkg) -property :installed, [true, false], default: false, desired_state: false -property :package_id, String -property :dmg_passphrase, String -property :accept_eula, [true, false], default: false -property :headers, [Hash, nil], default: nil -property :allow_untrusted, [true, false], default: false - -load_current_value do |new_resource| - if ::File.directory?("#{new_resource.destination}/#{new_resource.app}.app") - Chef::Log.info "Already installed; to upgrade, remove \"#{new_resource.destination}/#{new_resource.app}.app\"" - installed true - elsif shell_out("pkgutil --pkgs='#{new_resource.package_id}'").exitstatus == 0 - Chef::Log.info "Already installed; to upgrade, try \"sudo pkgutil --forget '#{new_resource.package_id}'\"" - installed true - else - installed false - end -end - -action :install do - unless current_resource.installed - - volumes_dir = new_resource.volumes_dir ? new_resource.volumes_dir : new_resource.app - dmg_name = new_resource.dmg_name ? new_resource.dmg_name : new_resource.app - - dmg_file = if new_resource.file.nil? - "#{Chef::Config[:file_cache_path]}/#{dmg_name}.dmg" - else - new_resource.file - end - - remote_file "#{dmg_file} - #{new_resource.name}" do - path dmg_file - source new_resource.source - headers new_resource.headers if new_resource.headers - checksum new_resource.checksum if new_resource.checksum - end if new_resource.source - - passphrase_cmd = new_resource.dmg_passphrase ? "-passphrase #{new_resource.dmg_passphrase}" : '' - ruby_block "attach #{dmg_file}" do - block do - cmd = shell_out("hdiutil imageinfo #{passphrase_cmd} '#{dmg_file}' | grep -q 'Software License Agreement: true'") - software_license_agreement = cmd.exitstatus == 0 - raise "Requires EULA Acceptance; add 'accept_eula true' to package resource" if software_license_agreement && !new_resource.accept_eula - accept_eula_cmd = new_resource.accept_eula ? 'echo Y | PAGER=true' : '' - shell_out!("#{accept_eula_cmd} hdiutil attach #{passphrase_cmd} '#{dmg_file}' -mountpoint '/Volumes/#{volumes_dir}' -quiet") - end - not_if "hdiutil info #{passphrase_cmd} | grep -q 'image-path.*#{dmg_file}'" - end - - case new_resource.type - when 'app' - execute "rsync --force --recursive --links --perms --executability --owner --group --times '/Volumes/#{volumes_dir}/#{new_resource.app}.app' '#{new_resource.destination}'" do - user new_resource.owner if new_resource.owner - end - - declare_resource(:file, "#{new_resource.destination}/#{new_resource.app}.app/Contents/MacOS/#{new_resource.app}") do - mode '755' - ignore_failure true - end - when 'mpkg', 'pkg' - install_cmd = "installation_file=$(ls '/Volumes/#{volumes_dir}' | grep '.#{new_resource.type}$') && sudo installer -pkg \"/Volumes/#{volumes_dir}/$installation_file\" -target /" - install_cmd += ' -allowUntrusted' if new_resource.allow_untrusted - - execute install_cmd do - # Prevent cfprefsd from holding up hdiutil detach for certain disk images - environment('__CFPREFERENCES_AVOID_DAEMON' => '1') - end - end - - execute "hdiutil detach '/Volumes/#{volumes_dir}' || hdiutil detach '/Volumes/#{volumes_dir}' -force" - end -end diff --git a/cookbooks/git/.foodcritic b/cookbooks/git/.foodcritic deleted file mode 100644 index b9f8767..0000000 --- a/cookbooks/git/.foodcritic +++ /dev/null @@ -1 +0,0 @@ -~FC016 diff --git a/cookbooks/git/CHANGELOG.md b/cookbooks/git/CHANGELOG.md index d2f2797..324797b 100644 --- a/cookbooks/git/CHANGELOG.md +++ b/cookbooks/git/CHANGELOG.md @@ -2,6 +2,63 @@ This file is used to list changes made in each version of the git cookbook. +## 10.0.0 (2019-10-16) + +- Add testing for CentOS 8, openSUSE 15, Ubuntu 18.04 in Travis +- Require Chef Infra Client 14 or later so we can drop the dependency on build-essential +- Resolve multiple cookstyle warnings + +## 9.0.1 (2018-06-02) + +- Update the platforms we test on +- Remove extra attr_accessor in config and requires +- Bump git version to 2.17.1 to resolve CVE + +## 9.0.0 (2018-03-08) + +- Remove the dependency on the homebrew cookbook by not automatically installing homebrew in the git resource on macOS systems. Homebrew needs to be setup before this resource runs and that should probably be the very first thing you do on a macOS system +- Use the build_essential resource instead of including the default recipe. This requires version 5.0 or later of the build-essential cookbook and allows us to use the build_essential resource that will be built into Chef 14 when that ships +- Remove extra includes in the resources that weren't necessary +- Updated testing to include Fedora 27, Ubuntu 18.04, Debian 9, macOS 10.12, and Windows 2016 + +## 8.0.1 (2018-02-10) + +- Resolve the new FC118 foodcritic warning +- Remove the ChefSpec matchers which are auto generated now +- Resolve FC104 warning + +## 8.0.0 (2017-09-01) + +### Breaking Changes + +- macOS resource now properly executes and uses homebrew to install git instead of dmg and packages posted to SourceForge +- Default to Git 2.9.5 now, which properly compiles on Fedora / Amazon Linux + +## Other Changes + +- Fixed support for Amazon Linux on Chef 13 +- Unified the package setup for source installs which fixes Amazon/Fedora +- Removed an entirely duplicate service provider +- Remove unused runit templates +- Properly fail when we're on an unsupported platform + +## 7.0.0 (2017-09-01) + +- Remove support for RHEL 5 which removes the need for the yum-epel cookbook +- Move templates out of the default directory now that we require Chef 12 +- Remove support for Ubuntu 10.04 +- Remove the version requirement on mac_os_x in the metadata +- Move maintainer information to the readme +- Expand Travis testing + +## 6.1.0 (2017-05-30) + +- Test with Local Delivery and not Rake +- Remove EOL platforms from the kitchen configs +- Use a SPDX standard license string +- Updated default versions documented in README to fix Issue #120. +- Remove class_eval and require chef 12.7+ + ## 6.0.0 (2017-02-14) - Fail on deprecations is now enabled so we're fully Chef 13 compatible diff --git a/cookbooks/git/MAINTAINERS.md b/cookbooks/git/MAINTAINERS.md deleted file mode 100644 index 645ed14..0000000 --- a/cookbooks/git/MAINTAINERS.md +++ /dev/null @@ -1,15 +0,0 @@ - - -# Maintainers - -This file lists how this cookbook project is maintained. When making changes to the system, this file tells you who needs to review your patch - you need a review from an existing maintainer for the cookbook to provide a :+1: on your pull request. Additionally, you need to not receive a veto from a Lieutenant or the Project Lead. - -Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) for details on the process and how to become a maintainer or the project lead. - -# Project Maintainer -* [Tim Smith](https://github.com/tas50) - -# Maintainers -* [Jennifer Davis](https://github.com/sigje) -* [Tim Smith](https://github.com/tas50) -* [Thom May](https://github.com/thommay) diff --git a/cookbooks/git/README.md b/cookbooks/git/README.md index 2196803..6619a1d 100644 --- a/cookbooks/git/README.md +++ b/cookbooks/git/README.md @@ -20,17 +20,17 @@ The following platforms have been tested with Test Kitchen: |---------------+-------| | centos-7 | X | |---------------+-------| +| centos-8 | X | +|---------------+-------| | fedora | X | |---------------+-------| -| debian-7 | X | +| debian-9 | X | |---------------+-------| -| debian-8 | X | -|---------------+-------| -| ubuntu-14.04 | X | +| debian-10 | X | |---------------+-------| | ubuntu-16.04 | X | |---------------+-------| -| openSUSE 13.2 | X | +| ubuntu-18.04 | X | |---------------+-------| | openSUSE Leap | X | |---------------+-------| @@ -38,13 +38,11 @@ The following platforms have been tested with Test Kitchen: ### Chef -- Chef 12.5+ +- Chef 14+ ### Cookbooks -- depends 'build-essential' - For compiling from source -- depends 'dmg' - For macOS Support -- depends 'yum-epel' - For older RHEL platform_family support +- none ## Usage @@ -60,6 +58,8 @@ Add `git::default`, `git::source` or `git::windows` to your run_list OR add `dep The `git_client` resource manages the installation of a Git client on a machine. +`Note`: on macOS systems homebrew must first be installed on the system before running this resource. Prior to version 9.0 of this cookbook homebrew was automatically installed. + #### Example ```ruby @@ -68,6 +68,17 @@ git_client 'default' do end ``` +#### Example of source install + +```ruby +git_client 'source' do + provider Chef::Provider::GitClient::Source + source_version '2.14.2' + source_checksum 'a03a12331d4f9b0f71733db9f47e1232d4ddce00e7f2a6e20f6ec9a19ce5ff61' + action :install +end +``` + ### git_config The `git_config` resource manages the configuration of Git client on a machine. @@ -96,23 +107,15 @@ Currently, there are distinct sets of resource properties, used by the providers - `source_prefix` - Defaults to '/usr/local' - `source_url` - Defaults to a calculated URL based on source_version -- `source_version` - Defaults to 2.7.4 +- `source_version` - Defaults to 2.8.1 - `source_use_pcre` - configure option for build. Defaults to false -- `source_checksum` - Defaults to a known value for the 2.7.4 source tarball - -# used by OSX package providers - -- `osx_dmg_app_name` - Defaults to 'git-2.7.1-intel-universal-mavericks' -- `osx_dmg_package_id` - Defaults to 'GitOSX.Installer.git271.git.pkg' -- `osx_dmg_volumes_dir` - Defaults to 'Git 2.7.1 Mavericks Intel Universal' -- `osx_dmg_url` - Defaults to Sourceforge -- `osx_dmg_checksum` - Defaults to the value for 2.7.1 +- `source_checksum` - Defaults to a known value for the 2.8.1 source tarball # used by the Windows package providers - `windows_display_name` - Windows display name - `windows_package_url` - Defaults to the Internet -- `windows_package_checksum` - Defaults to the value for 2.7.4 +- `windows_package_checksum` - Defaults to the value for 2.8.1 ## Recipes @@ -127,11 +130,6 @@ This cookbook ships with ready to use, attribute driven recipes that utilize the - `node['git']['checksum']` - package SHA256 checksum - `node['git']['display_name']` - `windows_package` resource Display Name (makes the package install idempotent) -### Mac OS X - -- `node['git']['osx_dmg']['url']` - URL to git package -- `node['git']['osx_dmg']['checksum']` - package SHA256 checksum - ### Linux - `node['git']['prefix']` - git install directory @@ -140,11 +138,13 @@ This cookbook ships with ready to use, attribute driven recipes that utilize the - `node['git']['checksum']` - tarball SHA256 checksum - `node['git']['use_pcre']` - if true, builds git with PCRE enabled -## License & Authors +## Maintainers -- Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io)) -- Author:: Sean OMeara ([sean@sean.io](mailto:sean@sean.io)) -- Copyright:: 2009-2017, Chef Software, Inc. +This cookbook is maintained by Chef's Community Cookbook Engineering team. Our goal is to improve cookbook quality and to aid the community in contributing to cookbooks. To learn more about our team, process, and design goals see our [team documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/COOKBOOK_TEAM.MD). To learn more about contributing to cookbooks like this see our [contributing documentation](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD), or if you have general questions about this cookbook come chat with us in #cookbok-engineering on the [Chef Community Slack](http://community-slack.chef.io/) + +## License + +**Copyright:** 2009-2017, Chef Software, Inc. ``` Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cookbooks/git/attributes/default.rb b/cookbooks/git/attributes/default.rb index a8b339e..7dc1b1a 100644 --- a/cookbooks/git/attributes/default.rb +++ b/cookbooks/git/attributes/default.rb @@ -3,7 +3,7 @@ # Cookbook:: git # Attributes:: default # -# Copyright:: 2008-2016, Chef Software, Inc. +# Copyright:: 2008-2019, 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. @@ -29,17 +29,11 @@ when 'windows' end default['git']['url'] = 'https://github.com/git-for-windows/git/releases/download/v%{version}.windows.1/Git-%{version}-%{architecture}-bit.exe' default['git']['display_name'] = "Git version #{node['git']['version']}" -when 'mac_os_x' - default['git']['osx_dmg']['app_name'] = 'git-2.8.1-intel-universal-mavericks' - default['git']['osx_dmg']['volumes_dir'] = 'Git 2.8.1 Mavericks Intel Universal' - default['git']['osx_dmg']['package_id'] = 'GitOSX.Installer.git281Universal.git.pkg' - default['git']['osx_dmg']['url'] = 'http://sourceforge.net/projects/git-osx-installer/files/git-2.8.1-intel-universal-mavericks.dmg/download' - default['git']['osx_dmg']['checksum'] = 'c2912895a1e2018d9be4c646765d511f7c82e0114275505dbd13d1ac70c62023' else default['git']['prefix'] = '/usr/local' - default['git']['version'] = '2.8.1' + default['git']['version'] = '2.17.1' default['git']['url'] = 'https://nodeload.github.com/git/git/tar.gz/v%{version}' - default['git']['checksum'] = 'e08503ecaf5d3ac10c40f22871c996a392256c8d038d16f52ebf974cba29ae42' + default['git']['checksum'] = '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a' default['git']['use_pcre'] = false end diff --git a/cookbooks/git/libraries/helpers.rb b/cookbooks/git/libraries/helpers.rb index bedde84..7bf29b3 100644 --- a/cookbooks/git/libraries/helpers.rb +++ b/cookbooks/git/libraries/helpers.rb @@ -3,9 +3,8 @@ module GitCookbook # linux packages default to distro offering def parsed_package_name return new_resource.package_name if new_resource.package_name - return 'git-core' if node['platform'] == 'ubuntu' && node['platform_version'].to_f < 10.10 - return 'developer/versioning/git' if node['platform'] == 'omnios' - return 'scmgit' if node['platform'] == 'smartos' + return 'developer/versioning/git' if platform?('smartos') + return 'scmgit' if platform?('smartos') 'git' end @@ -21,7 +20,7 @@ module GitCookbook def parsed_source_checksum return new_resource.source_checksum if new_resource.source_checksum - '8d53703d75890c03e26a915c7af3b7b98d8cfb94382f685a9bcbee1eeaec47b4' # 2.7.4 tarball + '690f12cc5691e5adaf2dd390eae6f5acce68ae0d9bd9403814f8a1433833f02a' # 2.17.1 tarball end # windows diff --git a/cookbooks/git/libraries/matchers.rb b/cookbooks/git/libraries/matchers.rb deleted file mode 100644 index 25ed8df..0000000 --- a/cookbooks/git/libraries/matchers.rb +++ /dev/null @@ -1,16 +0,0 @@ -if defined?(ChefSpec) - ChefSpec.define_matcher(:git_client) - ChefSpec.define_matcher(:git_service) - - def set_git_config(resource_name) # rubocop:disable Style/AccessorMethodName - ChefSpec::Matchers::ResourceMatcher.new(:git_config, :set, resource_name) - end - - def install_git_client(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:git_client, :install, resource_name) - end - - def install_git_service(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:git_service, :install, resource_name) - end -end diff --git a/cookbooks/git/libraries/provider_git_client.rb b/cookbooks/git/libraries/provider_git_client.rb index 41d7cfd..84aaa45 100644 --- a/cookbooks/git/libraries/provider_git_client.rb +++ b/cookbooks/git/libraries/provider_git_client.rb @@ -1,12 +1,6 @@ class Chef class Provider class GitClient < Chef::Provider::LWRPBase - use_inline_resources - - def whyrun_supported? - true - end - include GitCookbook::Helpers end end diff --git a/cookbooks/git/libraries/provider_git_client_osx.rb b/cookbooks/git/libraries/provider_git_client_osx.rb index db604c9..cb3dea3 100644 --- a/cookbooks/git/libraries/provider_git_client_osx.rb +++ b/cookbooks/git/libraries/provider_git_client_osx.rb @@ -2,20 +2,10 @@ class Chef class Provider class GitClient class Osx < Chef::Provider::GitClient - include Chef::DSL::IncludeRecipe - - provides :git_client, os: 'mac_os_x' + provides :git_client, platform: 'mac_os_x' action :install do - dmg_package 'GitOSX-Installer' do - app new_resource.osx_dmg_app_name - package_id new_resource.osx_dmg_package_id - volumes_dir new_resource.osx_dmg_volumes_dir - source new_resource.osx_dmg_url - checksum new_resource.osx_dmg_checksum - type 'pkg' - action :install - end + package 'git' end action :delete do diff --git a/cookbooks/git/libraries/provider_git_client_package.rb b/cookbooks/git/libraries/provider_git_client_package.rb index 8c750e3..38db86d 100644 --- a/cookbooks/git/libraries/provider_git_client_package.rb +++ b/cookbooks/git/libraries/provider_git_client_package.rb @@ -2,14 +2,9 @@ class Chef class Provider class GitClient class Package < Chef::Provider::GitClient - include Chef::DSL::IncludeRecipe - provides :git_client, os: 'linux' action :install do - # FIXME: rhel 5 - include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5 - # Software installation package "#{new_resource.name} :create #{parsed_package_name}" do package_name parsed_package_name diff --git a/cookbooks/git/libraries/provider_git_client_source.rb b/cookbooks/git/libraries/provider_git_client_source.rb index 6ab8bc7..7add0a9 100644 --- a/cookbooks/git/libraries/provider_git_client_source.rb +++ b/cookbooks/git/libraries/provider_git_client_source.rb @@ -2,30 +2,16 @@ class Chef class Provider class GitClient class Source < Chef::Provider::GitClient - include Chef::DSL::IncludeRecipe - action :install do - return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" unless platform_family?('rhel', 'suse', 'fedora', 'debian') + raise "#{node['platform']} is not supported by the git_client source resource" unless platform_family?('rhel', 'suse', 'fedora', 'debian', 'amazon') - include_recipe 'build-essential' - include_recipe 'yum-epel' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 5 + build_essential 'install compilation tools for git' # move this to attributes. case node['platform_family'] - when 'fedora' - pkgs = %w(tar openssl-devel libcurl-devel expat-devel perl-ExtUtils-MakeMaker) - when 'rhel' - case node['platform_version'].to_i - when 5 - pkgs = %w(tar expat-devel gettext-devel curl-devel openssl-devel zlib-devel) - pkgs += %w( pcre-devel ) if new_resource.source_use_pcre - when 6, 7 - pkgs = %w(tar expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel) - pkgs += %w( pcre-devel ) if new_resource.source_use_pcre - else - pkgs = %w(expat-devel gettext-devel curl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel) if node['platform'] == 'amazon' - pkgs += %w( pcre-devel ) if new_resource.source_use_pcre - end + when 'rhel', 'fedora', 'amazon' + pkgs = %w(tar expat-devel gettext-devel libcurl-devel openssl-devel perl-ExtUtils-MakeMaker zlib-devel) + pkgs += %w( pcre-devel ) if new_resource.source_use_pcre when 'debian' pkgs = %w(libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev) pkgs += %w( libpcre3-dev ) if new_resource.source_use_pcre @@ -52,7 +38,7 @@ class Chef command <<-COMMAND (mkdir git-#{new_resource.source_version} && tar -zxf git-#{new_resource.source_version}.tar.gz -C git-#{new_resource.source_version} --strip-components 1) (cd git-#{new_resource.source_version} && make prefix=#{new_resource.source_prefix} #{additional_make_params} install) - COMMAND + COMMAND not_if "git --version | grep #{new_resource.source_version}" not_if "#{new_resource.source_prefix}/bin/git --version | grep #{new_resource.source_version}" end diff --git a/cookbooks/git/libraries/provider_git_client_windows.rb b/cookbooks/git/libraries/provider_git_client_windows.rb index 305cdd2..8b88e1a 100644 --- a/cookbooks/git/libraries/provider_git_client_windows.rb +++ b/cookbooks/git/libraries/provider_git_client_windows.rb @@ -3,8 +3,6 @@ class Chef class Provider class GitClient class Windows < Chef::Provider::GitClient - include Chef::DSL::IncludeRecipe - provides :git_client, os: 'windows' action :install do @@ -22,7 +20,7 @@ class Chef else ENV['ProgramW6432'] || ENV['ProgramFiles'] end - GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd".freeze + GIT_PATH = "#{PROGRAM_FILES}\\Git\\Cmd" # COOK-3482 - windows_path resource doesn't change the current process # environment variables. Therefore, git won't actually be on the PATH @@ -36,7 +34,7 @@ class Chef end windows_path GIT_PATH do - notifies :create, 'ruby_block[Add Git Path]', :immediately + notifies :run, 'ruby_block[Add Git Path]', :immediately action :add end end diff --git a/cookbooks/git/libraries/provider_git_service.rb b/cookbooks/git/libraries/provider_git_service.rb index 7f74e90..b7b200a 100644 --- a/cookbooks/git/libraries/provider_git_service.rb +++ b/cookbooks/git/libraries/provider_git_service.rb @@ -1,19 +1,13 @@ class Chef class Provider class GitClient < Chef::Provider::LWRPBase - use_inline_resources - - def whyrun_supported? - true - end - include Chef::DSL::IncludeRecipe include GitCookbook::Helpers provides :git_service, os: 'linux' action :create do - return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if node['platform'] == 'windows' + return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if platform?('windows') include_recipe 'git' diff --git a/cookbooks/git/libraries/provider_git_service_xinetd.rb b/cookbooks/git/libraries/provider_git_service_xinetd.rb deleted file mode 100644 index 74b524e..0000000 --- a/cookbooks/git/libraries/provider_git_service_xinetd.rb +++ /dev/null @@ -1,55 +0,0 @@ -class Chef - class Provider - class GitClient < Chef::Provider::LWRPBase - use_inline_resources - - def whyrun_supported? - true - end - - include Chef::DSL::IncludeRecipe - include GitCookbook::Helpers - - action :create do - return "#{node['platform']} is not supported by the #{cookbook_name}::#{recipe_name} recipe" if node['platform'] == 'windows' - - include_recipe 'git' - - directory new_resource.service_base_path do - owner 'root' - group 'root' - mode '0755' - end - - case node['platform_family'] - when 'debian' - package 'xinetd' - when 'rhel' - package 'git-daemon' - else - log 'Platform requires setting up a git daemon service script.' - log "Hint: /usr/bin/git daemon --export-all --user=nobody --group=daemon --base-path=#{new_resource.service_base_path}" - return - end - - template '/etc/xinetd.d/git' do - backup false - source 'git-xinetd.d.erb' - owner 'root' - group 'root' - mode '0644' - variables( - git_daemon_binary: value_for_platform_family( - 'debian' => '/usr/lib/git-core/git-daemon', - 'rhel' => '/usr/libexec/git-core/git-daemon' - ) - ) - end - - service 'xinetd' do - action [:enable, :restart] - end - end - end - end -end diff --git a/cookbooks/git/metadata.json b/cookbooks/git/metadata.json index 28f80e7..e8249be 100644 --- a/cookbooks/git/metadata.json +++ b/cookbooks/git/metadata.json @@ -1 +1 @@ -{"name":"git","version":"6.0.0","description":"Installs git and/or sets up a Git server daemon","long_description":"# Git Cookbook\n\n[![Build Status](https://travis-ci.org/chef-cookbooks/git.svg?branch=master)](https://travis-ci.org/chef-cookbooks/git) [![Cookbook Version](https://img.shields.io/cookbook/v/git.svg)](https://supermarket.chef.io/cookbooks/git)\n\nInstalls git_client from package or source. Optionally sets up a git service under xinetd.\n\n## Scope\n\nThis cookbook is concerned with the Git SCM utility. It does not address ecosystem tooling or related projects.\n\n## Requirements\n\n### Platforms\n\nThe following platforms have been tested with Test Kitchen:\n\n```\n|---------------+-------|\n| centos-6 | X |\n|---------------+-------|\n| centos-7 | X |\n|---------------+-------|\n| fedora | X |\n|---------------+-------|\n| debian-7 | X |\n|---------------+-------|\n| debian-8 | X |\n|---------------+-------|\n| ubuntu-14.04 | X |\n|---------------+-------|\n| ubuntu-16.04 | X |\n|---------------+-------|\n| openSUSE 13.2 | X |\n|---------------+-------|\n| openSUSE Leap | X |\n|---------------+-------|\n```\n\n### Chef\n\n- Chef 12.5+\n\n### Cookbooks\n\n- depends 'build-essential' - For compiling from source\n- depends 'dmg' - For macOS Support\n- depends 'yum-epel' - For older RHEL platform_family support\n\n## Usage\n\nAdd `git::default`, `git::source` or `git::windows` to your run_list OR add `depends 'git', '~> 4.3'` to your cookbook's metadata.rb. include_recipe one of the recipes from your cookbook OR use the git_client resource directly, the same way you'd use core Chef resources (file, template, directory, package, etc).\n\n## Resources Overview\n\n- `git_client`: Manages a Git client installation on a machine. Acts as a singleton when using the (default) package provider. Source provider available as well.\n- `git_service`: Sets up a Git service via xinetd. WARNING: This is insecure and will probably be removed in the future\n- `git_config`: Sets up Git configuration on a node.\n\n### git_client\n\nThe `git_client` resource manages the installation of a Git client on a machine.\n\n#### Example\n\n```ruby\ngit_client 'default' do\n action :install\nend\n```\n\n### git_config\n\nThe `git_config` resource manages the configuration of Git client on a machine.\n\n#### Example\n\n```ruby\ngit_config 'url.https://github.com/.insteadOf' do\n value 'git://github.com/'\n scope 'system'\n options '--add'\nend\n```\n\n#### Properties\n\nCurrently, there are distinct sets of resource properties, used by the providers for source, package, macos, and windows.\n\n# used by linux package providers\n\n- `package_name` - Package name to install on Linux machines. Defaults to a calculated value based on platform.\n- `package_version` - Defaults to nil.\n- `package_action` - Defaults to `:install`\n\n# used by source providers\n\n- `source_prefix` - Defaults to '/usr/local'\n- `source_url` - Defaults to a calculated URL based on source_version\n- `source_version` - Defaults to 2.7.4\n- `source_use_pcre` - configure option for build. Defaults to false\n- `source_checksum` - Defaults to a known value for the 2.7.4 source tarball\n\n# used by OSX package providers\n\n- `osx_dmg_app_name` - Defaults to 'git-2.7.1-intel-universal-mavericks'\n- `osx_dmg_package_id` - Defaults to 'GitOSX.Installer.git271.git.pkg'\n- `osx_dmg_volumes_dir` - Defaults to 'Git 2.7.1 Mavericks Intel Universal'\n- `osx_dmg_url` - Defaults to Sourceforge\n- `osx_dmg_checksum` - Defaults to the value for 2.7.1\n\n# used by the Windows package providers\n\n- `windows_display_name` - Windows display name\n- `windows_package_url` - Defaults to the Internet\n- `windows_package_checksum` - Defaults to the value for 2.7.4\n\n## Recipes\n\nThis cookbook ships with ready to use, attribute driven recipes that utilize the `git_client` and `git_service` resources. As of cookbook 4.x, they utilize the same attributes layout scheme from the 3.x. Due to some overlap, it is currently impossible to simultaneously install the Git client as a package and from source by using the \"manipulate a the node attributes and run a recipe\" technique. If you need both, you'll need to utilize the git_client resource in a recipe.\n\n## Attributes\n\n### Windows\n\n- `node['git']['version']` - git version to install\n- `node['git']['url']` - URL to git package\n- `node['git']['checksum']` - package SHA256 checksum\n- `node['git']['display_name']` - `windows_package` resource Display Name (makes the package install idempotent)\n\n### Mac OS X\n\n- `node['git']['osx_dmg']['url']` - URL to git package\n- `node['git']['osx_dmg']['checksum']` - package SHA256 checksum\n\n### Linux\n\n- `node['git']['prefix']` - git install directory\n- `node['git']['version']` - git version to install\n- `node['git']['url']` - URL to git tarball\n- `node['git']['checksum']` - tarball SHA256 checksum\n- `node['git']['use_pcre']` - if true, builds git with PCRE enabled\n\n## License & Authors\n\n- Author:: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io))\n- Author:: Sean OMeara ([sean@sean.io](mailto:sean@sean.io))\n- Copyright:: 2009-2017, Chef Software, Inc.\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":{"amazon":">= 0.0.0","centos":">= 0.0.0","debian":">= 0.0.0","fedora":">= 0.0.0","freebsd":">= 0.0.0","mac_os_x":">= 10.6.0","omnios":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","smartos":">= 0.0.0","scientific":">= 0.0.0","suse":">= 0.0.0","opensuse":">= 0.0.0","opensuseleap":">= 0.0.0","ubuntu":">= 0.0.0","windows":">= 0.0.0"},"dependencies":{"build-essential":">= 0.0.0","dmg":">= 0.0.0","yum-epel":">= 0.0.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{"git":"Installs git","git::server":"Sets up a runit_service for git daemon","git::source":"Installs git from source"}} \ No newline at end of file +{"name":"git","version":"10.0.0","description":"Installs git and/or sets up a Git server daemon","long_description":"","maintainer":"Chef Software, Inc.","maintainer_email":"cookbooks@chef.io","license":"Apache-2.0","platforms":{"amazon":">= 0.0.0","centos":">= 0.0.0","debian":">= 0.0.0","fedora":">= 0.0.0","freebsd":">= 0.0.0","mac_os_x":">= 0.0.0","omnios":">= 0.0.0","oracle":">= 0.0.0","redhat":">= 0.0.0","smartos":">= 0.0.0","scientific":">= 0.0.0","suse":">= 0.0.0","opensuseleap":">= 0.0.0","ubuntu":">= 0.0.0","windows":">= 0.0.0"},"dependencies":{},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/chef-cookbooks/git","issues_url":"https://github.com/chef-cookbooks/git/issues","chef_version":[[">= 14"]],"ohai_version":[]} \ No newline at end of file diff --git a/cookbooks/git/metadata.rb b/cookbooks/git/metadata.rb new file mode 100644 index 0000000..f45a478 --- /dev/null +++ b/cookbooks/git/metadata.rb @@ -0,0 +1,26 @@ +name 'git' +maintainer 'Chef Software, Inc.' +maintainer_email 'cookbooks@chef.io' +license 'Apache-2.0' +description 'Installs git and/or sets up a Git server daemon' +version '10.0.0' + +supports 'amazon' +supports 'centos' +supports 'debian' +supports 'fedora' +supports 'freebsd' +supports 'mac_os_x' +supports 'omnios' +supports 'oracle' +supports 'redhat' +supports 'smartos' +supports 'scientific' +supports 'suse' +supports 'opensuseleap' +supports 'ubuntu' +supports 'windows' + +source_url 'https://github.com/chef-cookbooks/git' +issues_url 'https://github.com/chef-cookbooks/git/issues' +chef_version '>= 14' diff --git a/cookbooks/git/recipes/default.rb b/cookbooks/git/recipes/default.rb index bc7feed..da57fa5 100644 --- a/cookbooks/git/recipes/default.rb +++ b/cookbooks/git/recipes/default.rb @@ -2,7 +2,7 @@ # Cookbook:: git # Recipe:: default # -# Copyright:: 2008-2016, Chef Software, Inc. +# Copyright:: 2008-2019, 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. diff --git a/cookbooks/git/recipes/package.rb b/cookbooks/git/recipes/package.rb index e8812f6..af90138 100644 --- a/cookbooks/git/recipes/package.rb +++ b/cookbooks/git/recipes/package.rb @@ -2,7 +2,7 @@ # Cookbook:: git # Recipe:: package # -# Copyright:: 2008-2016, Chef Software, Inc. +# Copyright:: 2008-2019, Chef Software, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,17 +17,6 @@ # limitations under the License. case node['platform'] -when 'mac_os_x' - # FIXME: The resource has three distinct groups of properties used in - # different providers... should we make multiple resource types instead? - git_client 'default' do - osx_dmg_app_name node['git']['osx_dmg']['app_name'] - osx_dmg_package_id node['git']['osx_dmg']['package_id'] - osx_dmg_volumes_dir node['git']['osx_dmg']['volumes_dir'] - osx_dmg_url node['git']['osx_dmg']['url'] - osx_dmg_checksum node['git']['osx_dmg']['checksum'] - action :install - end when 'windows' include_recipe 'git::windows' else diff --git a/cookbooks/git/recipes/server.rb b/cookbooks/git/recipes/server.rb index 1567cbb..05ecb42 100644 --- a/cookbooks/git/recipes/server.rb +++ b/cookbooks/git/recipes/server.rb @@ -2,7 +2,7 @@ # Cookbook:: git # Recipe:: server # -# Copyright:: 2009-2016, Chef Software, Inc. +# Copyright:: 2009-2019, 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. diff --git a/cookbooks/git/recipes/windows.rb b/cookbooks/git/recipes/windows.rb index 7fd5882..13cd459 100644 --- a/cookbooks/git/recipes/windows.rb +++ b/cookbooks/git/recipes/windows.rb @@ -2,7 +2,7 @@ # Cookbook:: git # Recipe:: windows # -# Copyright:: 2008-2016, Chef Software, Inc. +# Copyright:: 2008-2019, 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. diff --git a/cookbooks/git/resources/config.rb b/cookbooks/git/resources/config.rb index 2f3d88c..3554bf0 100644 --- a/cookbooks/git/resources/config.rb +++ b/cookbooks/git/resources/config.rb @@ -1,4 +1,4 @@ -property :key, String, name_attribute: true +property :key, String, name_property: true property :value, String property :scope, equal_to: %w(local global system), default: 'global', desired_state: false property :path, String, desired_state: false @@ -6,10 +6,6 @@ property :user, String, desired_state: false property :group, String, desired_state: false property :options, String, desired_state: false -attr_accessor :exists - -require 'mixlib/shellout' - def initialize(*args) super @@ -38,7 +34,7 @@ action :set do end end -action_class.class_eval do +action_class do def config_cmd "git config --#{new_resource.scope}" end diff --git a/cookbooks/git/templates/default/sv-git-daemon-log-run.erb b/cookbooks/git/templates/default/sv-git-daemon-log-run.erb deleted file mode 100644 index a79a518..0000000 --- a/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec svlogd -tt ./main diff --git a/cookbooks/git/templates/default/sv-git-daemon-run.erb b/cookbooks/git/templates/default/sv-git-daemon-run.erb deleted file mode 100644 index f340a23..0000000 --- a/cookbooks/git/templates/default/sv-git-daemon-run.erb +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -exec 2>&1 -exec /usr/bin/git daemon <%= node['git']['server']['export_all'] ? '--export-all' : nil %> --user=nobody --group=daemon --syslog --base-path=<%= node["git"]["server"]["base_path"] %> <%= node["git"]["server"]["base_path"] %> diff --git a/cookbooks/git/templates/default/git-xinetd.d.erb b/cookbooks/git/templates/git-xinetd.d.erb similarity index 100% rename from cookbooks/git/templates/default/git-xinetd.d.erb rename to cookbooks/git/templates/git-xinetd.d.erb diff --git a/cookbooks/golang/CHANGELOG.md b/cookbooks/golang/CHANGELOG.md new file mode 100644 index 0000000..0313261 --- /dev/null +++ b/cookbooks/golang/CHANGELOG.md @@ -0,0 +1,98 @@ +# CHANGELOG for golang + +This file is used to list changes made in each version of golang. + +## 4.1.0 + +- Create a custom resource to install Go from source or by downloading a package + +## 4.0.0 + +- Update testing setup: + - Use Chef Workstation instead of Rubygems + - Includes dropping `foodcritic` in favor of current `cookstyle` + - Add more recent & current distro versions + - Add very basic unit tests + - Use GitHub Actions instead of Travis CI +- Refactor minitest to Inspec +- Refactor to use current style of Chef Custom Resource +- Update default version to Go v1.14.4 +- Use `build_essential` when building from source + - Requires Chef >= 14.0.0 +- Omit attempting to install `bzr` on CentOS 8, they do not have that package available +- Utilize default Chef order-of-operations instead of `notifies` +- Use `ark` resource to simplify download & installation of binary & source +- Clean up unnecessary env vars from source build +- Build from source per [official Go docs](https://golang.org/doc/install/source) +- Use native resources instead of shell commands when building from source +- Set `$PATH` in `golang.sh` so that the existing values are last, per general practice +- Tighten up `golang_package` so it does not perform actions at compile time, it uses `execute` in favor of `bash` resources, and in general is more Chef-y +- Update tests to validate that non-root users can install Go and Go packages +- Refactor attributes to add ability to install a version from source that differs from the packaged version (which is needed to build from source) + +## 3.0.0 + +- rename to `chef-golang` so that metadata name matches repositoriy name + +## 2.0.0 + +- change attribute namespace to `node['golang']` + +## 1.7.2 + +- Better chef12,13 support +- Ruby 2.3 +- Update gems, lint + +## 1.7.1 + +- Create a temporary directory + +## 1.7.0 + +- Golang 1.5 + +## 1.6.2 + +- Ability to install from source + +## 1.6.0 + +- Removed support for Ruby 1.9.3 + +## 1.5.1 + +- Fix testing with Vagrant, Test-Kitchen +- Golang 1.4 + +## 1.5.0 + +- Golang 1.3 + +## 1.4.0 + +- Add build action to LWRP +- Update default go version to 1.2.2 +- Add autodetection the platform architecture +- Change package location to `http://golang.org/dl/` + +## 1.3.0 + +## 1.2.0 + +## 1.1.0 + +- Added package LWRP +- Configurable `gopath` & `gobin` + +## 1.0.2 + +- Lets users easily specify another install dir + +## 1.0.1 + +- Avoid extra unpacked copy of Go + +## 1.0.0 + +- Initial release of golang diff --git a/cookbooks/golang/CONTRIBUTING.md b/cookbooks/golang/CONTRIBUTING.md new file mode 100644 index 0000000..a946aea --- /dev/null +++ b/cookbooks/golang/CONTRIBUTING.md @@ -0,0 +1,4 @@ +# Contributing + +Please refer to +[https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) diff --git a/cookbooks/golang/README.md b/cookbooks/golang/README.md new file mode 100644 index 0000000..4328d7d --- /dev/null +++ b/cookbooks/golang/README.md @@ -0,0 +1,77 @@ +# Golang (Go) Cookbook + +[![Cookbook Version](https://img.shields.io/cookbook/v/golang.svg?style=flat)](https://supermarket.chef.io/cookbooks/golang) +[![CI State](https://github.com/sous-chefs/golang/workflows/ci/badge.svg)](https://github.com/sous-chefs/golang/actions?query=workflow%3Aci) +[![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers) +[![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors) +[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) + +## Description + +Chef cookbook for the [Go programming language](http://golang.org/). + +## Requirements + +### Platform + +* Ubuntu >= 18.04 +* Debian >= 8 +* CentOS >= 7 + +## Usage + +### golang::default + +Include `golang` in your node's `run_list`: + +```json +{ + "name":"my_node", + "run_list": [ + "recipe[golang]" + ] +} +``` + +### golang::packages + +To install Go packages using node attributes add the packages to the `['golang']['packages']` attribute: + +```json +{ + "name":"my_node", + "golang": { + "packages": [ + "github.com/go-check/check" + ] + }, + "run_list": [ + "recipe[golang]" + ] +} +``` + +## Contributors + +This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false) + +### Backers + +Thank you to all our backers! + +![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40) + +### Sponsors + +Support this project by becoming a sponsor. Your logo will show up here with a link to your website. + +![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100) +![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100) diff --git a/cookbooks/golang/attributes/default.rb b/cookbooks/golang/attributes/default.rb new file mode 100644 index 0000000..6f049f7 --- /dev/null +++ b/cookbooks/golang/attributes/default.rb @@ -0,0 +1,15 @@ +# +# Cookbook:: golang +# Attribute:: default +# + +default['golang']['scm'] = true +default['golang']['scm_packages'] = value_for_platform( + 'centos' => { '>= 8' => %w(git mercurial) }, + 'default' => %w(git mercurial bzr) +) + +default['golang']['install_dir'] = '/usr/local' +default['golang']['gopath'] = '/opt/go' +default['golang']['gobin'] = '/opt/go/bin' +default['golang']['packages'] = [] diff --git a/cookbooks/golang/metadata.json b/cookbooks/golang/metadata.json new file mode 100644 index 0000000..2c1c376 --- /dev/null +++ b/cookbooks/golang/metadata.json @@ -0,0 +1 @@ +{"name":"golang","version":"4.1.0","description":"Installs go programming language","long_description":"","maintainer":"Sous Chefs","maintainer_email":"help@sous-chefs.org","license":"Apache-2.0","platforms":{"debian":">= 0.0.0","ubuntu":">= 0.0.0","redhat":">= 0.0.0","centos":">= 0.0.0","fedora":">= 0.0.0","amazon":">= 0.0.0","scientific":">= 0.0.0","oracle":">= 0.0.0"},"dependencies":{"ark":"~> 5.0"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/sous-chefs/golang","issues_url":"https://github.com/sous-chefs/golang/issues","chef_version":[[">= 14.0"]],"ohai_version":[]} \ No newline at end of file diff --git a/cookbooks/golang/metadata.rb b/cookbooks/golang/metadata.rb new file mode 100644 index 0000000..81e6bbb --- /dev/null +++ b/cookbooks/golang/metadata.rb @@ -0,0 +1,20 @@ +name 'golang' +maintainer 'Sous Chefs' +maintainer_email 'help@sous-chefs.org' +license 'Apache-2.0' +description 'Installs go programming language' +source_url 'https://github.com/sous-chefs/golang' +issues_url 'https://github.com/sous-chefs/golang/issues' +chef_version '>= 14.0' +version '4.1.0' + +supports 'debian' +supports 'ubuntu' +supports 'redhat' +supports 'centos' +supports 'fedora' +supports 'amazon' +supports 'scientific' +supports 'oracle' + +depends 'ark', '~> 5.0' diff --git a/cookbooks/golang/recipes/default.rb b/cookbooks/golang/recipes/default.rb new file mode 100644 index 0000000..91cec2d --- /dev/null +++ b/cookbooks/golang/recipes/default.rb @@ -0,0 +1,30 @@ +# +# Cookbook:: golang +# Recipe:: default +# +# Copyright:: 2013, Alexander Rozhnov +# +# 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. +# + +golang 'Install go' do + from_source node['golang']['from_source'] + version node['golang']['version'] if node['golang']['version'] # go version + source_version node['golang']['source_version'] if node['golang']['source_version'] # go version from source + owner node['golang']['owner'] if node['golang']['owner'] + group node['golang']['group'] if node['golang']['group'] +end + +node['golang']['packages'].each do |package| + golang_package package +end diff --git a/cookbooks/golang/resources/default.rb b/cookbooks/golang/resources/default.rb new file mode 100644 index 0000000..64c4d77 --- /dev/null +++ b/cookbooks/golang/resources/default.rb @@ -0,0 +1,167 @@ +# +# Cookbook:: golang +# Resource:: default +# +# Copyright:: 2020, Sous-chefs +# +# 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. +# + +# Install golang by compiling from source +property :from_source, [true, false], default: false + +# Base directory for go +property :install_dir, String, default: '/usr/local' +property :gopath, String, default: '/opt/go' +property :gobin, String, default: '/opt/go/bin' + +# Directory and file attributes +property :owner, String, default: 'root' +property :group, String, default: 'root' +property :directory_mode, String, default: '0755' + +# version to install +# ark input binaries and stuff download +# e.g. https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz +# https://dl.google.com/go/go1.14.4/linux-amd64.tar.gz +# https://golang.org/dl/go1.14.6.darwin-amd64.tar.gz +# https://golang.org/dl/go1.14.6.linux-amd64.tar.gz +property :url, String, default: 'https://golang.org/dl/goVERSION.OS-PLATFORM.tar.gz' +property :version, String, default: '1.14.4' + +# ark input source +# e.g. https://dl.google.com/go/go1.14.4.src.tar.gz +property :source_url, String, default: 'https://golang.org/dl/goVERSION.src.tar.gz' +property :source_version, String, default: '1.14.4' + +# installation script from the source repository +property :source_method, String, default: 'all.bash' + +# install SCM packages +property :scm, [true, false], default: true +property :scm_packages, [String, Array], default: %w(git mercurial) + +action_class do + def bin_url + return new_resource.url if property_is_set?(:url) + new_resource.url.sub(/PLATFORM/, platform).sub(/OS/, os).sub(/VERSION/, new_resource.version) + end + + def source_url + return new_resource.source_url if property_is_set?(:source_url) + new_resource.source_url.sub(/VERSION/, new_resource.source_version) + end + + def os + node['os'] + end + + def platform + node['kernel']['machine'] =~ /i.86/ ? '386' : 'amd64' + end +end + +action :install do + directory new_resource.gopath do + recursive true + owner new_resource.owner + group new_resource.group + mode new_resource.directory_mode + end + + directory new_resource.gobin do + recursive true + owner new_resource.owner + group new_resource.group + mode new_resource.directory_mode + end + + directory new_resource.install_dir do + recursive true + mode new_resource.directory_mode + end + + directory ::File.join(Chef::Config[:file_cache_path], 'go') do + recursive true + end + + template '/etc/profile.d/golang.sh' do + source 'golang.sh.erb' + mode new_resource.directory_mode + variables gobin: new_resource.gobin, + gopath: new_resource.gobin, + install_dir: new_resource.install_dir + end + + if new_resource.scm + apt_update do + only_if { platform_family? 'debian' } + end + package new_resource.scm_packages + end + + # pgk to install go binaries, doc, base packages + # ark is not idempotent by itself. Check to see if the go binary is the correct version + url = bin_url + ark 'go' do + url url + version new_resource.version + not_if "/usr/local/go-#{new_resource.version}/bin/go version | grep #{new_resource.version}" + end + + ##### SOURCE BUILD + + if new_resource.from_source + + directory ::File.join(new_resource.install_dir, 'go', 'bin') do + recursive true + mode new_resource.directory_mode + end + + build_essential + + file "#{new_resource.install_dir}/go" do + manage_symlink_source true + action :delete + only_if do + # Create idempotency by not deleting symlink if it points to source build + ::File.exist?("#{new_resource.install_dir}/go") && + ::File.ftype("#{new_resource.install_dir}/go") == 'link' && + ::File.readlink("#{new_resource.install_dir}/go") != "#{new_resource.install_dir}/go-source" + end + end + + url = source_url + ark 'go' do # resource with the same name, that's an issue. Source install + url url + version 'source' + action :put + release_file '/tmp/ark_release_file' + not_if "test -x #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} && #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} version | grep #{new_resource.source_version}" + end + + # see if build already done + # converge_by if not done + execute 'build-golang' do + cwd "#{new_resource.install_dir}/go/src" + command "./#{new_resource.source_method}" + environment({ + # Use the package-installed Go as the bootstrap version b/c Go is built with Go + GOROOT_BOOTSTRAP: "#{new_resource.install_dir}/go-#{new_resource.version}", + GOROOT: "#{new_resource.install_dir}/go", + GOBIN: "#{new_resource.install_dir}/go/bin", + }) + not_if "test -x #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} && #{::File.join(new_resource.install_dir, 'go', 'bin', 'go')} version | grep #{new_resource.source_version}" + end + end +end diff --git a/cookbooks/golang/resources/package.rb b/cookbooks/golang/resources/package.rb new file mode 100644 index 0000000..4090444 --- /dev/null +++ b/cookbooks/golang/resources/package.rb @@ -0,0 +1,52 @@ +# +# Cookbook:: golang +# Resource:: default +# + +default_action :install + +gocache = '/tmp/go' + +action :install do + execute "go get #{new_resource.name}" do + user node['golang']['owner'] + group node['golang']['group'] + environment({ + PATH: "#{node['golang']['install_dir']}/go/bin:#{node['golang']['gobin']}:" \ + '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + GOPATH: node['golang']['gopath'], + GOBIN: node['golang']['gobin'], + GOCACHE: gocache, + }) + end +end + +action :update do + execute "go get -u #{new_resource.name}" do + user node['golang']['owner'] + group node['golang']['group'] + environment({ + PATH: "#{node['golang']['install_dir']}/go/bin:#{node['golang']['gobin']}:" \ + '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + GOPATH: node['golang']['gopath'], + GOBIN: node['golang']['gobin'], + GOCACHE: gocache, + }) + end +end + +action :build do + execute "go build -work -x #{new_resource.name}" do + user node['golang']['owner'] + group node['golang']['group'] + cwd gocache + environment({ + PATH: "#{node['golang']['install_dir']}/go/bin:#{node['golang']['gobin']}:" \ + '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + HOME: "/home/#{node['golang']['owner']}", + GOPATH: node['golang']['gopath'], + GOBIN: node['golang']['gobin'], + GOCACHE: gocache, + }) + end +end diff --git a/cookbooks/golang/templates/golang.sh.erb b/cookbooks/golang/templates/golang.sh.erb new file mode 100644 index 0000000..41db116 --- /dev/null +++ b/cookbooks/golang/templates/golang.sh.erb @@ -0,0 +1,3 @@ +export PATH="<%= ::File.join(@install_dir, 'go', 'bin') %>:<%= @gobin %>:$PATH" +export GOPATH=<%= @gopath %> +export GOBIN=<%= @gobin %> diff --git a/site-cookbooks/kosmos-bitcoin/metadata.rb b/site-cookbooks/kosmos-bitcoin/metadata.rb index 37f95f4..59b2b93 100644 --- a/site-cookbooks/kosmos-bitcoin/metadata.rb +++ b/site-cookbooks/kosmos-bitcoin/metadata.rb @@ -20,4 +20,4 @@ chef_version '>= 14.0' # source_url 'https://github.com//kosmos-bitcoin' depends "ark" -depends "kosmos_encfs" +depends "golang"