Class: Pot::Installers::Binary

Inherits:
Pot::Installer show all
Defined in:
lib/pot/installers/binary.rb

Overview

Binary Installer

binary “some.url.com/archive.tar.gz” do

prefix   "/home/user/local"
archives "/home/user/sources"

end

Instance Attribute Summary

Attributes inherited from Pot::Installer

#actor, #options, #package, #post, #pre

Instance Method Summary collapse

Methods inherited from Pot::Installer

#archives, #builds, #commands, #prefix, #process

Constructor Details

#initialize(parent, binary_archive, options = {}, &block) ⇒ Binary

:nodoc:



11
12
13
14
15
# File 'lib/pot/installers/binary.rb', line 11

def initialize(parent, binary_archive, options = {}, &block) #:nodoc:
  @binary_archive = binary_archive
  @options = options
  super parent, options, &block
end

Instance Method Details

#extract_command(archive_name = @binary_archive.split("/").last) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pot/installers/binary.rb', line 30

def extract_command(archive_name = @binary_archive.split("/").last)
  case archive_name
  when /(tar.gz)|(tgz)$/
    'tar xzf'
  when /(tar.bz2)|(tb2)$/
    'tar xjf'
  when /tar$/
    'tar xf'
  when /zip$/
    'unzip -o'
  else
    raise "Unknown binary archive format: #{archive_name}"
  end
end

#install_commandsObject

:nodoc:



25
26
27
28
# File 'lib/pot/installers/binary.rb', line 25

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}'"
end

#prepare_commandsObject

:nodoc:



17
18
19
20
21
22
23
# File 'lib/pot/installers/binary.rb', line 17

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]}" ]
end