Class: Puppet::Provider::Package::Windows::MsiPackage
- Defined in:
- lib/puppet/provider/package/windows/msi_package.rb
Constant Summary collapse
- INSTALLSTATE_DEFAULT =
From msi.h
5
- INSTALLUILEVEL_NONE =
product is installed for the current user
2
- REG_VALUE_NAMES =
registry values to load under each product entry in HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall for this provider
%w[ DisplayVersion WindowsInstaller ]
Constants inherited from Package
Package::REG_DISPLAY_VALUE_NAMES
Constants included from Util::Windows::Registry
Util::Windows::Registry::ERROR_NO_MORE_ITEMS, Util::Windows::Registry::KEY32, Util::Windows::Registry::KEY64, Util::Windows::Registry::KEY_ALL_ACCESS, Util::Windows::Registry::KEY_READ, Util::Windows::Registry::KEY_WRITE, Util::Windows::Registry::WCHAR_SIZE
Instance Attribute Summary collapse
- #packagecode ⇒ Object readonly
- #productcode ⇒ Object readonly
Attributes inherited from Package
Class Method Summary collapse
-
.from_registry(name, values) ⇒ Object
Return an instance of the package from the registry, or nil.
- .install_command(resource) ⇒ Object
-
.installer ⇒ Object
Get the COM installer object, it’s in a separate method for testing.
-
.valid?(name, values) ⇒ Boolean
Is this a valid MSI package we should manage?.
Instance Method Summary collapse
-
#initialize(name, version, productcode, packagecode) ⇒ MsiPackage
constructor
A new instance of MsiPackage.
-
#match?(resource) ⇒ Boolean
Does this package match the resource?.
- #uninstall_command ⇒ Object
Methods inherited from Package
each, get_display_name, installer_class, munge, quote, reg_value_names_to_load, replace_forward_slashes, with_key
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail
Methods included from Util::Windows::Registry
#delete_key, #delete_value, #each_key, #each_value, #keys, #open, #root, #values, #values_by_name
Constructor Details
#initialize(name, version, productcode, packagecode) ⇒ MsiPackage
Returns a new instance of MsiPackage.
50 51 52 53 54 55 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 50 def initialize(name, version, productcode, packagecode) super(name, version) @productcode = productcode @packagecode = packagecode end |
Instance Attribute Details
#packagecode ⇒ Object (readonly)
7 8 9 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 7 def packagecode @packagecode end |
#productcode ⇒ Object (readonly)
7 8 9 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 7 def productcode @productcode end |
Class Method Details
.from_registry(name, values) ⇒ Object
Return an instance of the package from the registry, or nil
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 28 def self.from_registry(name, values) if valid?(name, values) inst = installer if inst.ProductState(name) == INSTALLSTATE_DEFAULT MsiPackage.new(get_display_name(values), values['DisplayVersion'], name, # productcode inst.ProductInfo(name, 'PackageCode')) end end end |
.install_command(resource) ⇒ Object
64 65 66 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 64 def self.install_command(resource) ['msiexec.exe', '/qn', '/norestart', '/i', munge(resource[:source])] end |
.installer ⇒ Object
Get the COM installer object, it’s in a separate method for testing
22 23 24 25 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 22 def self.installer # REMIND: when does the COM release happen? WIN32OLE.new("WindowsInstaller.Installer") end |
.valid?(name, values) ⇒ Boolean
Is this a valid MSI package we should manage?
42 43 44 45 46 47 48 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 42 def self.valid?(name, values) # See http://community.spiceworks.com/how_to/show/2238 displayName = get_display_name(values) !!(displayName && displayName.length > 0 && values['WindowsInstaller'] == 1 && # DWORD name =~ /\A\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}\Z/i) end |
Instance Method Details
#match?(resource) ⇒ Boolean
Does this package match the resource?
58 59 60 61 62 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 58 def match?(resource) resource[:name].casecmp(packagecode) == 0 || resource[:name].casecmp(productcode) == 0 || resource[:name] == name end |
#uninstall_command ⇒ Object
68 69 70 |
# File 'lib/puppet/provider/package/windows/msi_package.rb', line 68 def uninstall_command ['msiexec.exe', '/qn', '/norestart', '/x', productcode] end |