Method: Mac::Pkg#generic_install_dmg

Defined in:
lib/beaker/host/mac/pkg.rb

#generic_install_dmg(dmg_file, pkg_base, pkg_name) ⇒ Object

Install a package from a specified dmg

@example: Install vagrant from URL

mymachost.generic_install_dmg('https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.dmg', 'Vagrant', 'Vagrant.pkg')

Parameters:

  • dmg_file (String)

    The dmg file, including path if not relative. Can be a URL.

  • pkg_base (String)

    The base name of the directory that the dmg attaches to under ‘/Volumes`

  • pkg_name (String)

    The name of the package file that should be used by the installer



22
23
24
25
26
27
28
29
# File 'lib/beaker/host/mac/pkg.rb', line 22

def generic_install_dmg(dmg_file, pkg_base, pkg_name)
  execute("test -f #{dmg_file}", :accept_all_exit_codes => true) do |result|
    execute("curl -O #{dmg_file}") unless result.exit_code == 0
  end
  dmg_name = File.basename(dmg_file, '.dmg')
  execute("hdiutil attach #{dmg_name}.dmg")
  execute("installer -pkg /Volumes/#{pkg_base}/#{pkg_name} -target /")
end