Sha256: f24233246f5538c1b8b2de4fb7ef5f30ed3ce08b6826392708eda0f052a929af

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require 'pe_build/on_machine'

# Download PE installers to a POSIX VM
#
# @since 0.14.0
class PEBuild::Cap::StageInstaller::POSIX

  extend PEBuild::OnMachine

  # Download an installer to a remote VM
  #
  # @param uri [URI] A URI containing the download source.
  # @param dest_dir [String] The destination directory to download the
  #   installer to.
  #
  # @return [void]
  def self.stage_installer(machine, uri, dest_dir='.')
    filename = File.basename(uri.path)
    installer_dir = filename.gsub(/.tar(?:\.gz)?/, '')

    # GNU tar will attempt to guess the file format. Other versions of tar,
    # such as those shipped with Solaris, take the approach that trying to
    # interpret unknown binaries is none of their business.
    tar_flags = if filename.end_with?('.tar.gz')
      'xzf'
    else
      'xf'
    end

    unless machine.communicate.test("test -d #{dest_dir}/#{installer_dir}")
      machine.ui.info I18n.t('pebuild.cap.stage_installer.downloading_installer',
        :url => uri)

      on_machine(machine, "curl -fsSLk #{uri} -o #{dest_dir}/#{filename}")
      on_machine(machine, "tar #{tar_flags} #{dest_dir}/#{filename} -C #{dest_dir}")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-pe_build-0.15.5 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.15.4 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.15.3 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.15.1 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.15.0 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.14.2 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.14.1 lib/pe_build/cap/stage_installer/posix.rb
vagrant-pe_build-0.14.0 lib/pe_build/cap/stage_installer/posix.rb