Skip to content

Commit

Permalink
Merge pull request sprinkle-tool#18 from rdvdijk/master
Browse files Browse the repository at this point in the history
Fixed 1.9 compatibility
  • Loading branch information
crafterm committed May 8, 2011
2 parents 7fa0bff + c600ed8 commit c39bb75
Show file tree
Hide file tree
Showing 35 changed files with 215 additions and 104 deletions.
2 changes: 1 addition & 1 deletion lib/sprinkle/configurable.rb
Expand Up @@ -18,7 +18,7 @@ def assert_delivery
def method_missing(sym, *args, &block)
unless args.empty? # mutate if not set
@options ||= {}
@options[sym] = *args unless @options[sym]
@options[sym] = args unless @options[sym]
end

@options[sym] || @package.send(sym, *args, &block) # try the parents options if unknown
Expand Down
8 changes: 4 additions & 4 deletions lib/sprinkle/installers/binary.rb
Expand Up @@ -18,13 +18,13 @@ def prepare_commands #:nodoc:
raise 'No installation area defined' unless @options[:prefix]
raise 'No archive download area defined' unless @options[:archives]

[ "mkdir -p #{@options[:prefix]}",
"mkdir -p #{@options[:archives]}" ]
[ "mkdir -p #{@options[:prefix].first}",
"mkdir -p #{@options[:archives].first}" ]
end

def install_commands #:nodoc:
commands = [ "bash -c 'wget -cq --directory-prefix=#{@options[:archives]} #{@binary_archive}'" ]
commands << "bash -c 'cd #{@options[:prefix]} && #{extract_command} #{@options[:archives]}/#{@binary_archive.split("/").last}'"
commands = [ "bash -c 'wget -cq --directory-prefix=#{@options[:archives].first} #{@binary_archive}'" ]
commands << "bash -c 'cd #{@options[:prefix].first} && #{extract_command} #{@options[:archives].first}/#{@binary_archive.split("/").last}'"
end

def extract_command(archive_name = @binary_archive.split("/").last)
Expand Down
4 changes: 2 additions & 2 deletions lib/sprinkle/installers/rake.rb
Expand Up @@ -22,14 +22,14 @@ module Installers
class Rake < Installer
def initialize(parent, commands, options = {}, &block) #:nodoc:
super parent, options, &block
@commands = commands.to_a
@commands = commands
end

protected

def install_commands #:nodoc:
file = @options[:rakefile] ? "-f #{@options[:rakefile]} " : ""
"rake #{file}#{@commands.join(' ')}"
"rake #{file}#{@commands}"
end

end
Expand Down
22 changes: 11 additions & 11 deletions lib/sprinkle/installers/source.rb
Expand Up @@ -91,36 +91,36 @@ def prepare_commands #:nodoc:
raise 'No build area defined' unless @options[:builds]
raise 'No source download area defined' unless @options[:archives]

[ "mkdir -p #{@options[:prefix]}",
"mkdir -p #{@options[:builds]}",
"mkdir -p #{@options[:archives]}" ]
[ "mkdir -p #{@options[:prefix].first}",
"mkdir -p #{@options[:builds].first}",
"mkdir -p #{@options[:archives].first}" ]
end

def download_commands #:nodoc:
if File.exist? @source
[ "cp #{@source} #{@options[:archives]}/#{archive_name}" ]
[ "cp #{@source} #{@options[:archives].first}/#{archive_name}" ]
else
[ "wget -cq --directory-prefix='#{@options[:archives]}' #{@source}" ]
[ "wget -cq --directory-prefix='#{@options[:archives].first}' #{@source}" ]
end
end

def extract_commands #:nodoc:
[ "bash -c 'cd #{@options[:builds]} && #{extract_command} #{@options[:archives]}/#{archive_name}'" ]
[ "bash -c 'cd #{@options[:builds].first} && #{extract_command} #{@options[:archives].first}/#{archive_name}'" ]
end

def configure_commands #:nodoc:
return [] if custom_install?

command = "bash -c 'cd #{build_dir} && ./configure --prefix=#{@options[:prefix]} "
command = "bash -c 'cd #{build_dir} && ./configure --prefix=#{@options[:prefix].first} "

extras = {
:enable => '--enable', :disable => '--disable',
:with => '--with', :without => '--without',
:option => '-',
}

extras.inject(command) { |m, (k, v)| m << create_options(k, v) if options[k]; m }

extras.inject(command) { |m, (k, v)| m << create_options(k, v) if options[k]; m }
[ command << " > #{@package.name}-configure.log 2>&1'" ]
end

Expand Down Expand Up @@ -154,7 +154,7 @@ def dress(commands, stage)
private

def create_options(key, prefix) #:nodoc:
@options[key].inject(' ') { |m, option| m << "#{prefix}-#{option} "; m }
@options[key].first.inject('') { |m, option| m << "#{prefix}-#{option} "; m }
end

def extract_command #:nodoc:
Expand All @@ -179,7 +179,7 @@ def archive_name #:nodoc:
end

def build_dir #:nodoc:
"#{@options[:builds]}/#{options[:custom_dir] || base_dir}"
"#{@options[:builds].first}/#{options[:custom_dir] || base_dir}"
end

def base_dir #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/actors/capistrano_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Actors::Capistrano do

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/actors/local_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Actors::Local do

