class Chef::Provider::Package::Windows::MSI
Attributes
logger[R]
new_resource[R]
uninstall_entries[R]
Public Class Methods
new(resource, uninstall_entries)
click to toggle source
# File lib/chef/provider/package/windows/msi.rb, line 32 def initialize(resource, uninstall_entries) @new_resource = resource @logger = new_resource.logger @uninstall_entries = uninstall_entries end
Public Instance Methods
expand_options(options)
click to toggle source
# File lib/chef/provider/package/windows/msi.rb, line 43 def expand_options(options) options ? " #{options}" : "" end
install_package()
click to toggle source
# File lib/chef/provider/package/windows/msi.rb, line 70 def install_package # We could use MsiConfigureProduct here, but we'll start off with msiexec logger.trace("#{new_resource} installing MSI package '#{new_resource.source}'") shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", default_env: false, timeout: new_resource.timeout, returns: new_resource.returns) end
installed_version()
click to toggle source
Returns a version if the package is installed or nil if it is not.
# File lib/chef/provider/package/windows/msi.rb, line 48 def installed_version if !new_resource.source.nil? && ::File.exist?(new_resource.source) logger.trace("#{new_resource} getting product code for package at #{new_resource.source}") product_code = get_product_property(new_resource.source, "ProductCode") logger.trace("#{new_resource} checking package status and version for #{product_code}") get_installed_version(product_code) else if uninstall_entries.count != 0 uninstall_entries.map(&:display_version).uniq end end end
package_version()
click to toggle source
# File lib/chef/provider/package/windows/msi.rb, line 61 def package_version return new_resource.version if new_resource.version if !new_resource.source.nil? && ::File.exist?(new_resource.source) logger.trace("#{new_resource} getting product version for package at #{new_resource.source}") get_product_property(new_resource.source, "ProductVersion") end end
remove_package()
click to toggle source
# File lib/chef/provider/package/windows/msi.rb, line 76 def remove_package # We could use MsiConfigureProduct here, but we'll start off with msiexec if !new_resource.source.nil? && ::File.exist?(new_resource.source) logger.trace("#{new_resource} removing MSI package '#{new_resource.source}'") shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", default_env: false, timeout: new_resource.timeout, returns: new_resource.returns) else uninstall_version = new_resource.version || installed_version uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) } .map(&:uninstall_string).uniq.each do |uninstall_string| uninstall_string = "msiexec /x #{uninstall_string.match(/{.*}/)}" uninstall_string += expand_options(new_resource.options) uninstall_string += " /q" unless %r{ /q}.match?(uninstall_string.downcase) logger.trace("#{new_resource} removing MSI package version using '#{uninstall_string}'") shell_out!(uninstall_string, default_env: false, timeout: new_resource.timeout, returns: new_resource.returns) end end end