Sha256: 3332374f595fa64cd15f58ddd5b83fb7cd69457185a29d8ca93390d9d21f9d9c
Contents?: true
Size: 1.82 KB
Versions: 14
Compression:
Stored size: 1.82 KB
Contents
module Sprinkle module Installers # The Binary installer will download a binary archive and then extract # it in the directory specified by the prefix option. # # == Example Usage # # binary "http://some.url.com/archive.tar.gz" do # prefix "/home/user/local" # archives "/home/user/sources" # end # # This example will download archive.tar.gz to /home/user/sources and then # extract it into /home/user/local. class Binary < Installer api do def binary(source, options = {}, &block) install Binary.new(self, source, options, &block) end end def initialize(parent, binary_archive, options = {}, &block) #:nodoc: @binary_archive = binary_archive 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]}/#{archive_name}'\"" end def archive_name #:nodoc: @archive_name ||= @binary_archive.split("/").last.gsub('%20', ' ') end def extract_command #:nodoc: 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 end end end
Version data entries
14 entries across 14 versions & 1 rubygems