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 26 def self.from_registry(name, values) 27 if valid?(name, values) 28 ExePackage.new( 29 get_display_name(values), 30 values['DisplayVersion'], 31 values['UninstallString'] 32 ) 33 end 34 end
install_command(resource)
click to toggle source
# File lib/puppet/provider/package/windows/exe_package.rb 62 def self.install_command(resource) 63 file_location = resource[:source] 64 if file_location.start_with?('http://', 'https://') 65 tempfile = Tempfile.new(['','.exe']) 66 begin 67 uri = URI(Puppet::Util.uri_encode(file_location)) 68 client = Puppet.runtime[:http] 69 client.get(uri, options: { include_system_store: true }) do |response| 70 raise Puppet::HTTP::ResponseError.new(response) unless response.success? 71 72 File.open(tempfile.path, 'wb') do |file| 73 response.read_body do |data| 74 file.write(data) 75 end 76 end 77 end 78 rescue => detail 79 raise Puppet::Error.new(_("Error when installing %{package}: %{detail}") % { package: resource[:name] ,detail: detail.message}, detail) 80 ensure 81 self.register(tempfile.path) 82 tempfile.close() 83 file_location = tempfile.path 84 end 85 end 86 87 munge(file_location) 88 end
new(name, version, uninstall_string)
click to toggle source
Calls superclass method
Puppet::Provider::Package::Windows::Package::new
# File lib/puppet/provider/package/windows/exe_package.rb 51 def initialize(name, version, uninstall_string) 52 super(name, version) 53 54 @uninstall_string = uninstall_string 55 end
register(path)
click to toggle source
# File lib/puppet/provider/package/windows/exe_package.rb 20 def self.register(path) 21 Puppet::Type::Package::ProviderWindows.paths ||= [] 22 Puppet::Type::Package::ProviderWindows.paths << path 23 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 37 def self.valid?(name, values) 38 # See http://community.spiceworks.com/how_to/show/2238 39 displayName = get_display_name(values) 40 !!(displayName && displayName.length > 0 && 41 values['UninstallString'] && 42 values['UninstallString'].length > 0 && 43 values['WindowsInstaller'] != 1 && # DWORD 44 name !~ /^KB[0-9]{6}/ && 45 values['ParentKeyName'] == nil && 46 values['Security Update'] == nil && 47 values['Update Rollup'] == nil && 48 values['Hotfix'] == nil) 49 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 58 def match?(resource) 59 resource[:name] == name 60 end
uninstall_command()
click to toggle source
# File lib/puppet/provider/package/windows/exe_package.rb 90 def uninstall_command 91 # Only quote bare uninstall strings, e.g. 92 # C:\Program Files (x86)\Notepad++\uninstall.exe 93 # Don't quote uninstall strings that are already quoted, e.g. 94 # "c:\ruby187\unins000.exe" 95 # Don't quote uninstall strings that contain arguments: 96 # "C:\Program Files (x86)\Git\unins000.exe" /SILENT 97 if uninstall_string =~ /\A[^"]*.exe\Z/i 98 command = "\"#{uninstall_string}\"" 99 else 100 command = uninstall_string 101 end 102 103 command 104 end