class Puppet::Provider::Package::Windows::MsiPackage

Constants

INSTALLSTATE_DEFAULT

From msi.h

INSTALLUILEVEL_NONE

Attributes

packagecode[R]
productcode[R]

Public Class Methods

from_registry(name, values) click to toggle source

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
install_command(resource) click to toggle source
# 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
installer() click to toggle source

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
new(name, version, productcode, packagecode) click to toggle source
# 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
valid?(name, values) click to toggle source

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

Public Instance Methods

match?(resource) click to toggle source

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
uninstall_command() click to toggle source
# File lib/puppet/provider/package/windows/msi_package.rb, line 58
def uninstall_command
  ['msiexec.exe', '/qn', '/norestart', '/x', productcode]
end