Class: Chef::Provider::Package::Windows::MSI

Inherits:
Object
  • Object
show all
Includes:
ReservedNames::Win32::API::Installer
Defined in:
lib/chef/provider/package/windows/msi.rb

Instance Method Summary collapse

Methods included from ReservedNames::Win32::API::Installer

#get_installed_version, #get_product_property, #open_package

Constructor Details

#initialize(resource) ⇒ MSI

Returns a new instance of MSI.



30
31
32
# File 'lib/chef/provider/package/windows/msi.rb', line 30

def initialize(resource)
  @new_resource = resource
end

Instance Method Details

#expand_options(options) ⇒ Object

From Chef::Provider::Package



35
36
37
# File 'lib/chef/provider/package/windows/msi.rb', line 35

def expand_options(options)
  options ? " #{options}" : ""
end

#install_package(name, version) ⇒ Object



52
53
54
55
56
# File 'lib/chef/provider/package/windows/msi.rb', line 52

def install_package(name, version)
  # We could use MsiConfigureProduct here, but we'll start off with msiexec
  Chef::Log.debug("#{@new_resource} installing MSI package '#{@new_resource.source}'")
  shell_out!("msiexec /qn /i \"#{@new_resource.source}\" #{expand_options(@new_resource.options)}", {:timeout => @new_resource.timeout, :returns => @new_resource.returns})
end

#installed_versionObject

Returns a version if the package is installed or nil if it is not.



40
41
42
43
44
45
# File 'lib/chef/provider/package/windows/msi.rb', line 40

def installed_version
  Chef::Log.debug("#{@new_resource} getting product code for package at #{@new_resource.source}")
  product_code = get_product_property(@new_resource.source, "ProductCode")
  Chef::Log.debug("#{@new_resource} checking package status and verion for #{product_code}")
  get_installed_version(product_code)
end

#package_versionObject



47
48
49
50
# File 'lib/chef/provider/package/windows/msi.rb', line 47

def package_version
  Chef::Log.debug("#{@new_resource} getting product version for package at #{@new_resource.source}")
  get_product_property(@new_resource.source, "ProductVersion")
end

#remove_package(name, version) ⇒ Object



58
59
60
61
62
# File 'lib/chef/provider/package/windows/msi.rb', line 58

def remove_package(name, version)
  # We could use MsiConfigureProduct here, but we'll start off with msiexec
  Chef::Log.debug("#{@new_resource} removing MSI package '#{@new_resource.source}'")
  shell_out!("msiexec /qn /x \"#{@new_resource.source}\" #{expand_options(@new_resource.options)}", {:timeout => @new_resource.timeout, :returns => @new_resource.returns})
end