Skip to content

Commit

Permalink
Merge pull request #3 from RoboticCheese/jdh-linux
Browse files Browse the repository at this point in the history
Add support for a bunch of Linux platforms
  • Loading branch information
hartmantis committed Jun 28, 2015
2 parents d0d35e4 + 47ac530 commit a231d5a
Show file tree
Hide file tree
Showing 23 changed files with 531 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .kitchen.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ platforms:
- name: macosx
driver:
name: localhost
- name: ubuntu-14-04-x64
- name: debian-7-0-x64
# TODO: https://github.com/test-kitchen/test-kitchen/issues/683
# - name: freebsd-10-1-x64
# driver:
# username: freebsd
# transport:
# username: freebsd
- name: centos-7-0-x64
- name: fedora-21-x64
9 changes: 9 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ platforms:
- name: windows-8
driver:
box: roboticcheese/windows-8
- name: ubuntu-14.04
- name: debian-7.8
- name: freebsd-10.1
driver:
ssh:
shell: "'/bin/sh'"
- name: centos-7.1
- name: fedora-21
- name: opensuse-13.1

suites:
- name: default
Expand Down
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ A Chef cookbook for installing GIMP.
Requirements
============

This cookbook currently supports OS X and Windows only. Additional platform
support is coming.
This cookbook currently supports OS X, Windows, Debian/Ubuntu, FreeBSD, the
assorted RHEL variants, and OpenSUSE. It uses the dmg, windows, apt, freebsd,
and zypper community cookbooks to enable that platform support.

Usage
=====
Expand Down Expand Up @@ -79,6 +80,27 @@ Provider for Mac OS X platforms.

Provider for Windows platforms.

***Chef::Provider::GimpApp::Debian***

Provider for Debian and Ubuntu platforms.

***Chef::Provider::GimpApp::Freebsd***

Provider for FreeBSD platforms.

***Chef::Provider::GimpApp::Rhel***

Provider for Red Hat/CentOS/Scientific/Amazon/Fedora platforms.

***Chef::Provider::GimpApp::Opensuse***

Provider for OpenSUSE platforms.

***Chef::Provider::GimpApp::Package***

A generic provider for any platform that can install GIMP with a Chef package
resource.

***Chef::Provider::GimpApp***

A parent provider for all the platform-specific providers to subclass.
Expand Down
4 changes: 4 additions & 0 deletions libraries/provider_gimp_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

require 'chef/provider/lwrp_base'
require_relative 'resource_gimp_app'
require_relative 'provider_gimp_app_debian'
require_relative 'provider_gimp_app_freebsd'
require_relative 'provider_gimp_app_mac_os_x'
require_relative 'provider_gimp_app_opensuse'
require_relative 'provider_gimp_app_rhel'
require_relative 'provider_gimp_app_windows'

class Chef
Expand Down
49 changes: 49 additions & 0 deletions libraries/provider_gimp_app_debian.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Encoding: UTF-8
#
# Cookbook Name:: gimp
# Library:: provider_gimp_app_debian
#
# Copyright 2015 Jonathan Hartman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/provider/lwrp_base'
require 'chef/dsl/include_recipe'
require_relative 'provider_gimp_app'
require_relative 'provider_gimp_app_package'

class Chef
class Provider
class GimpApp < Provider::LWRPBase
# A GIMP provider for Ubuntu/Debian.
#
# @author Jonathan Hartman <j@p4nt5.com>
class Debian < GimpApp::Package
include Chef::DSL::IncludeRecipe

private

#
# Update APT's cache before trying to install the GIMP package.
#
# (see GimpApp::Package#install!)
#
def install!
include_recipe 'apt'
super
end
end
end
end
end
49 changes: 49 additions & 0 deletions libraries/provider_gimp_app_freebsd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Encoding: UTF-8
#
# Cookbook Name:: gimp
# Library:: provider_gimp_app_freebsd
#
# Copyright 2015 Jonathan Hartman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/provider/lwrp_base'
require 'chef/dsl/include_recipe'
require_relative 'provider_gimp_app'
require_relative 'provider_gimp_app_package'

class Chef
class Provider
class GimpApp < Provider::LWRPBase
# A GIMP provider for FreeBSD.
#
# @author Jonathan Hartman <j@p4nt5.com>
class Freebsd < GimpApp::Package
include Chef::DSL::IncludeRecipe

