Sha256: e0bf51968a079cd26d1e4091d290a58f2ba4a8dddda8a1baf70ab72e3d4b7a94
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
module Sprinkle module Installers # = Binary Installer # # binary "http://some.url.com/archive.tar.gz" do # prefix "/home/user/local" # archives "/home/user/sources" # end # class Binary < Installer def initialize(parent, binary_archive, options = {}, &block) #:nodoc: @binary_archive = binary_archive @options = options super parent, options, &block end 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 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 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' else raise "Unknown binary archive format: #{archive_name}" end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems