Module: Mac::Pkg
Instance Attribute Summary
Attributes included from Beaker::CommandFactory
Instance Method Summary collapse
- #check_for_package(name) ⇒ Object
-
#deploy_package_repo(path, name, version) ⇒ Object
Deploy configuration generated by the packaging tooling to this host.
-
#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
-
#pe_puppet_agent_promoted_package_info(puppet_collection = nil, opts = {}) ⇒ String
Gets host-specific information for PE promoted puppet-agent packages.
-
#pe_puppet_agent_promoted_package_install(onhost_copy_base, onhost_copied_download, onhost_copied_file, download_file, opts) ⇒ Object
Installs a given PE promoted package on a host.
-
#puppet_agent_dev_package_info(puppet_collection = nil, puppet_agent_version = nil, opts = {}) ⇒ String
Gets the path & file name for the puppet agent dev package on OSX.
- #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 |
#deploy_package_repo(path, name, version) ⇒ Object
See Beaker::DSL::Helpers::HostHelpers#deploy_package_repo for info on params
Deploy configuration generated by the packaging tooling to this host.
This method calls one of #deploy_apt_repo, #deploy_yum_repo, or #deploy_zyp_repo depending on the platform of this Host.
51 52 53 |
# File 'lib/beaker/host/mac/pkg.rb', line 51 def deploy_package_repo(path, name, version) raise "Package repo cannot be deployed on #{self}; the platform is not supported" end |
#determine_if_x86_64 ⇒ Boolean
Examine the host system to determine the architecture
57 58 59 60 |
# File 'lib/beaker/host/mac/pkg.rb', line 57 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 |
#pe_puppet_agent_promoted_package_info(puppet_collection = nil, opts = {}) ⇒ String
Gets host-specific information for PE promoted puppet-agent packages
115 116 117 118 119 120 121 122 123 |
# File 'lib/beaker/host/mac/pkg.rb', line 115 def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} ) = "Must provide %s argument to get puppet agent dev package information" raise ArgumentError, % "puppet_collection" unless puppet_collection variant, version, arch, codename = self['platform'].to_array release_file = "/repos/apple/#{version}/#{puppet_collection}/#{arch}/puppet-agent-*" download_file = "puppet-agent-#{variant}-#{version}.tar.gz" return '', release_file, download_file end |
#pe_puppet_agent_promoted_package_install(onhost_copy_base, onhost_copied_download, onhost_copied_file, download_file, opts) ⇒ Object
Installs a given PE promoted package on a host
134 135 136 137 138 139 140 141 |
# File 'lib/beaker/host/mac/pkg.rb', line 134 def pe_puppet_agent_promoted_package_install( onhost_copy_base, onhost_copied_download, onhost_copied_file, download_file, opts ) execute("tar -zxvf #{onhost_copied_download} -C #{onhost_copy_base}") # move to better location execute("mv #{onhost_copied_file}.dmg .") self.install_package("puppet-agent-*") end |
#puppet_agent_dev_package_info(puppet_collection = nil, puppet_agent_version = nil, opts = {}) ⇒ String
OSX does require :download_url to be set on the opts argument in order to check for builds on the builds server
Gets the path & file name for the puppet agent dev package on OSX
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/beaker/host/mac/pkg.rb', line 75 def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} ) = "Must provide %s argument to get puppet agent dev package information" raise ArgumentError, % "puppet_collection" unless puppet_collection raise ArgumentError, % "puppet_agent_version" unless puppet_agent_version raise ArgumentError, % "opts[:download_url]" unless opts[:download_url] variant, version, arch, codename = self['platform'].to_array mac_pkg_name = "puppet-agent-#{puppet_agent_version}" version = version[0,2] + '.' + version[2,2] unless version.include?(".") # newest hotness path_chunk = "apple/#{version}/#{puppet_collection}/#{arch}" release_path_end = path_chunk # moved to doing this when 'el capitan' came out & the objection was # raised that the code name wasn't a fact, & as such can be hard to script # example: puppet-agent-0.1.0-1.osx10.9.dmg release_file = "#{mac_pkg_name}-1.osx#{version}.dmg" if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}") # new hotness # little older change involved the code name as only difference from above # example: puppet-agent-0.1.0-1.mavericks.dmg release_file = "#{mac_pkg_name}-1.#{codename}.dmg" end if not link_exists?("#{opts[:download_url]}/#{release_path_end}/#{release_file}") # oops, try the old stuff release_path_end = "apple/#{puppet_collection}" # example: puppet-agent-0.1.0-osx-10.9-x86_64.dmg release_file = "#{mac_pkg_name}-#{variant}-#{version}-x86_64.dmg" end return release_path_end, release_file 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 |