Expand Down
4 changes: 2 additions & 2 deletions spec/sprinkle/configurable_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
require File.expand_path("../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Configurable do
module MyPrefix
Expand Down Expand Up @@ -32,7 +32,7 @@ class Configurable
@configurable.instance_eval do
hsv 'gts'
end
@configurable.hsv.should == 'gts'
@configurable.hsv.first.should == 'gts'
end

it 'should allow the delivery instance variable to be accessed' do
Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/deployment_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper'
require File.expand_path("../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Deployment do
include Sprinkle::Deployment
Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/extensions/array_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Array, 'task name conversions' do

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/extensions/string_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe String, 'task name conversions' do

Expand Down
7 changes: 5 additions & 2 deletions spec/sprinkle/installers/apt_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Apt do

Expand Down Expand Up @@ -51,7 +51,9 @@ def create_apt(*debs, &block)
@installer.send(:install_sequence).should == [ 'op1', %(env DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get --force-yes -qyu install ruby), 'op2' ]
end

it 'should install a specific version if defined'
it 'should install a specific version if defined' do
pending
end

end

Expand All @@ -67,4 +69,5 @@ def create_apt(*debs, &block)
end

end

end
64 changes: 64 additions & 0 deletions spec/sprinkle/installers/binary_spec.rb
@@ -0,0 +1,64 @@
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Binary do
include Sprinkle::Deployment

def create_context
binary = 'http://www.example.com/archive.tar.gz'

deployment = deployment do
delivery :capistrano
binary "http://www.example.com/archive.tar.gz" do
prefix '/prefix/directory'
archives '/archives/directory'
end
end

installer = create_binary binary do
prefix '/prefix/directory'
archives '/archives/directory'
end

installer.defaults(@deployment)

[binary, deployment, installer]
end

def create_binary(binary, version = nil, &block)
@package = mock(Sprinkle::Package, :name => 'package', :version => version)
Sprinkle::Installers::Binary.new(@package, binary, &block)
end

describe "binary#prepare_commands" do
before do
@binary, @deployment, @installer = create_context
end

it "should return mkdir command to create the prefix directory" do
@installer.send(:prepare_commands)[0].should == 'mkdir -p /prefix/directory'
end
it "should return mkdir command to create the archives directory" do
@installer.send(:prepare_commands)[1].should == 'mkdir -p /archives/directory'
end
end


describe "binary#install_commands" do
before do
@binary, @deployment, @installer = create_context
end

it "should return a commands to place the binary in the correct archive directory" do
@installer.send(:install_commands)[0].should =~ /--directory-prefix=\/archives\/directory/
end

it "should return a command to extract to the correct prefix folder" do
@installer.send(:install_commands)[1].should =~ /cd \/prefix\/directory/
end

it "should return a command to extract the right file in the right directory" do
@installer.send(:install_commands)[1].should =~ / \/archives\/directory\/archive.tar.gz/
end
end

end
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/bsd_port_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::BsdPort do

Expand Down
6 changes: 4 additions & 2 deletions spec/sprinkle/installers/freebsd_pkg_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::FreebsdPkg do

Expand Down Expand Up @@ -42,7 +42,9 @@ def create_pkg(pkgs, &block)
@installer.send(:install_sequence).should == [ 'op1', 'pkg_add -r ruby', 'op2' ]
end

it 'should install a specific version if defined'
it 'should install a specific version if defined' do
pending
end

end

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/freebsd_portinstall_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::FreebsdPortinstall do

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/gem_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Gem do

Expand Down
6 changes: 3 additions & 3 deletions spec/sprinkle/installers/installer_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Installer do
include Sprinkle::Deployment
Expand Down Expand Up @@ -41,13 +41,13 @@ def install_sequence

it 'should accept an optional block to customize installers defaults' do
@installer = create_installer do; prefix '/usr/local'; end
@installer.prefix.should == '/usr/local'
@installer.prefix.first.should == '/usr/local'
end

it 'should override any deployment level defaults' do
@installer = create_installer do; prefix '/usr/local'; end
@installer.defaults(@deployment)
@installer.prefix.should == '/usr/local'
@installer.prefix.first.should == '/usr/local'
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/mac_port_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::MacPort do

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/noop_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Noop do

Expand Down
6 changes: 4 additions & 2 deletions spec/sprinkle/installers/openbsd_pkg_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::OpenbsdPkg do

Expand Down Expand Up @@ -42,7 +42,9 @@ def create_pkg(pkgs, &block)
@installer.send(:install_sequence).should == [ 'op1', 'pkg_add ruby', 'op2' ]
end

it 'should install a specific version if defined'
it 'should install a specific version if defined' do
pending
end

end

Expand Down
6 changes: 4 additions & 2 deletions spec/sprinkle/installers/opensolaris_pkg_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::OpensolarisPkg do

Expand Down Expand Up @@ -42,7 +42,9 @@ def create_pkg(pkgs, &block)
@installer.send(:install_sequence).should == [ 'op1', 'pkg install ruby', 'op2' ]
end

it 'should install a specific version if defined'
it 'should install a specific version if defined' do
pending
end

end

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/push_text_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::PushText do

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/rake_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Rake do

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/replace_text_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::ReplaceText do

Expand Down
10 changes: 7 additions & 3 deletions spec/sprinkle/installers/rpm_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Rpm do

Expand Down Expand Up @@ -42,8 +42,12 @@ def create_rpm(debs, &block)
@installer.send(:install_sequence).should == [ 'op1', 'rpm -Uvh ruby', 'op2' ]
end

it 'should specify a non interactive mode to the apt installer'
it 'should install a specific version if defined'
it 'should specify a non interactive mode to the apt installer' do
pending
end
it 'should install a specific version if defined' do
pending
end

end

Expand Down
2 changes: 1 addition & 1 deletion spec/sprinkle/installers/runner_spec.rb
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.expand_path("../../spec_helper", File.dirname(__FILE__))

describe Sprinkle::Installers::Runner do

Expand Down

0 comments on commit c39bb75

Please sign in to comment.