Class: PEBuild::Cap::StageInstaller::POSIX

Inherits:
Object
  • Object
show all
Extended by:
OnMachine
Defined in:
lib/pe_build/cap/stage_installer/posix.rb

Overview

Download PE installers to a POSIX VM

Since:

  • 0.14.0

Class Method Summary collapse

Methods included from OnMachine

on_machine

Class Method Details

.stage_installer(machine, uri, dest_dir = '.') ⇒ void

This method returns an undefined value.

Download an installer to a remote VM

Parameters:

  • uri (URI)

    A URI containing the download source.

  • dest_dir (String) (defaults to: '.')

    The destination directory to download the installer to.

Since:

  • 0.14.0



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pe_build/cap/stage_installer/posix.rb', line 17

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)

    # Download and stage the installer without using sudo, so that root
    # doesn't own the resulting directory. This allows files to be uploaded
    # later.
    on_machine(machine, "curl -fsSLk #{uri} -o #{dest_dir}/#{filename}", sudo: false)
    on_machine(machine, "tar #{tar_flags} #{dest_dir}/#{filename} -C #{dest_dir}", sudo: false)
  end
end