private

#
# Update Ports before trying to install the GIMP package.
#
# (see GimpApp::Package#install!)
#
def install!
include_recipe 'freebsd::portsnap'
super
end
end
end
end
end
47 changes: 47 additions & 0 deletions libraries/provider_gimp_app_opensuse.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Encoding: UTF-8
#
# Cookbook Name:: gimp
# Library:: provider_gimp_app_opensuse
#
# Copyright 2015 Jonathan Hartman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/provider/lwrp_base'
require 'chef/dsl/include_recipe'
require_relative 'provider_gimp_app'
require_relative 'provider_gimp_app_package'

class Chef
class Provider
class GimpApp < Provider::LWRPBase
# A GIMP provider for OpenSUSE.
#
# @author Jonathan Hartman <j@p4nt5.com>
class Opensuse < GimpApp::Package
include Chef::DSL::IncludeRecipe

#
# Update Zypper before trying to install the GIMP package.
#
# (see GimpApp::Package#install!)
#
def install!
include_recipe 'zypper'
super
end
end
end
end
end
54 changes: 54 additions & 0 deletions libraries/provider_gimp_app_package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Encoding: UTF-8
#
# Cookbook Name:: gimp
# Library:: provider_gimp_app_package
#
# Copyright 2015 Jonathan Hartman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/provider/lwrp_base'
require_relative 'provider_gimp_app'

class Chef
class Provider
class GimpApp < Provider::LWRPBase
# A generic GIMP provider for package-based platforms.
#
# @author Jonathan Hartman <j@p4nt5.com>
class Package < GimpApp
private

#
# (see GimpApp#install!)
#
def install!
package 'gimp' do
version new_resource.version
action :install
end
end

#
# (see GimpApp#remove!)
#
def remove!
package 'gimp' do
action :remove
end
end
end
end
end
end
35 changes: 35 additions & 0 deletions libraries/provider_gimp_app_rhel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Encoding: UTF-8
#
# Cookbook Name:: gimp
# Library:: provider_gimp_app_rhel
#
# Copyright 2015 Jonathan Hartman
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/provider/lwrp_base'
require_relative 'provider_gimp_app'
require_relative 'provider_gimp_app_package'

class Chef
class Provider
class GimpApp < Provider::LWRPBase
# A GIMP provider for Red Hat and its variants.
#
# @author Jonathan Hartman <j@p4nt5.com>
class Rhel < GimpApp::Package
end
end
end
end
17 changes: 17 additions & 0 deletions libraries/provider_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,20 @@
Chef::Platform.set(platform: :windows,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Windows)
Chef::Platform.set(platform: :ubuntu,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Debian)
Chef::Platform.set(platform: :debian,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Debian)
Chef::Platform.set(platform: :freebsd,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Freebsd)
[:redhat, :centos, :scientific, :amazon, :fedora].each do |platform|
Chef::Platform.set(platform: platform,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Rhel)
end
Chef::Platform.set(platform: :opensuse,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Opensuse)
12 changes: 12 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@

depends 'dmg', '~> 2.2'
depends 'windows', '~> 1.37'
depends 'apt', '~> 2.7'
depends 'freebsd', '~> 0.3'
depends 'zypper', '~> 0.1'

supports 'mac_os_x'
supports 'windows'
supports 'ubuntu'
supports 'debian'
supports 'freebsd'
supports 'redhat'
supports 'centos'
supports 'scientific'
supports 'amazon'
supports 'fedora'
supports 'opensuse'
# rubocop:enable SingleSpaceBeforeFirstArg
21 changes: 21 additions & 0 deletions spec/libraries/provider_gimp_app_debian_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Encoding: UTF-8

require_relative '../spec_helper'
require_relative '../../libraries/provider_gimp_app_debian'

describe Chef::Provider::GimpApp::Debian do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::GimpApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }

describe '#install!' do
it 'uses an package to install GIMP' do
p = provider
expect(p).to receive(:include_recipe).with('apt')
expect(p).to receive(:package).with('gimp').and_yield
expect(p).to receive(:version).with(nil)
expect(p).to receive(:action).with(:install)
p.send(:install!)
end
end
end

0 comments on commit a231d5a

Please sign in to comment.