Class: Puppet::Provider::Package::Windows::ExePackage

Inherits:
Package show all
Defined in:
lib/puppet/provider/package/windows/exe_package.rb

Constant Summary collapse

REG_VALUE_NAMES =

registry values to load under each product entry in HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall for this provider

[
  'DisplayVersion',
  'UninstallString',
  'ParentKeyName',
  'Security Update',
  'Update Rollup',
  'Hotfix',
  '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

Instance Attribute Summary collapse

Attributes inherited from Package

#name, #version

Class Method Summary collapse

Instance Method Summary collapse

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::Windows::Registry

#delete_key, #delete_value, #each_key, #each_value, #keys, #open, #root, #values, #values_by_name

Methods included from FFI::Library

#attach_function_private

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Methods included from Enumerable

#uniq

Constructor Details

#initialize(name, version, uninstall_string) ⇒ ExePackage

Returns a new instance of ExePackage


46
47
48
49
50
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 46

def initialize(name, version, uninstall_string)
  super(name, version)

  @uninstall_string = uninstall_string
end

Instance Attribute Details

#uninstall_stringObject (readonly)


5
6
7
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 5

def uninstall_string
  @uninstall_string
end

Class Method Details

.from_registry(name, values) ⇒ Object

Return an instance of the package from the registry, or nil


21
22
23
24
25
26
27
28
29
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 21

def self.from_registry(name, values)
  if valid?(name, values)
    ExePackage.new(
      get_display_name(values),
      values['DisplayVersion'],
      values['UninstallString']
    )
  end
end

.install_command(resource) ⇒ Object


57
58
59
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 57

def self.install_command(resource)
  munge(resource[:source])
end

.valid?(name, values) ⇒ Boolean

Is this a valid executable package we should manage?


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 32

def self.valid?(name, values)
  # See http://community.spiceworks.com/how_to/show/2238
  displayName = get_display_name(values)
  !!(displayName && displayName.length > 0 &&
     values['UninstallString'] &&
     values['UninstallString'].length > 0 &&
     values['WindowsInstaller'] != 1 && # DWORD
     name !~ /^KB[0-9]{6}/ &&
     values['ParentKeyName'] == nil &&
     values['Security Update'] == nil &&
     values['Update Rollup'] == nil &&
     values['Hotfix'] == nil)
end

Instance Method Details

#match?(resource) ⇒ Boolean

Does this package match the resource?


53
54
55
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 53

def match?(resource)
  resource[:name] == name
end

#uninstall_commandObject


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/puppet/provider/package/windows/exe_package.rb', line 61

def uninstall_command
  # Only quote bare uninstall strings, e.g.
  #   C:\Program Files (x86)\Notepad++\uninstall.exe
  # Don't quote uninstall strings that are already quoted, e.g.
  #   "c:\ruby187\unins000.exe"
  # Don't quote uninstall strings that contain arguments:
  #   "C:\Program Files (x86)\Git\unins000.exe" /SILENT
  if uninstall_string =~ /\A[^"]*.exe\Z/i
    command = "\"#{uninstall_string}\""
  else
    command = uninstall_string
  end

  command
end