Module: Mac::Pkg

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/mac/pkg.rb

Instance Attribute Summary

Attributes included from Beaker::CommandFactory

#assertions

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

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

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.



33
34
35
# File 'lib/beaker/host/mac/pkg.rb', line 33

def deploy_package_repo(path, name, version)
  raise "Package repo cannot be deployed on #{self}; the platform is not supported"
end

#determine_if_x86_64Boolean

Examine the host system to determine the architecture

Returns:

  • (Boolean)

    true if x86_64, false otherwise



39
40
41
42
# File 'lib/beaker/host/mac/pkg.rb', line 39

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

#install_package(name, cmdline_args = '', version = nil) ⇒ Object



8
9
10
11
# File 'lib/beaker/host/mac/pkg.rb', line 8

def install_package(name, cmdline_args = '', version = nil)
  execute("hdiutil attach #{name}.dmg")
  execute("installer -pkg /Volumes/#{name}/#{name}.pkg -target /")
end

#pe_puppet_agent_promoted_package_info(puppet_collection = nil, opts = {}) ⇒ String

Gets host-specific information for PE promoted puppet-agent packages

Parameters:

  • puppet_collection (String) (defaults to: nil)

    Name of the puppet collection to use

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options hash to provide extra values

Returns:

  • (String, String, String)

    Host-specific information for packages

    1. release_path_end Suffix for the release_path. Used on Windows. Check

    Windows::Pkg#pe_puppet_agent_promoted_package_info to see usage.

    1. release_file Path to the file on release build servers

    2. download_file Filename for the package itself

Raises:

  • (ArgumentError)


96
97
98
99
100
101
102
103
104
# File 'lib/beaker/host/mac/pkg.rb', line 96

def pe_puppet_agent_promoted_package_info( puppet_collection = nil, opts = {} )
  error_message = "Must provide %s argument to get puppet agent dev package information"
  raise ArgumentError, error_message % "puppet_collection" unless puppet_collection

  variant, version, arch, codename = self['platform'].to_array
  release_file = "/repos/apple/#{puppet_collection}/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

Parameters:

  • onhost_copy_base (String)

    Base copy directory on the host

  • onhost_copied_download (String)

    Downloaded file path on the host

  • onhost_copied_file (String)

    Copied file path once un-compressed

  • download_file (String)

    File name of the downloaded file

  • opts (Hash{Symbol=>String})

    additional options

Returns:

  • nil



115
116
117
118
119
120
121
122
# File 'lib/beaker/host/mac/pkg.rb', line 115

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

Note:

OSX doesn’t use any additional options at this time, but does require both puppet_collection & puppet_agent_version, & will fail without them

Gets the path & file name for the puppet agent dev package on OSX

Parameters:

  • puppet_collection (String) (defaults to: nil)

    Name of the puppet collection to use

  • puppet_agent_version (String) (defaults to: nil)

    Version of puppet agent to get

  • opts (Hash{Symbol=>String}) (defaults to: {})

    Options hash to provide extra values

Returns:

  • (String, String)

    Path to the directory and filename of the package, respectively

Raises:

  • (ArgumentError)

    If one of the two required parameters (puppet_collection, puppet_agent_version) is either not passed or set to nil



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/beaker/host/mac/pkg.rb', line 57

def puppet_agent_dev_package_info( puppet_collection = nil, puppet_agent_version = nil, opts = {} )
  error_message = "Must provide %s argument to get puppet agent dev package information"
  raise ArgumentError, error_message % "puppet_collection" unless puppet_collection
  raise ArgumentError, error_message % "puppet_agent_version" unless puppet_agent_version

  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



13
14
15
# File 'lib/beaker/host/mac/pkg.rb', line 13

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

Parameters:

  • name (String)

    The name of the package to update

  • cmdline_args (String) (defaults to: '')

    Additional command line arguments for the package manager



22
23
24
# File 'lib/beaker/host/mac/pkg.rb', line 22

def upgrade_package(name, cmdline_args = '')
    raise "Package #{name} cannot be upgraded on #{self}"
end