Sha256: 77795672807de8a54cc1a059b5bd8433f46e2eba92f78eca6befcc23ad5605fe

Contents?: true

Size: 1.55 KB

Versions: 18

Compression:

Stored size: 1.55 KB

Contents

require 'rho_connect_install_constants'

module DownloadAndDocompress
  # download_and_decompress
  # Delegates the download and decompression duties
  def download_and_decompress(prefix, tarballs)
    tarballs.each do |url|
      if !File.exists?("#{ get_tarball_name url }") || !File.exists?("#{ get_version url }")
        puts "Downloading #{url} ..."
        wget_download prefix, url
        decompress prefix, url
      end
    end
  end

  # wget_download
  # Takes a URL and the name of a tarball and issues a wget command on said
  # URL  unless the tarball or directory already exists
  def wget_download(prefix, url)
    if !File.exists?("#{ prefix }/#{ get_tarball_name url }") &&
       !File.directory?("#{ prefix }/#{ get_version url }")
       cmd "wget -P #{prefix} #{url} -o /dev/null"
       raise "ERROR: #{url} not found" if $? != 0
    end
  end

  # decompress
  # Decompress downloaded files unless already decompressed directory
  # exists
  def decompress(prefix, url)
    tarball = get_tarball_name(url)
    dir = get_version(url)
    cmd "tar -xzf #{prefix}/#{tarball} -C #{prefix} > /dev/null 2>&1" unless File.directory? "#{prefix}/#{dir}"
  end #decompress

  # get_version
  # This method extracts the untarballed name of files retrieved via wget
  # from their URL
  def get_version(url)
    url =~ /.*\/(.*)\.t.*\Z/
    $1
  end #get_version

  # get_tarball_name
  # This method extracts the name of files retrieved via wget from their URL
  def get_tarball_name(url)
    url =~ /.*\/(.*\.t.*)/
    $1
  end #get_tarball_name
end #DownloadAndDocompress

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-7.5.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-7.4.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-7.1.17 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-6.2.0 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-6.0.11 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.18 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.17 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.15 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.0.22 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.0.7 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.0.3 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.5.0 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-5.1.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.4 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.3 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-4.0.2 installer/unix-like/rho_connect_install_dnd.rb