Sha256: 8cf56f31b10441f1f3b18436a4964ead522577fd6fefb6c5220323c25377a435

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

require 'rho_connect_install_constants'

module DownloadAndDocompress
  # download_and_decompress
  # Delegates the download and decompression duties
  def download_and_decompress(prefix, tarballs)
    #print_header "Downloading ..."
    downloads = 0
    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
        downloads += 1
      end #if
    end #do
#    if downloads == 0
#      log_print "Nothing additional to download"
#    end #if
  end #download_and_decompress

  # 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 } "
    end #if
  end #wget_download

  # 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 }" 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

13 entries across 13 versions & 1 rubygems

Version Path
rhoconnect-3.1.2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.1.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.1.0 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.1.0.beta2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.1.0.beta1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.6 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.5 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.4 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.3 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.2 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.1 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.0 installer/unix-like/rho_connect_install_dnd.rb
rhoconnect-3.0.0.rc1 installer/unix-like/rho_connect_install_dnd.rb