Module: Mac::Pkg
Instance Attribute Summary
Attributes included from Beaker::CommandFactory
Instance Method Summary collapse
- #check_for_package(name) ⇒ Object
-
#determine_if_x86_64 ⇒ Boolean
Examine the host system to determine the architecture.
-
#generic_install_dmg(dmg_file, pkg_base, pkg_name) ⇒ Object
Install a package from a specified dmg.
- #install_package(name, _cmdline_args = '', _version = nil) ⇒ Object
- #uninstall_package(name, _cmdline_args = '') ⇒ Object
-
#upgrade_package(name, _cmdline_args = '') ⇒ Object
Upgrade an installed package to the latest available version.
Methods included from Beaker::CommandFactory
Instance Method Details
#check_for_package(name) ⇒ Object
4 5 6 |
# File 'lib/beaker/host/mac/pkg.rb', line 4 def check_for_package(name) raise "Package #{name} cannot be queried on #{self}" end |
#determine_if_x86_64 ⇒ Boolean
Examine the host system to determine the architecture
46 47 48 49 |
# File 'lib/beaker/host/mac/pkg.rb', line 46 def determine_if_x86_64 result = exec(Beaker::Command.new("uname -a | grep x86_64"), :expect_all_exit_codes => true) result.exit_code == 0 end |
#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')
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 |
#install_package(name, _cmdline_args = '', _version = nil) ⇒ Object
8 9 10 |
# File 'lib/beaker/host/mac/pkg.rb', line 8 def install_package(name, _cmdline_args = '', _version = nil) generic_install_dmg("#{name}.dmg", name, "#{name}.pkg") end |
#uninstall_package(name, _cmdline_args = '') ⇒ Object
31 32 33 |
# File 'lib/beaker/host/mac/pkg.rb', line 31 def uninstall_package(name, _cmdline_args = '') raise "Package #{name} cannot be uninstalled on #{self}" end |
#upgrade_package(name, _cmdline_args = '') ⇒ Object
Upgrade an installed package to the latest available version
40 41 42 |
# File 'lib/beaker/host/mac/pkg.rb', line 40 def upgrade_package(name, _cmdline_args = '') raise "Package #{name} cannot be upgraded on #{self}" end |