class Puppet::Provider::Package::Windows::ExePackage

Constants

REG_VALUE_NAMES

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

Attributes

uninstall_string[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/exe_package.rb
27 def self.from_registry(name, values)
28   if valid?(name, values)
29     ExePackage.new(
30       get_display_name(values),
31       values['DisplayVersion'],
32       values['UninstallString']
33     )
34   end
35 end
install_command(resource) click to toggle source
   # File lib/puppet/provider/package/windows/exe_package.rb
63 def self.install_command(resource)
64   file_location = resource[:source]
65   if file_location.start_with?('http://', 'https://')
66     tempfile = Tempfile.new(['','.exe'])
67     begin
68       uri = URI(Puppet::Util.uri_encode(file_location))
69       client = Puppet.runtime[:http]
70       client.get(uri, options: { include_system_store: true }) do |response|
71         raise Puppet::HTTP::ResponseError.new(response) unless response.success?
72 
73         File.open(tempfile.path, 'wb') do |file|
74           response.read_body do |data|
75             file.write(data)
76           end
77         end
78       end
79     rescue => detail
80       raise Puppet::Error.new(_("Error when installing %{package}: %{detail}") % { package: resource[:name] ,detail: detail.message}, detail)
81     ensure
82       self.register(tempfile.path)
83       tempfile.close()
84       file_location = tempfile.path
85     end
86   end
87 
88   munge(file_location)
89 end
new(name, version, uninstall_string) click to toggle source
   # File lib/puppet/provider/package/windows/exe_package.rb
52 def initialize(name, version, uninstall_string)
53   super(name, version)
54 
55   @uninstall_string = uninstall_string
56 end
register(path) click to toggle source
   # File lib/puppet/provider/package/windows/exe_package.rb
21 def self.register(path)
22   Puppet::Type::Package::ProviderWindows.paths ||= []
23   Puppet::Type::Package::ProviderWindows.paths << path
24 end
valid?(name, values) click to toggle source

Is this a valid executable package we should manage?

   # File lib/puppet/provider/package/windows/exe_package.rb
38 def self.valid?(name, values)
39   # See http://community.spiceworks.com/how_to/show/2238
40   displayName = get_display_name(values)
41   !!(displayName && displayName.length > 0 &&
42      values['UninstallString'] &&
43      values['UninstallString'].length > 0 &&
44      values['WindowsInstaller'] != 1 && # DWORD
45      name !~ /^KB[0-9]{6}/ &&
46      values['ParentKeyName'] == nil &&
47      values['Security Update'] == nil &&
48      values['Update Rollup'] == nil &&
49      values['Hotfix'] == nil)
50 end

Public Instance Methods

match?(resource) click to toggle source

Does this package match the resource?

   # File lib/puppet/provider/package/windows/exe_package.rb
59 def match?(resource)
60   resource[:name] == name
61 end
uninstall_command() click to toggle source
    # File lib/puppet/provider/package/windows/exe_package.rb
 91 def uninstall_command
 92   # Only quote bare uninstall strings, e.g.
 93   #   C:\Program Files (x86)\Notepad++\uninstall.exe
 94   # Don't quote uninstall strings that are already quoted, e.g.
 95   #   "c:\ruby187\unins000.exe"
 96   # Don't quote uninstall strings that contain arguments:
 97   #   "C:\Program Files (x86)\Git\unins000.exe" /SILENT
 98   if uninstall_string =~ /\A[^"]*.exe\Z/i
 99     command = "\"#{uninstall_string}\""
100   else
101     command = uninstall_string
102   end
103 
104   command
105 end