-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RoboticCheese/jdh-add-deb-support
Add Ubuntu/Debian support
- Loading branch information
Showing
13 changed files
with
272 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
--- | ||
driver: | ||
name: digitalocean | ||
# debian-8 image doesn't exist in nyc2 | ||
region: nyc3 | ||
|
||
platforms: | ||
- name: macosx | ||
driver: | ||
name: localhost | ||
- name: ubuntu-14-04-x64 | ||
# The Debian 8 image doesn't have sudo installed | ||
- name: debian-8-x64 | ||
provisioner: | ||
sudo_command: | ||
verifier: | ||
sudo_command: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Accept the Steam license agreement: | ||
# $ sudo debconf-show steam | ||
# * steam/license: | ||
# * steam/question: I AGREE | ||
# steam/purge: | ||
steam steam/question select I AGREE | ||
#steam/license steam/license note | ||
#steam steam/purge none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Encoding: UTF-8 | ||
# | ||
# Cookbook Name:: steam | ||
# Library:: provider_steam_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_steam_app' | ||
|
||
class Chef | ||
class Provider | ||
class SteamApp < Provider::LWRPBase | ||
# An provider for Steam on Ubuntu/Debian. | ||
# | ||
# @author Jonathan Hartman <j@p4nt5.com> | ||
class Debian < SteamApp | ||
URL ||= 'https://steamcdn-a.akamaihd.net/client/installer/steam.deb' | ||
PATH ||= '/usr/bin/steam' | ||
|
||
include Chef::DSL::IncludeRecipe | ||
|
||
private | ||
|
||
# | ||
# Install dependencies, download the Steam package, and install it. | ||
# | ||
# (see SteamApp#install!) | ||
# | ||
def install! | ||
resolve_dependencies | ||
download_package | ||
install_package | ||
end | ||
|
||
# | ||
# Use a dpkg_package resource to uninstall Steam. | ||
# | ||
# (see SteamApp#remove!) | ||
# | ||
def remove! | ||
dpkg_package 'steam-launcher' do | ||
action :remove | ||
end | ||
end | ||
|
||
# | ||
# Use a dpkg_package resource to install the .deb file. | ||
# | ||
def install_package | ||
s = download_path | ||
dpkg_package 'steam-launcher' do | ||
source s | ||
action :install | ||
end | ||
end | ||
|
||
# | ||
# Use a remote_file resource to download the .deb to Chef's cache dir. | ||
# | ||
def download_package | ||
remote_file download_path do | ||
source URL | ||
action :create | ||
only_if { !::File.exist?(PATH) } | ||
end | ||
end | ||
|
||
# | ||
# Construct a download destination under Chef's cache dir. | ||
# | ||
# @return [String] | ||
# | ||
def download_path | ||
::File.join(Chef::Config[:file_cache_path], ::File.basename(URL)) | ||
end | ||
|
||
# | ||
# Ensure the steam package's dependencies are satisfied since we're | ||
# installing a .deb directly with dpkg. The package depends on one of | ||
# xterm, gnome-terminal, konsole, so only install xterm if neither of | ||
# the others is present. | ||
# | ||
# TODO: The hardcoded package list is pretty ugly. Should either pull | ||
# dependencies from the package file at runtime or wait for the APT | ||
# repo maintainers to fix the bug that prevents us from using that | ||
# (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772598) | ||
# | ||
def resolve_dependencies | ||
include_recipe 'apt' | ||
%w(python libc6 python-apt xz-utils curl zenity).each do |p| | ||
package p do | ||
action :install | ||
end | ||
end | ||
package 'xterm' do | ||
action :install | ||
not_if 'dpkg -s gnome-terminal || dpkg -s konsole' | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Encoding: UTF-8 | ||
|
||
require_relative '../spec_helper' | ||
require_relative '../../libraries/provider_steam_app_debian' | ||
|
||
describe Chef::Provider::SteamApp::Debian do | ||
let(:name) { 'default' } | ||
let(:new_resource) { Chef::Resource::SteamApp.new(name, nil) } | ||
let(:provider) { described_class.new(new_resource, nil) } | ||
|
||
describe '#install!' do | ||
it 'installs dependencies, downloads and installs the package' do | ||
p = provider | ||
expect(p).to receive(:resolve_dependencies) | ||
expect(p).to receive(:download_package) | ||
expect(p).to receive(:install_package) | ||
p.send(:install!) | ||
end | ||
end | ||
|
||
describe '#remove!' do | ||
it 'uses a dpkg_package to uninstall the package' do | ||
p = provider | ||
expect(p).to receive(:dpkg_package).with('steam-launcher').and_yield | ||
expect(p).to receive(:action).with(:remove) | ||
p.send(:remove!) | ||
end | ||
end | ||
|
||
describe '#install_package' do | ||
before(:each) do | ||
allow_any_instance_of(described_class).to receive(:download_path) | ||
.and_return('/tmp/steam.deb') | ||
end | ||
|
||
it 'uses a dpkg_package to install the package' do | ||
p = provider | ||
expect(p).to receive(:dpkg_package).with('steam-launcher').and_yield | ||
expect(p).to receive(:source).with('/tmp/steam.deb') | ||
expect(p).to receive(:action).with(:install) | ||
p.send(:install_package) | ||
end | ||
end | ||
|
||
describe '#download_package' do | ||
before(:each) do | ||
allow_any_instance_of(described_class).to receive(:download_path) | ||
.and_return('/tmp/steam.deb') | ||
end | ||
|
||
it 'uses a remote_file to download the package' do | ||
p = provider | ||
expect(p).to receive(:remote_file).with('/tmp/steam.deb').and_yield | ||
expect(p).to receive(:source).with(described_class::URL) | ||
expect(p).to receive(:action).with(:create) | ||
expect(p).to receive(:only_if).and_yield | ||
expect(File).to receive(:exist?).with(described_class::PATH) | ||
p.send(:download_package) | ||
end | ||
end | ||
|
||
describe '#download_path' do | ||
it 'returns a path under the Chef cache dir' do | ||
expected = "#{Chef::Config[:file_cache_path]}/steam.deb" | ||
expect(provider.send(:download_path)).to eq(expected) | ||
end | ||
end | ||
|
||
describe '#resolve_dependencies' do | ||
before(:each) do | ||
allow_any_instance_of(described_class).to receive(:include_recipe) | ||
allow_any_instance_of(described_class).to receive(:package) | ||
end | ||
|
||
it 'ensures the APT cache is up to date' do | ||
p = provider | ||
expect(p).to receive(:include_recipe).with('apt') | ||
p.send(:resolve_dependencies) | ||
end | ||
|
||
it 'installs all the hard requirements and, conditonally, xterm' do | ||
p = provider | ||
%w(python libc6 python-apt xz-utils curl zenity).each do |pkg| | ||
expect(p).to receive(:package).with(pkg).and_yield | ||
expect(p).to receive(:action).with(:install) | ||
end | ||
expect(p).to receive(:package).with('xterm').and_yield | ||
expect(p).to receive(:action).with(:install) | ||
expect(p).to receive(:not_if) | ||
.with('dpkg -s gnome-terminal || dpkg -s konsole') | ||
p.send(:resolve_dependencies) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters