From msi.h
Return an instance of the package from the registry, or nil
# File lib/puppet/provider/package/windows/msi_package.rb, line 18 def self.from_registry(name, values) if valid?(name, values) inst = installer if inst.ProductState(name) == INSTALLSTATE_DEFAULT MsiPackage.new(values['DisplayName'], values['DisplayVersion'], name, # productcode inst.ProductInfo(name, 'PackageCode')) end end end
# File lib/puppet/provider/package/windows/msi_package.rb, line 54 def self.install_command(resource) ['msiexec.exe', '/qn', '/norestart', '/i', quote(resource[:source])] end
Get the COM installer object, it’s in a separate method for testing
# File lib/puppet/provider/package/windows/msi_package.rb, line 12 def self.installer # REMIND: when does the COM release happen? WIN32OLE.new("WindowsInstaller.Installer") end
# File lib/puppet/provider/package/windows/msi_package.rb, line 40 def initialize(name, version, productcode, packagecode) super(name, version) @productcode = productcode @packagecode = packagecode end
Is this a valid MSI package we should manage?
# File lib/puppet/provider/package/windows/msi_package.rb, line 32 def self.valid?(name, values) # See http://community.spiceworks.com/how_to/show/2238 !!(values['DisplayName'] and values['DisplayName'].length > 0 and values['SystemComponent'] != 1 and # DWORD values['WindowsInstaller'] == 1 and # DWORD name =~ /\A\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}\Z/) end
Does this package match the resource?
# File lib/puppet/provider/package/windows/msi_package.rb, line 48 def match?(resource) resource[:name].casecmp(packagecode) == 0 || resource[:name].casecmp(productcode) == 0 || resource[:name] == name end
# File lib/puppet/provider/package/windows/msi_package.rb, line 58 def uninstall_command ['msiexec.exe', '/qn', '/norestart', '/x', productcode] end